zango123
zango123

Reputation: 1658

Cucumber's support/hooks.rb equivalent in Rspec

I need to write timestamps to a log file before each rspec test. With cucumber this can be acomplished easily by using hooks.rb. Is there an equivalent way to do this with Rspec? Mind you that this has to be done in a centralized manner. It's not practical for me to place code before each rspec file because my test suite is quite large.

Upvotes: 0

Views: 167

Answers (1)

zango123
zango123

Reputation: 1658

Just figured it out myself.

In the spec_helper.rb file, within a

RSpec.configure do |config|
...
end 

block place the following code:

config.before(:each) do
  puts 'this line will be executed before each test'
end

Upvotes: 1

Related Questions