-
-
Save JonRowe/f19eb6f69692f90a1b26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe do | |
module Global | |
class << self | |
attr_accessor :shared_state | |
end | |
end | |
shared_examples_for "example" do |value| | |
puts "Defining state: #{Global.shared_state = value}" | |
specify do | |
puts "Using state #{Global.shared_state}" | |
expect(Global.shared_state).to eq value | |
end | |
end | |
it_should_behave_like "example", :my_value | |
it_should_behave_like "example", :other_value | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Defining state: my_value | |
Defining state: other_value | |
Using state other_value | |
Using state other_value | |
F. | |
Failures: | |
1) it should behave like example should eq :my_value | |
Failure/Error: expect(Global.shared_state).to eq value | |
expected: :my_value | |
got: :other_value | |
(compared using ==) | |
Diff: | |
@@ -1,2 +1,2 @@ | |
-:my_value | |
+:other_value | |
Shared Example Group: "example" called from ./examples_spec.rb:17 | |
# ./examples_spec.rb:13:in `block (3 levels) in <top (required)>' | |
Finished in 0.00108 seconds | |
2 examples, 1 failure | |
Failed examples: | |
rspec ./examples_spec.rb:11 # it should behave like example should eq :my_value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment