it "should have an attribute named booze" do @martini.should respond_to(:booze) @martini.should respond_to(:booze=) end it "should have an attribute named garnish" do @martini.should respond_to(:garnish) @martini.should respond_to(:garnish=) end end Martini Spec Draft
Barkeep::Martini.new end it "should have an attribute named booze" do @martini.should have_attribute(:booze) end it "should have an attribute named garnish" do @martini.should have_attribute(:garnish) end end Custom Matcher
it "should have an attribute named booze" do subject.should have_attribute(:booze) end it "should have an attribute named garnish" do subject.should have_attribute(:garnish) end end subject()
it "should have an attribute named booze" do should have_attribute(:booze) end it "should have an attribute named garnish" do should have_attribute(:garnish) end end Implicit subject()
it "should have an attribute named booze" do @martini.should respond_to(:booze) @martini.should respond_to(:booze=) end it "should have an attribute named garnish" do @martini.should respond_to(:garnish) @martini.should respond_to(:garnish=) end end Original Draft
it { should have_attribute(:glass) } ! it "should have an ingredients Array" do subject.ingredients.should be_a Array end end Whiskey & Martini #ingredients
have_attribute(:garnish) } it { should have_attribute(:mixer) } context "with a mixer" do before do @mixer = 'vermouth' subject.mixer = @mixer end it "should include mixer in ingredients" do subject.ingredients.should include @mixer end end context()
have_attribute(:garnish) } it { should have_attribute(:mixer) } context "with a mixer" do let(:mixer) { 'vermouth' } before { subject.mixer = mixer } it "should include mixer in ingredients" do subject.ingredients.should include mixer end end end let()
have_attribute(:garnish) } it { should have_attribute(:mixer) } context "with a mixer" do let(:mixer) { 'vermouth' } before { subject.mixer = mixer } its(:ingredients) { should include mixer } end end its()
have_attribute(:garnish) } it { should have_attribute(:mixer) } end ! describe Barkeep::Martini, ".new with mixer" do let(:mixer) { 'vermouth' } subject { Barkeep::Martini.new(:mixer => mixer) } its(:ingredients) { should include mixer } end its()
{ double("Espon 5000") } subject { Barkeep::Terminal.new(:ip => ones) } ! before do Printer.stub(:new) { epson } end ! it "should have a printer" do subject.printer.should eq epson end end stub()
{ double("Espon 5000") } subject { Barkeep::Terminal.new(:ip => ones) } ! it "should have a printer" do Printer.should_receive(:new). with(:ip => ones) { epson } subject.printer end end should_receive()
{} # run before each example config.after (:each) {} # run after each example config.after (:all) {} # run once ! # run before each example of type :model config.before(:each, :type => :model) {} end RSpec.configure
{|version| !(RUBY_VERSION.to_s =~ /^#{version.to_s}/) }} end ! # in any spec file describe "something" do it "does something", :ruby => 1.8 do # .... end it "does something", :ruby => 1.9 do # .... Exclusion
should have_many(:posts) } it { should validate_presence_of(:email) } it { should allow_value("[email protected]").for(:email) } it { should_not allow_value("test").for(:email) } end