Skip to content

Instantly share code, notes, and snippets.

@amitpatelx
Created March 16, 2012 10:37
Show Gist options
  • Save amitpatelx/2049502 to your computer and use it in GitHub Desktop.
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.
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