[rspec-users] How do we test a Rails Model which does not have an equivalent table in the backend using RSpec

Mohnish J. lists at ruby-forum.com
Mon Nov 21 21:11:08 EST 2011


Sidu Ponnappa wrote in post #1032900:
>> I'm getting a common error for all such defined methods saying that>
> `database_name.table_name does not exist`. Well , this is true but how>
> should is
> it really making a difference?, and how to get a work around> for this
> to just
> test a simple use case of calling a method successfully> in the above
> context.
> I don't believe this issue has anything to do with RSpec (you'd see
> the same if you used MiniTest or any other tool).
>
> You want to have Moderator be a simple Ruby object, or possibly have
> it inherit from ActiveModel rather than ActiveRecord.
>
> Best,
> Sidu.
> http://c42.in
> http://rubymonk.com

Thanks for your inputs Sidu,I tried replacing ActiveRecord with 
ActiveModel got the following error:-


/home/mohnish/.rvm/gems/ruby-1.9.2-p180/gems/restfulie-1.0.3/lib/restfulie/server/action_controller/patch.rb:2: 
warning: already initialized constant HTTP_METHODS
/home/mohnish/Cognizant/socialtango/app/models/admin_stats.rb:1:in `<top 
(required)>': uninitialized constant ActiveModel::Base (NameError)


Seems like, I will have to look for another workaround..

-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list