Problem with Rails 3 and have_scope

30 views
Skip to first unread message

ericindc

unread,
Jan 14, 2011, 7:04:26 PM1/14/11
to Remarkable
I'm not sure how to get have_scope passing. I'm on Rails 3.0.3 with
using the alpha4 version of remarkable_activerecord. According to the
docs, what I have should work.

Failure/Error: it { should have_scope(:latest).limit(3) }
Expected :latest when called on Post scope to SELECT "posts".*
FROM "posts" WHERE (published_at is not null) ORDER BY published_at
desc LIMIT 3, got SELECT "posts".* FROM "posts" WHERE (published_at is
not null) ORDER BY published_at desc LIMIT 3



class Post < ActiveRecord::Base
has_many :comments

scope :latest, limit(3)

default_scope where('published_at is not null').order('published_at
desc')
end



require 'spec_helper'

describe Post do
it { should have_many(:comments) }

# Commented out because this breaks with an error about an array
index. Any ideas?
#
#it { should have_default_scope.where('published_at is not
null').order('published_at desc') }
it { should have_scope(:latest).limit(3) }
end

ericindc

unread,
Jan 14, 2011, 7:24:36 PM1/14/11
to Remarkable
So it looks like have_scope and have_default_scope both don't work.
Is there a solution to this? Thanks.

Christopher Dell

unread,
Jan 26, 2011, 10:17:18 AM1/26/11
to Remarkable
I'm seeing the same behaviour where the expected SQL is identical to
the received SQL, but the spec fails.

rails (3.0.3)
rspec (2.3.0)
remarkable_activemodel (4.0.0.alpha4)
remarkable_activerecord (4.0.0.alpha4)

On Jan 15, 1:24 am, ericindc <ericmilf...@gmail.com> wrote:
> So it looks likehave_scopeand have_default_scope both don't work.
> Is there a solution to this?  Thanks.
>
> On Jan 14, 7:04 pm, ericindc <ericmilf...@gmail.com> wrote:
>
>
>
> > I'm not sure how to gethave_scopepassing.  I'm on Rails 3.0.3 with
> > using the alpha4 version of remarkable_activerecord.  According to the
> > docs, what I have should work.
>
> > Failure/Error: it { shouldhave_scope(:latest).limit(3) }
Reply all
Reply to author
Forward
0 new messages