[rspec-users] rspec and should have_many through

Justin Ko jko170 at gmail.com
Tue Sep 13 21:41:15 EDT 2011


On Tue, Sep 13, 2011 at 8:53 PM, slavix <mikerin.slava at gmail.com> wrote:

> Hi,
> Anyone can help me with rspec shoulda validations  please.
> I can't get the syntax right for these validations. Please correct me
>
>    it { should have_one :tradable, :through => :trade_order}
>    it { should belong_to :source,   :polymorphic => true }
>    it { should have_many :transfers, :as => :source }
>
> this is for Rspec 2, rails 3.1,
>
>  gem "rspec-rails"
>  gem "remarkable_activerecord", "~> 4.0.0.alpha4"
>  gem 'rspec-rails-ext'
>  gem 'rspec-rails-matchers'
>  gem "shoulda-matchers"
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>

I believe remarkable_activerecord and shoulda-matchers have conflicting
API's? Also, looks like you need to use methods, rather than symbols as
arguments:

it { should have_one(:tradable).through(:trade_order) }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110913/2b20e8ce/attachment.html>


More information about the rspec-users mailing list