Rspec - specific_specs options
Sometime, we need to do something different in some specific test cases.
It’s reason why rspec supports option specific_specs
.
For example:
before(:each, specific_specs: true) do
puts "before hook runs"
end
it 'wont run the before hook' do
true
end
it 'will run the before hook', specific_specs: true do
true
end
The code below is full version for this example:
describe("something", specific_specs: true) do
before(:each, specific_specs: true) do
puts "before hook runs"
end
it 'wont run the before hook', specific_specs: false do
true
end
it 'will run the before hook' do
true
end
end
Or if you want to convert specific_specs position, you could try:
describe("something", specific_specs: false) do
before(:each, specific_specs: false) do
puts "before hook runs"
end
it 'will run the before hook' do
true
end
it 'wont run the before hook', specific_specs: true do
true
end
end