[rspec-users] params not available for controller specs?

2007-12-04 Thread Al Chou
Hi, all, I'm trying to write a spec for a controller method that starts out: def download @orders = Order.find( params[:ids] ) ... and started writing a spec that set params[:ids] to a mock. I was surprised to discover that controller specs (at least in RSpec 1.0.8) don't offer the

Re: [rspec-users] params not available for controller specs?

2007-12-04 Thread Jarkko Laine
On 4.12.2007, at 10.17, Al Chou wrote: > Hi, all, > > I'm trying to write a spec for a controller method that starts out: > > > def download > @orders = Order.find( params[:ids] ) > ... > > and started writing a spec that set params[:ids] to a mock. Why would you want to set params[:id

Re: [rspec-users] params not available for controller specs?

2007-12-04 Thread Al Chou
I actually did stub Order.find() but was getting a nil object error because params[:ids] was nil. I can't write controller.download :ids => '1/2/3' in the controller spec, and get download, :ids => ids_string results in the following error message: NameError in 'Admin::OrdersController s

Re: [rspec-users] params not available for controller specs?

2007-12-04 Thread Daniel Tenner
Try: get :download, :ids => ids_string You need the ":" in front of the action name. Daniel On 4 Dec 2007, at 09:28 4 Dec 2007, Al Chou wrote: I actually did stub Order.find() but was getting a nil object error because params[:ids] was nil. I can't write controller.download :ids => '1/2/3

Re: [rspec-users] params not available for controller specs?

2007-12-04 Thread Al Chou
Ah, thanks! That was a breakthrough. My mock object "ids_string" isn't receiving the method calls I expect (even though the code under test actually does what I want it to do and works correctly), but at least I'm past the params issue. Al - Original Message From: Daniel Tenner <[E

Re: [rspec-users] params not available for controller specs?

2007-12-04 Thread Jarkko Laine
On 4.12.2007, at 17.13, Al Chou wrote: > Ah, thanks! That was a breakthrough. My mock object "ids_string" > isn't receiving the method calls I expect (even though the code > under test actually does what I want it to do and works correctly), > but at least I'm past the params issue. You d

[rspec-users] Newbie question

2007-12-04 Thread Andy Goundry
Good day all :-) I am getting into RSpec and am a little confused by an aspect of mocks / mock_models in controller tests. I've gone through the online docs and the PeepCode movies and have them slightly contradictory on this matter. I hope you can clarify. Many thanks in advance :-) I'm writing

Re: [rspec-users] Newbie question

2007-12-04 Thread Tom Stuart
On 4 Dec 2007, at 15:41, Andy Goundry wrote: > I've created the following spec test to simply ensure that the > Account model receives a call to :new, but the spec is failing as it > also receives a call to :save! and it isn't expecting it. I am using > "@account = mock_model(Account)". If i

Re: [rspec-users] Newbie question

2007-12-04 Thread Andy Goundry
cheers Tom. That worked. I'll go dig in the rspec source... On 04/12/2007, Tom Stuart <[EMAIL PROTECTED]> wrote: > > On 4 Dec 2007, at 15:41, Andy Goundry wrote: > > I've created the following spec test to simply ensure that the > > Account model receives a call to :new, but the spec is failing as

Re: [rspec-users] params not available for controller specs?

2007-12-04 Thread Al Chou
Going back to my original message, I have the following at the beginning of the download method: def download @orders = Order.find( params[:ids] ) ... The problem is that params[:ids], although built as an Array object by the view that calls the download method on the controller, is pa

Re: [rspec-users] params not available for controller specs?

2007-12-04 Thread Jarkko Laine
On 4.12.2007, at 18.19, Al Chou wrote: > Going back to my original message, I have the following at the > beginning of the download method: > > def download >@orders = Order.find( params[:ids] ) >... > > The problem is that params[:ids], although built as an Array object > by the vi

[rspec-users] Unexpected message on :attr_accessor

2007-12-04 Thread schleg
This may be a dumb noob issue, but I haven't found any answers while seaching the forum-- I have a controller method def edit @user = User.find params[:id] @user.password_confirmation = @user.password end The User class has an "attr_accessor :password_confirmation" definition (so "p

Re: [rspec-users] Unexpected message on :attr_accessor

2007-12-04 Thread David Chelimsky
On Dec 4, 2007 11:49 AM, schleg <[EMAIL PROTECTED]> wrote: > > This may be a dumb noob issue, but I haven't found any answers while seaching > the forum-- > > I have a controller method > > def edit > @user = User.find params[:id] > @user.password_confirmation = @user.password > end > >

Re: [rspec-users] Unexpected message on :attr_accessor

2007-12-04 Thread aslak hellesoy
On Dec 4, 2007 8:02 PM, David Chelimsky <[EMAIL PROTECTED]> wrote: > On Dec 4, 2007 11:49 AM, schleg <[EMAIL PROTECTED]> wrote: > > > > This may be a dumb noob issue, but I haven't found any answers while > > seaching > > the forum-- > > > > I have a controller method > > > > def edit > > @u

Re: [rspec-users] params not available for controller specs?

2007-12-04 Thread Al Chou
I get what you're saying, but I was trying to fix a bug in existing code in Substruct (that I did not write) that was caused by Rails passing the array as a /-delimited string and then not automatically decoding that string. As Substruct does not say that Edge Rails is a requirement, I felt it

[rspec-users] svn: Connection closed unexpectedly when getting trunk

2007-12-04 Thread Chris Olsen
Is anyone else getting this message? With rails 2.0 pre-releases it looks like you also have to be working with the latest version of rpsec. $ ruby script/plugin install svn://rubyforge.org/var/svn/rspec/trunk/rspec svn: Connection closed unexpectedly The above is what I get when I try to instal

Re: [rspec-users] [ANN] Webrat 0.1.0 released - Ruby Acceptance Testing for Web applications

2007-12-04 Thread David Chelimsky
On Nov 30, 2007 3:28 PM, Jens-Christian Fischer <[EMAIL PROTECTED]> wrote: > > > > Code is available at: http://svn.eastmedia.net/public/plugins/webrat/ > > > * Rails integration tests in Test::Unit _or_ > > * RSpec stories (using an RSpec version >= revision 2997) > > I had to add: > > require 'cg

Re: [rspec-users] params not available for controller specs?

2007-12-04 Thread David Chelimsky
On Dec 4, 2007 2:09 PM, Al Chou <[EMAIL PROTECTED]> wrote: > > I get what you're saying, but I was trying to fix a bug in existing code in > Substruct (that I did not write) that was caused by Rails passing the array > as a /-delimited string and then not automatically decoding that string. As > S

Re: [rspec-users] svn: Connection closed unexpectedly when getting trunk

2007-12-04 Thread David Chelimsky
On Dec 4, 2007 2:13 PM, Chris Olsen <[EMAIL PROTECTED]> wrote: > Is anyone else getting this message? > > With rails 2.0 pre-releases it looks like you also have to be working > with the latest version of rpsec. > > $ ruby script/plugin install > svn://rubyforge.org/var/svn/rspec/trunk/rspec > svn:

Re: [rspec-users] svn: Connection closed unexpectedly when getting trunk

2007-12-04 Thread Scott Taylor
On Dec 4, 2007, at 3:20 PM, David Chelimsky wrote: > On Dec 4, 2007 2:13 PM, Chris Olsen <[EMAIL PROTECTED]> wrote: >> Is anyone else getting this message? >> >> With rails 2.0 pre-releases it looks like you also have to be working >> with the latest version of rpsec. >> >> $ ruby script/plugin i

[rspec-users] AutoTest / Rspec - "stack level too deep"

2007-12-04 Thread Matthew Lins
Hello, I'm running AutoTest with Rspec on a Rails application. Every 20 or so runs I get "stack level too deep" on one particular controller stub. Ex. controller.stub!(:login).and_return(true) This particular line is in a before block of a certain describe block. The strange thing is, every si

Re: [rspec-users] AutoTest / Rspec - "stack level too deep"

2007-12-04 Thread Shane Mingins
On 5/12/2007, at 9:43 AM, Matthew Lins wrote: > Hello, > > I'm running AutoTest with Rspec on a Rails application. > > Every 20 or so runs I get "stack level too deep" on one particular > controller stub. > > So this spec fails when you just run it?? I was a little unsure if you are having a

Re: [rspec-users] Unexpected message on :attr_accessor

2007-12-04 Thread Jonathan Linowes
>> >> This should be: >> >> @user.should_receive(:password_confirmation=) >> > > Lots of beginners make this mistake. Maybe RSpec's mock framework > should be smart enough to suggest this fix by itself. > > Patch anyone? > > Aslak >> perhaps be even more explicit that it's an accessor, like User

Re: [rspec-users] Unexpected message on :attr_accessor

2007-12-04 Thread David Chelimsky
On Dec 4, 2007 2:54 PM, Jonathan Linowes <[EMAIL PROTECTED]> wrote: > > >> > >> This should be: > >> > >> @user.should_receive(:password_confirmation=) > >> > > > > Lots of beginners make this mistake. Maybe RSpec's mock framework > > should be smart enough to suggest this fix by itself. > > > > Pa

Re: [rspec-users] Unexpected message on :attr_accessor

2007-12-04 Thread Jonathan Linowes
err, that suggestion was supposed to read @user.should_set... etc On Dec 4, 2007, at 3:54 PM, Jonathan Linowes wrote: > >>> >>> This should be: >>> >>> @user.should_receive(:password_confirmation=) >>> >> >> Lots of beginners make this mistake. Maybe RSpec's mock framework >> should be smart enou

Re: [rspec-users] params not available for controller specs?

2007-12-04 Thread Al Chou
I think Jarkko is saying that no spec should have been written for the code I was trying to fix/change. I'm not sure I would agree that BDD/RSpec is an inappropriate tool for documenting what I was trying to change, but I think he would argue that Al - Original Message From: Davi

Re: [rspec-users] Unexpected message on :attr_accessor

2007-12-04 Thread David Chelimsky
On Dec 4, 2007 3:00 PM, David Chelimsky <[EMAIL PROTECTED]> wrote: > On Dec 4, 2007 2:54 PM, Jonathan Linowes <[EMAIL PROTECTED]> wrote: > > > > >> > > >> This should be: > > >> > > >> @user.should_receive(:password_confirmation=) > > >> > > > > > > Lots of beginners make this mistake. Maybe RSpec'

Re: [rspec-users] svn: Connection closed unexpectedly when getting trunk

2007-12-04 Thread Chris Olsen
David Chelimsky wrote: > > Try: > > http://rspec.rubyforge.org/svn/trunk/rspec > http://rspec.rubyforge.org/svn/trunk/rspec_on_rails That worked much better. Thanks -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@r

Re: [rspec-users] params not available for controller specs?

2007-12-04 Thread Jarkko Laine
On 4.12.2007, at 23.11, Al Chou wrote: > I think Jarkko is saying that no spec should have been written for > the code I was trying to fix/change. I'm not sure I would agree > that BDD/RSpec is an inappropriate tool for documenting what I was > trying to change, but I think he would argue

[rspec-users] shared behaviour for all views

2007-12-04 Thread Edward Ocampo-Gooding
Is there a way I can write something like a shared behaviour for all views that just checks the page responds with a 200 status and has a title, meta tags, and an h1? Here's an idea for a shared behaviour (that only applies if I set views to use it manually with it_should_behave_like "a standar

Re: [rspec-users] Unexpected message on :attr_accessor

2007-12-04 Thread schleg
Thanks, David! Glad I'm unstuck on this :) David Chelimsky-2 wrote: > > On Dec 4, 2007 11:49 AM, schleg <[EMAIL PROTECTED]> wrote: >> >> This may be a dumb noob issue, but I haven't found any answers while >> seaching >> the forum-- >> >> I have a controller method >> >> def edit >> @user

Re: [rspec-users] params not available for controller specs?

2007-12-04 Thread Al Chou
OK, I see your strategy now. Rather than mock the String argument, mock Order to confirm that it gets called with an array. Nice! Al - Original Message From: Jarkko Laine <[EMAIL PROTECTED]> To: rspec-users Sent: Tuesday, December 4, 2007 1:49:17 PM Subject: Re: [rspec-users] params

Re: [rspec-users] Unexpected message on :attr_accessor

2007-12-04 Thread Jonathan Linowes
damn, looks like I'm going to have to come up with 997 more good ideas just to break even :) On Dec 4, 2007, at 4:18 PM, David Chelimsky wrote: >> >> -1000 >> ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinf

Re: [rspec-users] Unexpected message on :attr_accessor

2007-12-04 Thread David Chelimsky
On Dec 4, 2007 9:49 PM, Jonathan Linowes <[EMAIL PROTECTED]> wrote: > damn, looks like I'm going to have to come up with 997 more good > ideas just to break even > :) Tell you what, I'll withdraw 999 and leave it as a -1. That leaves you at +2 I believe. > On Dec 4, 2007, at 4:18 PM, David Chelim

Re: [rspec-users] Unexpected message on :attr_accessor

2007-12-04 Thread David Chelimsky
On Dec 4, 2007 9:56 PM, David Chelimsky <[EMAIL PROTECTED]> wrote: > On Dec 4, 2007 9:49 PM, Jonathan Linowes <[EMAIL PROTECTED]> wrote: > > damn, looks like I'm going to have to come up with 997 more good > > ideas just to break even > > :) > > Tell you what, I'll withdraw 999 and leave it as a -1