Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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