I am new to ruby and ruby on rails. How can I stub attributes in a class?
class User < PresentationModel
...
attr_accessor :_vendor
_vendor is in my databse and has three columns: ID, shortname, type. How can I only stub this attirbute in rspec?
Something like this?
@vendor = mock_model(vendor, :ID=> 12, :shortname => 'testBLA', :type => 1)
Cheers
You can stub this attribute only by:
(Attention for the Rails id convention)
And then:
User.should_receive(:_vendor).and_return @vendor
You can check this question too.