Skip to content

Instantly share code, notes, and snippets.

@malclocke
Last active September 19, 2016 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malclocke/117786bf593c3ffde6f2 to your computer and use it in GitHub Desktop.
Save malclocke/117786bf593c3ffde6f2 to your computer and use it in GitHub Desktop.
# Example integration spec for a Rake task in Rails
#
# cat <<EOT > lib/tasks/myapp.rake
# namespace :myapp do
# task :mytask => :environment do
# puts "Hello"
# end
# end
# EOT
require "rails_helper"
describe "Rake tasks" do
before(:all) do
Myapp::Application.load_tasks
end
describe "myapp:mytask" do
subject { Rake::Task["myapp:mytask"] }
specify do
# Run the rake task and store the output
output = capture(:stdout) do
subject.invoke
end
expect(output).to match /Hello/
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment