Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seems to have trouble with default_scope in rails 3 (beta 4) #14

Open
ludicast opened this issue Jul 3, 2010 · 2 comments
Open

seems to have trouble with default_scope in rails 3 (beta 4) #14

ludicast opened this issue Jul 3, 2010 · 2 comments
Labels

Comments

@ludicast
Copy link

ludicast commented Jul 3, 2010

The scope is: default_scope order('start_at')

The spec is: it { should have_default_scope.order('start_at') }

I get the below error with & without the order method tacked on to the matcher. Also, I noticed that the spec is for 2.3.3 only so maybe this functionality isn't available yet in 3.0.

The relevant portion of the stack trace is:

/Users/natekidwell/.rvm/gems/ruby-1.8.7-p174@thefannypack/gems/activerecord-3.0.0.beta4/lib/active_record/relation.rb:331:in []': Symbol as array index (TypeError) from /Users/natekidwell/.rvm/gems/ruby-1.8.7-p174@thefannypack/gems/activerecord-3.0.0.beta4/lib/active_record/relation.rb:331:insend'
from /Users/natekidwell/.rvm/gems/ruby-1.8.7-p174@thefannypack/gems/activerecord-3.0.0.beta4/lib/active_record/relation.rb:331:in method_missing' from /Users/natekidwell/.rvm/gems/ruby-1.8.7-p174@thefannypack/gems/remarkable_activerecord-4.0.0.alpha4/lib/remarkable/active_record/matchers/have_default_scope_matcher.rb:19:indefault_scope'
from /Users/natekidwell/.rvm/gems/ruby-1.8.7-p174@thefannypack/gems/remarkable_activerecord-4.0.0.alpha4/lib/remarkable/active_record/matchers/have_default_scope_matcher.rb:19:in map!' from /Users/natekidwell/.rvm/gems/ruby-1.8.7-p174@thefannypack/gems/remarkable_activerecord-4.0.0.alpha4/lib/remarkable/active_record/matchers/have_default_scope_matcher.rb:19:indefault_scope'
from /Users/natekidwell/.rvm/gems/ruby-1.8.7-p174@thefannypack/gems/remarkable_activerecord-4.0.0.alpha4/lib/remarkable/active_record/matchers/have_default_scope_matcher.rb:26:in `interpolation_options'

@hosh
Copy link
Contributor

hosh commented Jul 6, 2010

You're probably not crazy. I have not yet had to use default_scope matcher. The scope matcher is funky in Remarkable 4, because we're basically calling .arel on the models and comparing arel objects. I did this because the scopes are now saved as lambda {} and no record of exactly what goes in there gets saved. I got the test working, but the last time I tried using have_scope in my project, it bombed. Having a tight timeline, I went ahead and cheated with respond_to instead of have_scope matcher; the default_scope matcher uses the same strategy so it is probably part of the same problem.

Anyone has a better way to do this, or maybe find out what the bug is?

@pivotal-casebook
Copy link

+1 I am having the exact same issue. It seems that have_default_scope is not a valid matcher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants