I have a strange situation when I run a separate rspec model specification file, all the examples are green, if I test my entire spec / models folder, all my examples are green. If I test the controllers, they all go green. If I test the entire package (via the rspec specifier), I get crashes. If I remove the controller tests, everything will be green. Now I expect this to be completely imposed, but I just can't understand.
I narrowed it down to concrete examples in controller tests, which leads to failure of the examples in the model specifications.
eg. in the notes_controller_spec.rb file, if this line is present
Note.any_instance.stubs(:valid?).returns(false)
it crashes in my models / account _spec.rb
Failure/Error: @account.all_notes.should have(2).notes ArgumentError: comparison of Note with Note failed ./app/models/account.rb:293:in `sort'
where is line 293:
(self.notes + self.transactions.map(&:notes).flatten).sort {|a,b| a.created_at <=> b.created_at }
I am sure this will be one of those moments in the palm of your hand, so be careful with me!
source share