Re: [rspec-users] spec'ing validates_uniqueness_of :whatever

2008-04-02 Thread Matt Berther
Hi Juanma, I do this this way: describe Model do def create(options={}) Model.create(options) end it "should not allow duplicate names" do model = create(:name => "name") new_model = create(:name => "name") new_model.should have_error_on(:name, :taken) end end -

Re: [rspec-users] newb q: Can story steps report a view rendering error?

2008-04-02 Thread Alex Satrapa
On 03/04/2008, at 10:09 , Tim Haines wrote: > For now I can add response.code.should == "200" or something similar.. The page returned by Rails to provide you with the stack trace and stuff? That is a valid HTML page, and it comes along with a HTTP 200 OK response. What you need to do is loo

Re: [rspec-users] Stub an instance method for every new instance of a class

2008-04-02 Thread Jed Hurt
Ahhh, clever. I see the light On Wed, Apr 2, 2008 at 8:19 AM, Corey Haines <[EMAIL PROTECTED]> wrote: > Create an instance of the controller > > contr = MyController.new > > MyController.stub!(:new).and_return contr > > contr.stub!(:method_i_want_to_stub).and_return 'sweetness' > > Something like

Re: [rspec-users] problem rendering template with story

2008-04-02 Thread Tim Haines
I got this way wrong. It was due to pages not rendering due to there being an error in the view (that I wasn't aware of). The problem in the view was due to the test database not being up to date with the latest migrations... (so page was rendering correctly in dev mode) I'm happy I've persisted

Re: [rspec-users] newb q: Can story steps report a view rendering error?

2008-04-02 Thread Kyle Hargraves
On Wed, Apr 2, 2008 at 6:09 PM, Tim Haines <[EMAIL PROTECTED]> wrote: > Hi'ya > > I have a When step that calls get game_url. It turns out that calling this > page is resulting in a render error, which explains my failing Then steps. > It would help me if the story told me there was a problem rend

[rspec-users] newb q: Can story steps report a view rendering error?

2008-04-02 Thread Tim Haines
Hi'ya I have a When step that calls get game_url. It turns out that calling this page is resulting in a render error, which explains my failing Then steps. It would help me if the story told me there was a problem rendering the response. Is there any way to get the story steps to automatically r

Re: [rspec-users] Given Logged In

2008-04-02 Thread Shane Mingins
Hi Tim I haven't had a chance to look at stories yet ... but can u not use the AuthenticatedTestHelper login_as method? Cheers Shane On 2/04/2008, at 6:16 PM, Tim Haines wrote: > Hi there, > > Given my recent problems with .should render_template after a second > post, I'm wondering if the

Re: [rspec-users] Stub an instance method for every new instance of a class

2008-04-02 Thread Corey Haines
Create an instance of the controller contr = MyController.new MyController.stub!(:new).and_return contr contr.stub!(:method_i_want_to_stub).and_return 'sweetness' Something like this? -Corey On Wed, Apr 2, 2008 at 12:22 AM, Jed Hurt <[EMAIL PROTECTED]> wrote: > I'm not sure how that would wo

Re: [rspec-users] [ANN] rspec_hpricot_matchers 1.0: have_tag on hpricot

2008-04-02 Thread Corey Haines
Just thought I'd send out a little update on using this library. Great! We converted our tests over to using it, and I'm very happy with it. Good job, Kyle! Keep up the good work. It did take a bit of time to convert (using @ in attributes, for example), but it was well worth it. -Corey On Wed, M

Re: [rspec-users] spec'ing validates_uniqueness_of :whatever

2008-04-02 Thread Pat Maddox
On Wed, Apr 2, 2008 at 1:19 AM, Courtenay <[EMAIL PROTECTED]> wrote: > IMO this function should be tested using the database, since it relies > heavily on the data. Agreed. Create a record, then create another record with duplicate data, and verify that the second record is invalid. Pat ___

Re: [rspec-users] spec'ing validates_uniqueness_of :whatever

2008-04-02 Thread Courtenay
IMO this function should be tested using the database, since it relies heavily on the data. Courtenay @(o..O)@ On Apr 2, 2008, at 1:13 AM, Juanma Cervera <[EMAIL PROTECTED]> wrote: > Hello > > I am learning rspec and trying to especify the activerecord > validations > of my

[rspec-users] spec'ing validates_uniqueness_of :whatever

2008-04-02 Thread Juanma Cervera
Hello I am learning rspec and trying to especify the activerecord validations of my models. How would I make a require_uniqueness_of specification for a field. Can I make this with mocks, without touching the database? Can somebody point me to some information or plugin for this issue. Thank you