Within my project, I have a number of models that have additional
methods
within them other than those provided by active record.
as an example (to keep it short and sweet)
class foo < ActiveRecod::Base
def status
“New Record”
end
def reset
“Reset”
end
end
in my spec file I have
require ‘spec_helper’
describe Foo do
before(:each) do
@foo = Foo.new()
end
it “should have a status of New Record”
@foo.status.should == “New Record”
end
it “should have a status of Reset after reset”
@foo.reset.should == “Reset”
end
end
however, when I run rake spec I get
NoMethodError in ‘Foo should have a status of New Record’
undefined method ‘status’ for #<Hash…>
and an equivalent one for the other method.
I am sure that this is something fundamental in my understanding, but
I’m
scuppered. I have spent the best part of a day trying to resolve this.
so,
- Why are my methods undefined, when they are there (I can create the
object via script/console and call the status and reset methods and see
them
work) - What is the best way of resolving the issue
Thanks