shared_context for rake tasks.
This gem is inspired by this post.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install rake_shared_context
If you have
rake reports:generate like following.
# lib/tasks/reports.rake namespace :reports do desc "Generate report" task :generate => :environment do ReportGenerator.generate end end
Then you can write following.
# spec/lib/tasks/reports_rake_spec.rb require 'spec_helper' describe "reports:generate" do include_context "rake" it 'prerequisites should include "environment"' do expect(subject.prerequisites).to include('environment') end it "generates the report" do expect(ReportGenerator).to receive(:generate) subject.invoke end end
- It expects that rake files are located under lib/tasks
- It expects that a argument is passed to
describeis task name
- Ruby 1.9.3, 2.0.0, 2.1.x, 2.2.x, 2.3.x
- Rspec 2, 3
To set up a development environment, do following
bundle install appraisal install bundle exec appraisal rspec-2 rake # test with rspec 2 bundle exec appraisal rspec-3 rake # test with rspec 3
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request