I''m having trouble figuring out why one of my specs passes when run
without --reverse and then fails with --reverse. What am I missing?
I''m using the plugin versions of both rspec and rspec_on_rails 0.9.2.
Here is the offending spec (Bill is an ActiveRecord model in a Rails app):
----------
describe Bill, " when valid" do
def valid_bill_attributes
{ :uuid => "ec5e943f-a819-433b-b786-ee847bb144e2",
:date => Date.today,
:amount => Money.new(15000) }
end
it "should have a uuid" do
bill = Bill.create(valid_bill_attributes)
bill.uuid = nil
bill.should have(2).errors_on(:uuid)
end
it "should have a uuid that is no longer than 36 characters" do
bill = Bill.create(valid_bill_attributes)
bill.uuid = bill.uuid + "1"
bill.should have(1).error_on(:uuid)
end
it "should have a uuid that is no shorter than 36 characters" do
bill = Bill.create(valid_bill_attributes)
bill.uuid = bill.uuid[0..34]
bill.should have(1).error_on(:uuid)
end
it "should have a case-insensitive, unique uuid" do
bill = Bill.create(valid_bill_attributes)
another = Bill.new(valid_bill_attributes)
another.should have(1).error_on(:uuid)
another.uuid = valid_bill_attributes[:uuid].upcase
another.should have(1).error_on(:uuid)
end
it "should have a date" do
bill = Bill.new(valid_bill_attributes.except(:date))
bill.should have(1).error_on(:date)
end
it "should have an amount_currency" do
bill = Bill.new(valid_bill_attributes)
bill.amount_currency = nil
bill.should have(1).error_on(:amount_currency)
end
it "should have an amount_cents greater than 0" do
bill = Bill.new(valid_bill_attributes)
bill.amount_cents = 0
bill.should have(1).error_on(:amount_cents)
bill.amount_cents = -2
bill.should have(1).error_on(:amount_cents)
end
end
describe Bill do
before(:each) do
@bill = Bill.new
@date = mock("date")
end
it "should return self.date.month when asked for :month" do
month = mock("month")
@bill.should_receive(:date).and_return(@date)
@date.should_receive(:month).and_return(month)
@bill.month.should == month
end
it "should return self.date.year when asked for :year" do
year = mock("year")
@bill.should_receive(:date).and_return(@date)
@date.should_receive(:year).and_return(year)
@bill.year.should == year
end
after(:each) do
@bill = nil
@date = nil
end
end
----------
And here is the output when I run the spec using the stock 0.9.2
spec.opts via ''spec -O spec/spec.opts
spec/models/bill_spec.rb'' (it
also fails when I run it via ''rake spec:models''):
----------
FFFFFFFFF
1)
NameError in ''Bill should return self.date.year when asked for
:year''
undefined method `date'' for class `Bill''
./spec/models/bill_spec.rb:71:
2)
NameError in ''Bill should return self.date.month when asked for
:month''
undefined method `date'' for class `Bill''
./spec/models/bill_spec.rb:64:
3)
NameError in ''Bill when valid should have an amount_cents greater than
0''
undefined method `proxied_by_rspec__date'' for class `Bill''
4)
NameError in ''Bill when valid should have an amount_currency''
undefined method `proxied_by_rspec__date'' for class `Bill''
5)
NameError in ''Bill when valid should have a date''
undefined method `proxied_by_rspec__date'' for class `Bill''
6)
NameError in ''Bill when valid should have a case-insensitive, unique
uuid''
undefined method `proxied_by_rspec__date'' for class `Bill''
7)
NameError in ''Bill when valid should have a uuid that is no shorter
than 36 characters''
undefined method `proxied_by_rspec__date'' for class `Bill''
8)
NameError in ''Bill when valid should have a uuid that is no longer
than 36 characters''
undefined method `proxied_by_rspec__date'' for class `Bill''
9)
NameError in ''Bill when valid should have a uuid''
undefined method `proxied_by_rspec__date'' for class `Bill''
----------