remarkable-rb / remarkable

Simplifying tests!
http://www.nomedojogo.com/category/remarkable/
MIT License
120 stars 64 forks source link

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

Open ludicast opened 14 years ago

ludicast commented 14 years ago

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 commented 14 years ago

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 commented 13 years ago

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