Question

My current Rakefile looks like this:

# ...

task :test do
    # build testing environment
    RSpec::Core::RakeTask.new(:spec) do |t|
        # ...
    end
    Rake::Task["spec"].execute
    # remove testing environment
end

Unfortunately this does not execute anything after Rake::Task["spec"].execute for some reasons that I can't possibly conceive.

So, is there a way to specify something to execute before and after the test suite runs, within the Rakefile?

Was it helpful?

Solution

If your specs failed, maybe that's why nothing after Rake::Task["spec"].execute gets executed. Instead of using the Rakefile, why not use Rspec's before(:suite) and after(:suite) hooks? You can put that code in your spec_helper.rb if you have one.

https://www.relishapp.com/rspec/rspec-core/v/2-0/docs/hooks/before-and-after-hooks#before/after-blocks-defined-in-config-are-run-in-order

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top