> The frustration your experiencing is actually a good thing, its your brain
> saying "hey something is just not right". Of
> course our natural reaction to this is just to get angry, but if we can get
> past that there is an opportunity to learn
> something important. In my limited experience I've found that listening to
> tests is one of the best ways to learn. There
> is probably something seriously wrong with your existing tests and code. So
> instead of trying to work around it, and get
> your tests to pass, seize the opportunity and try and work out why your tests
> and code suck and get to the bottom of the
> problem. This is a real opportunity to learn something.
I hear you, but honestly these tests are very straight forward and not
overly complicated in any way, shape, or form. I did some more
experimenting and was able to narrow the problem down to: Serialization and
Mocha.
class Foo < ActiveRecord::Base
serialize :bar
end
by using debugger within a test, I did:
> foo = Foo.create!
> foo.save
=> true
> foo.bar = stub("waka waka")
> foo.save
=> NoMethodError: undefined method `matches_method?' for nil:NilClass
from
/Users/bountybuy/.rvm/gems/ruby-1.9.3-p125@bountybuy/gems/mocha-0.10.5/lib/mocha/mock.rb:185:in
`respond_to?'
...
So the solution since using OpenStruct as an alternative was a disaster
is:
Foo.class_eval { attr_accessor :bar }
With that, ActiveRecord no longer handles the setter/getter methods
for that column, and this issue goes away.
AAAAAAAAAAAAGH!
So I am out of testing hell now.. yay!
Patrick J. Collins
http://collinatorstudios.com
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users