describe Cookie do
end
describe Cookie do
it "tastes yummy" do
end
end
describe Cookie do
it "tastes yummy" do
cookie = Cookie.new
cookie.chips.should == 72
end
end
describe Cookie do
it "has approximately 70 chips" do
cookie = Cookie.new
cookie.chips.should be_within(5).of(70)
end
end
should
should is called on[].should be_empty
method_missing magicbe_empty invokes empty? on its targetbe_valid invokes valid? on its targetdescribe Counter do
before do
@data = [0,1,2,3]
end
it "counts data" do
Counter.new(@data).count.should == 4
end
it "adds data too" do
Counter.new(@data).sum.should == 6
end
end
before blocks will be executed before each of the specs in that describe blockbefore :all do..end which executes only onceafter with similar semanticsdescribe Counter do
let(:data) { [0,1,2,3] }
it "counts data" do
Counter.new(data).count.should == 4
end
it "adds data too" do
Counter.new(data).sum.should == 6
end
end
describe Counter do
let(:data) { [0,1,2,3] }
subject { Counter.new(data) }
it { should be_a(Counter) }
it { should_not be_nil }
it "counts data" do
subject.count.should == 4
end
it "adds data"do
subject.sum.should == 6
end
end
/