Created
March 16, 2012 10:37
-
-
Save amitpatelx/2049502 to your computer and use it in GitHub Desktop.
This snippet(from The RSpec Book) shows how to define example group in RSpec.
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
require "rspec/expectations" | |
class Thing | |
def widgets | |
@widgets ||= [] | |
end | |
end | |
describe Thing do | |
before(:all) do | |
@thing = Thing.new | |
end | |
describe "initialized in before(:all)" do | |
it "has 0 widgets" do | |
@thing.should have(0).widgets | |
end | |
it "can get accept new widgets" do | |
@thing.widgets << Object.new | |
end | |
it "shares state across examples" do | |
@thing.should have(1).widgets | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment