Re: [rspec-users] Controller Spec & DataMapper Chaining

2011-03-20 Thread Sid Wood
Thats great advice and now that you've pointed it out it seems so obvious. Thanks Matt. See you at Cukeup! Sid On 19 March 2011 22:11, Matt Wynne wrote: > > On 19 Mar 2011, at 17:49, Sid Wood wrote: > > Thanks Ken, but when I said I was new to RSpec I didn't mean I was THAT > new! ;o) > > I thi

Re: [rspec-users] Controller Spec & DataMapper Chaining

2011-03-19 Thread Matt Wynne
On 19 Mar 2011, at 17:49, Sid Wood wrote: > Thanks Ken, but when I said I was new to RSpec I didn't mean I was THAT new! > ;o) > > I think people aren't grasping the DataMapper chaining that is at the root of > my testing confusion. I managed to come up with a solution that I've outlined > he

Re: [rspec-users] Controller Spec & DataMapper Chaining

2011-03-19 Thread Sid Wood
Thanks Ken, but when I said I was new to RSpec I didn't mean I was THAT new! ;o) I think people aren't grasping the DataMapper chaining that is at the root of my testing confusion. I managed to come up with a solution that I've outlined here http://pastie.org/1690040 Basically, I mocked out a cou

Re: [rspec-users] Controller Spec & DataMapper Chaining

2011-03-18 Thread Ken Chien
When calling get/post/etc, the second optional parameter is a hash representing the "params" hash. So, in order to test the conditional(s) in your controller, you should write: get :index, :alpha => true #test the first conditional In another example, pass in :beta => true like this: get

Re: [rspec-users] Controller Spec & DataMapper Chaining

2011-03-18 Thread Sid Wood
Thanks for the replies guys. My problem is writing a test for @widgets = @widgets.by_alpha(params[:alpha]) DataMapper allows you to chain additional criteria on an existing query and doesnt execute that query until in is used in the view. So the above statement gets baked into the previous defau

Re: [rspec-users] Controller Spec & DataMapper Chaining

2011-03-18 Thread Ken Chien
What problems are you running into? It appears that you should stub out Widget.all before all examples, unless you really want to hit the database. Ken 2011/3/18 Sid Wood > Hi there, > > I'm fairly new to RSpec, and DataMapper and I'm trying to write a > controller spec for an index action t

Re: [rspec-users] Controller Spec & DataMapper Chaining

2011-03-18 Thread Brian Ledsworth
Would you post the results of your spec? I'd like to see what you're getting. I'm not familiar with DataMapper, but from an Active Record standpoint, the order clause does not look right. e.g. should be Square.all.order(:name) Try running the spec without the order clause in index (e.g. Widget.

[rspec-users] Controller Spec & DataMapper Chaining

2011-03-18 Thread Sid Wood
Hi there, I'm fairly new to RSpec, and DataMapper and I'm trying to write a controller spec for an index action that will include DM query chaining. Here is a very simplified version of the Controller#index I'm working on def index @widgets = Widget.all(:order => [ :name.asc ]) if params[:a