Created
March 10, 2016 19:04
-
-
Save johana-star/18c1b6872bc39314ef47 to your computer and use it in GitHub Desktop.
RSpec example of order-dependent failure.
This file contains hidden or 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
RSpec.configure do |config| | |
config.order = :random | |
end | |
class Global | |
@@counter = 0 | |
def self.counter; @@counter; end | |
def self.increment_counter; @@counter += 1; end | |
end | |
RSpec.describe Global do | |
it "#counter is initialized to zero" do | |
expect(described_class.counter).to eq 0 | |
end | |
it "#increment_counter adds one to #counter" do | |
described_class.increment_counter | |
expect(described_class.counter).to eq 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment