'Alice' do before { greeting.gsub!('world', 'Alice') } it { expect(greeting).to eql 'Hello Alice!' } end context 'Bob' do before { greeting.gsub!('world', 'Bob') } it { expect(greeting).to eql 'Hello Bob!' } end end
'Alice' do before { greeting.gsub!('world', 'Alice') } it { expect(greeting).to eql 'Hello Alice!' } end context 'Bob' do before { greeting.gsub!('world', 'Bob') } it { expect(greeting).to eql 'Hello Bob!' } end end No isolation of the code to avoid the side effects
'Alice' do on :gsub!, 'world', 'Alice' do it { MUST eql 'Hello Alice!' } end end context 'Bob' do on :gsub!, 'world', 'Bob' do it { MUST eql 'Hello Bob!' } end end end
app do it { expect(app).to be 42 } end rspec 3-example/strange_app_spec.rb F 1. Failure: Expected "OMGLOL" to be 42. /Users/cyril/parisrb/3-example/strange_ app_spec.rb:10:in `block (2 levels) in <top (required)>' Ran 1 tests in 0.000195 seconds 0% compliant - 0 infos, 1 failures, 0 errors