Re: [rspec-users] Need help mocking this out

2007-12-16 Thread Daniel N
t;should find it's own articles" do >user = User.new >user.articles.should_receive(:find).with("1") >user.find_article("1) > end > end > > This has two benefits: > - each example is simpler and focuses on one object and how it behaves &g

Re: [rspec-users] Need help mocking this out

2007-12-03 Thread Daniel N
Assuming that there is a call like this in your controller @articles = current_user.articles One way to do this is to stub out the controller.current_user to return a mock object of the current_user Then put an expectation on the current user that it's articles method gets called. (return a mocke

Re: [rspec-users] Newbie question

2007-11-27 Thread Daniel N
On Nov 28, 2007 11:58 AM, Pito Salas <[EMAIL PROTECTED]> wrote: > I installed Rspec and am getting the following failure: > > $ sudo gem install rspec > Successfully installed rspec-1.0.8 > Installing ri documentation for rspec-1.0.8... > Installing RDoc documentation for rspec-1.0.8... > > $ spec

Re: [rspec-users] Getting Class in Shared Behaviours

2007-11-21 Thread Daniel N
On Nov 22, 2007 8:31 AM, aslak hellesoy <[EMAIL PROTECTED]> wrote: > On Nov 21, 2007 10:22 PM, David Chelimsky <[EMAIL PROTECTED]> wrote: > > > > On Nov 21, 2007 3:14 PM, Daniel N <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > > >

Re: [rspec-users] Getting Class in Shared Behaviours

2007-11-21 Thread Daniel N
On Nov 22, 2007 8:22 AM, David Chelimsky <[EMAIL PROTECTED]> wrote: > On Nov 21, 2007 3:14 PM, Daniel N <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I want to be able to get at the described class in my shared behaviour. > I'm > > sure an example wi

Re: [rspec-users] Getting Class in Shared Behaviours

2007-11-21 Thread Daniel N
edge revision 8175 > > > > On Nov 21, 2007, at 3:14 PM, Daniel N wrote: > > > Hi, > > > > I want to be able to get at the described class in my shared > > behaviour. I'm sure an example will say it better than my words > > > > describe "m

[rspec-users] Getting Class in Shared Behaviours

2007-11-21 Thread Daniel N
Hi, I want to be able to get at the described class in my shared behaviour. I'm sure an example will say it better than my words describe "my shared", :shared => true do it "should tell me what the class is its describing" do how_do_i_get_the_user_class_here end end describe User do

Re: [rspec-users] [ANN] Lighthouse and Engine Yard sponsorships

2007-11-18 Thread Daniel N
On Nov 19, 2007 8:24 AM, Scott Taylor <[EMAIL PROTECTED]> wrote: > > On Nov 18, 2007, at 4:10 PM, David Chelimsky wrote: > > > Hey all, > > > > I'm very happy to announce that ActiveReload[1] has generously offered > > to sponsor a lighthouse[2] account for rspec. We'll be moving ticket > > tracki

Re: [rspec-users] Textmate Formatting has gone away

2007-10-26 Thread Daniel N
On 10/27/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > > On 10/26/07, Daniel N <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I just updated my Textmate bundle to the latest in the svn because It > wasn't > > working with the latest version of r

[rspec-users] Textmate Formatting has gone away

2007-10-26 Thread Daniel N
Hi, I just updated my Textmate bundle to the latest in the svn because It wasn't working with the latest version of rspec. It's been a while since I updated the bundle ;) I like the format that I used to have of a progress bar across the top and html formatted results for each example, however n

Re: [rspec-users] plain text stories

2007-10-21 Thread Daniel N
On 10/22/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > > Thanks to discussions on this list, suggestions from many of you and a > patch from Pat Maddox, we now have Plain Text User Stories in Story > Runner. > > Read more: > > > http://blog.davidchelimsky.net/articles/2007/10/21/story-runner-in-

Re: [rspec-users] Side Effects in Stories

2007-10-18 Thread Daniel N
On 9/11/07, s.ross <[EMAIL PROTECTED]> wrote: > > I have a story where the user resets the password [hey, this story > thing really rocks!]. It is expected that the password will change > and that the user will be redirected to a login screen. A side effect > is that the user will receive email wit

Re: [rspec-users] controller spec with model that validates_uniqueness

2007-08-23 Thread Daniel N
On 8/24/07, Courtenay <[EMAIL PROTECTED]> wrote: > > Does this work? > >Image.stub!(:validates_uniqueness_of).and_return(true) > > > On 8/23/07, s.ross <[EMAIL PROTECTED]> wrote: > > I want to use mocks and stubs to test the controller, but am having > > trouble getting my validation not to tri

Re: [rspec-users] Any liberally-licensed open source projects out there that make good use of RSpec?

2007-08-08 Thread Daniel N
On 8/9/07, Obie Fernandez <[EMAIL PROTECTED]> wrote: > > Thanks, Scott. Checking it out now. > > On 7/31/07, Scott Taylor <[EMAIL PROTECTED]> wrote: > > > > I've just started DatedBackup (an rsnapshot-like utility), which has > > about 500 LOC at the moment. It is licensed under the GPL, and has >

Re: [rspec-users] Unimplemented Spec idea

2007-07-31 Thread Daniel N
On 8/1/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > > On 7/31/07, Daniel N <[EMAIL PROTECTED]> wrote: > > > > > > On 8/1/07, Scott Taylor <[EMAIL PROTECTED]> wrote: > > > > > > I absolutely love the unimplemented spec idea, and ten

Re: [rspec-users] Unimplemented Spec idea

2007-07-31 Thread Daniel N
On 8/1/07, Scott Taylor <[EMAIL PROTECTED]> wrote: > > > I absolutely love the unimplemented spec idea, and tend to use it a > lot. But occasionally it gets in my way, when I rush to write a > spec, and then want to change it to a non-implemented spec. My > normal solution is to comment out the d

Re: [rspec-users] View-Driven-Development by Behavior-Driven-Development and RSpec

2007-07-30 Thread Daniel N
On 7/30/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > > On 7/30/07, Daniel N <[EMAIL PROTECTED]> wrote: > > On 7/30/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > > > On 7/30/07, Daniel N <[EMAIL PROTECTED]> wrote: > > > > On 7/30/07,

Re: [rspec-users] View-Driven-Development by Behavior-Driven-Development and RSpec

2007-07-30 Thread Daniel N
On 7/30/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > > On 7/30/07, Daniel N <[EMAIL PROTECTED]> wrote: > > On 7/30/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > > > On 7/30/07, Mikel Lindsaar <[EMAIL PROTECTED]> wrote: > > > > I fi

Re: [rspec-users] View-Driven-Development by Behavior-Driven-Development and RSpec

2007-07-30 Thread Daniel N
On 7/30/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > > On 7/30/07, Mikel Lindsaar <[EMAIL PROTECTED]> wrote: > > I find myself doing the same thing... the, open the model and type in > > the it shoulds... > > > > I ws thinking along the same line... probably all that would be needed > > is a ra

Re: [rspec-users] View-Driven-Development by Behavior-Driven-Development and RSpec

2007-07-30 Thread Daniel N
On 7/30/07, Mikel Lindsaar <[EMAIL PROTECTED]> wrote: > > I find myself doing the same thing... the, open the model and type in > the it shoulds... I think it would need to do a bit more. If I call mock_model( User ) and the User class doesn't exist yet that will blow it up. I guess at that poi

Re: [rspec-users] View-Driven-Development by Behavior-Driven-Development and RSpec

2007-07-30 Thread Daniel N
On 7/30/07, Mikel Lindsaar <[EMAIL PROTECTED]> wrote: > > Dear Nathan, > > What you are sayiing is correct, and in terms of Ruby on Rails, BDD > _IS_ View Driven development... or at least it should be IMHO. > > At the end of the day, the only thing that matters in a Rails App is > the Behaviour sh

Re: [rspec-users] specing a call to render :layout => "some_layout"

2007-07-28 Thread Daniel N
On 7/28/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > > On 7/28/07, Daniel N <[EMAIL PROTECTED]> wrote: > > I'm trying to specify that an action should be rendered with a given > layout > > one particular spec. > > > > What I've got at t

[rspec-users] specing a call to render :layout => "some_layout"

2007-07-28 Thread Daniel N
I'm trying to specify that an action should be rendered with a given layout one particular spec. What I've got at the moment is this. it "should render with the grabber layout" do controller.should_receive( :render ).with( :layout => "my_layout" ) do_get end This doesnt work even tho

Re: [rspec-users] Mock or Stub strategy for validates_uniqueness_of

2007-07-25 Thread Daniel N
On 7/25/07, Mikel Lindsaar <[EMAIL PROTECTED]> wrote: Kyle, That is a good point. We are after the behaviour, not the implementation. Regards Mikel On 7/25/07, Daniel N <[EMAIL PROTECTED]> wrote: > > > > On 7/25/07, Kyle Hargraves <[EMAIL PROTECTED]> wrote:

Re: [rspec-users] Mock or Stub strategy for validates_uniqueness_of

2007-07-24 Thread Daniel N
On 7/25/07, Kyle Hargraves <[EMAIL PROTECTED]> wrote: Daniel N wrote: > On 7/25/07, Mikel Lindsaar <[EMAIL PROTECTED]> wrote: >> >> There would be a different way. >> >> In the idea of "Only test the code you write" all you really need to &

Re: [rspec-users] Mock or Stub strategy for validates_uniqueness_of

2007-07-24 Thread Daniel N
association rules and then this can be checked and kept track of when you are refactoring or changing code. Hope that helps. Regards Mikel Thanx Mikel. I didn't even think of using a uniq on the has_many. I was using a validates_uniquness_of :scope => 'book_id' I will def

Re: [rspec-users] Possible Bug

2007-07-24 Thread Daniel N
On 7/25/07, David Chelimsky <[EMAIL PROTECTED]> wrote: On 7/24/07, Daniel N <[EMAIL PROTECTED]> wrote: > > > On 7/25/07, Daniel N <[EMAIL PROTECTED]> wrote: > > I'm trying to test some code that has validates each and I've got a very > str

Re: [rspec-users] Possible Bug

2007-07-24 Thread Daniel N
On 7/25/07, Daniel N <[EMAIL PROTECTED]> wrote: I'm trying to test some code that has validates each and I've got a very strange failure Mock 'Book_1027' expected :store_with_privacy? with (#) but received it with (#) The Spec it "should check that a boo

Re: [rspec-users] Mock or Stub strategy for validates_uniqueness_of

2007-07-24 Thread Daniel N
On 7/24/07, Daniel N <[EMAIL PROTECTED]> wrote: On 7/24/07, Ashley Moran <[EMAIL PROTECTED]> wrote: > > > On 24 Jul 2007, at 14:07, Daniel N wrote: > > > Any hints as to how to do this without using fixtures? > > I did this literally minutes ago. I don

[rspec-users] Possible Bug

2007-07-24 Thread Daniel N
I'm trying to test some code that has validates each and I've got a very strange failure Mock 'Book_1027' expected :store_with_privacy? with (#) but received it with (#) The Spec it "should check that a book can save a clip" do @user = mock_model( User, :id => 3 ) @clip = mock_model( Cl

Re: [rspec-users] Mock or Stub strategy for validates_uniqueness_of

2007-07-24 Thread Daniel N
On 7/24/07, Ashley Moran <[EMAIL PROTECTED]> wrote: On 24 Jul 2007, at 14:07, Daniel N wrote: > Any hints as to how to do this without using fixtures? I did this literally minutes ago. I don't use fixtures at all, ever. Instead I put the data in the before block, eg: des

[rspec-users] Mock or Stub strategy for validates_uniqueness_of

2007-07-24 Thread Daniel N
Hi, I'm a bit stuck with mocking a unit test of a join model with regards to a validates_uniqueness_of clause. I have class Book < AR:B has_many :clippings various validates_presence_of etc end class Clip < AR:B has_many :clippings various validates_presence_of etc end class Clipping < A

Re: [rspec-users] need help getting a word right

2007-07-18 Thread Daniel N
On 7/19/07, David Chelimsky <[EMAIL PROTECTED]> wrote: Hey all, I see examples showing up that look like this: describe Thing do before(:each) do @thing = Thing.new end it do @thing.should be_something end end This will produce output like this: Thing - should be something

Re: [rspec-users] Getting past my login system

2007-07-16 Thread Daniel N
On 7/17/07, Ryan Tucker <[EMAIL PROTECTED]> wrote: Daniel N wrote: > > > On 7/17/07, *Ryan Tucker* <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > Daniel N wrote: > > > > > > On 7/17/07, *Ryan Tuc

Re: [rspec-users] Getting past my login system

2007-07-16 Thread Daniel N
On 7/17/07, Ryan Tucker <[EMAIL PROTECTED]> wrote: Daniel N wrote: > > > On 7/17/07, *Ryan Tucker* <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > Daniel N wrote: > > > > > > On 7/17/07, *Ryan Tuc

Re: [rspec-users] Getting past my login system

2007-07-16 Thread Daniel N
On 7/17/07, Ryan Tucker <[EMAIL PROTECTED]> wrote: Daniel N wrote: > > > On 7/17/07, *Ryan Tucker* <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > Ryan Tucker wrote: > > Thank you in advance for your help. I am relatively new to b

Re: [rspec-users] Getting past my login system

2007-07-16 Thread Daniel N
On 7/17/07, Ryan Tucker <[EMAIL PROTECTED]> wrote: Ryan Tucker wrote: > Thank you in advance for your help. I am relatively new to both Rails > and Rspec and I am hoping for some insight from some experienced veterans. > > Right now I am using Rspec for code that has already been written so > t

Re: [rspec-users] Specing Layouts

2007-07-15 Thread Daniel N
On 7/16/07, David Chelimsky <[EMAIL PROTECTED]> wrote: On 7/15/07, Daniel N <[EMAIL PROTECTED]> wrote: > > > > On 7/16/07, Daniel N <[EMAIL PROTECTED]> wrote: > > > > > > > > > > On 7/15/07, David Chelimsky < [EMAIL PROTECTE

Re: [rspec-users] Specing Layouts

2007-07-15 Thread Daniel N
On 7/16/07, Daniel N <[EMAIL PROTECTED]> wrote: On 7/15/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > > On 7/14/07, Daniel N <[EMAIL PROTECTED]> wrote: > > > > > > On 7/15/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > > > O

Re: [rspec-users] Specing Layouts

2007-07-15 Thread Daniel N
On 7/15/07, David Chelimsky <[EMAIL PROTECTED]> wrote: On 7/14/07, Daniel N <[EMAIL PROTECTED]> wrote: > > > On 7/15/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > > On 7/14/07, Daniel N <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > &

Re: [rspec-users] Specing Layouts

2007-07-14 Thread Daniel N
On 7/15/07, David Chelimsky <[EMAIL PROTECTED]> wrote: On 7/14/07, Daniel N <[EMAIL PROTECTED]> wrote: > Hi, > > I've just started to try and spec my application.html.erb layout as one of > the view specs but it totally barfs. > > I'm guessing that it

[rspec-users] Specing Layouts

2007-07-14 Thread Daniel N
Hi, I've just started to try and spec my application.html.erb layout as one of the view specs but it totally barfs. I'm guessing that it's due to the yield statements in the layout. Any clues as to how to proceed? Cheers Daniel ___ rspec-users mailin

Re: [rspec-users] Mocking User.find( :all, :limit => 10 )

2007-07-09 Thread Daniel N
My Bad... Please ignore On 7/10/07, Daniel N <[EMAIL PROTECTED]> wrote: Hi, I'm trying to setup a mock for my controller test but I can't get it to recognise the mock. I use it "should find all users" do User.should_receive(:find).with( :all, :limit => 10

[rspec-users] Mocking User.find( :all, :limit => 10 )

2007-07-09 Thread Daniel N
Hi, I'm trying to setup a mock for my controller test but I can't get it to recognise the mock. I use it "should find all users" do User.should_receive(:find).with( :all, :limit => 10 ).and_return([EMAIL PROTECTED]) do_get end and in the controller @users = User.find(:all, :limit => 10

[rspec-users] Is it bad to use a shared example in rspec_helper.rb?

2007-07-09 Thread Daniel N
I want to extract the method for logging in so that I don't have to include it in each before call. Is it bad to use a describe block within the rspec_helper in a rails project for controller tests? I have in my spec_helper.rb describe "an authenticated request", :shared => true do before( :ea

Re: [rspec-users] mocking methods in the controller.

2007-07-06 Thread Daniel N
On 7/6/07, David Chelimsky <[EMAIL PROTECTED]> wrote: On 7/6/07, Daniel N <[EMAIL PROTECTED]> wrote: > On 7/6/07, Daniel N <[EMAIL PROTECTED]> wrote: > > On 7/6/07, David Chelimsky < [EMAIL PROTECTED]> wrote: > > > On 7/5/07, Daniel N <[EMAIL PROTE

Re: [rspec-users] mocking methods in the controller.

2007-07-06 Thread Daniel N
On 7/6/07, Daniel N <[EMAIL PROTECTED]> wrote: On 7/6/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > > On 7/5/07, Daniel N <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I'm very new to rspec so please be patient with me. > > > > I&#x

Re: [rspec-users] Testing Rails Associations

2007-07-06 Thread Daniel N
On 7/6/07, Daniel N <[EMAIL PROTECTED]> wrote: > > > > On 7/6/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > > On 7/3/07, Daniel N <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > > > I'm very new to rspec, so if this is not th

Re: [rspec-users] Testing Rails Associations

2007-07-06 Thread Daniel N
On 7/6/07, David Chelimsky <[EMAIL PROTECTED]> wrote: On 7/3/07, Daniel N <[EMAIL PROTECTED]> wrote: > Hi, > > I'm very new to rspec, so if this is not the right forum please let me > know. > > I'm starting to spec my models first in an existing rails

Re: [rspec-users] mocking methods in the controller.

2007-07-06 Thread Daniel N
On 7/6/07, David Chelimsky <[EMAIL PROTECTED]> wrote: On 7/5/07, Daniel N <[EMAIL PROTECTED]> wrote: > Hi, > > I'm very new to rspec so please be patient with me. > > I've tried to take some of my tests out of the controller specs to check for > things th

[rspec-users] mocking methods in the controller.

2007-07-05 Thread Daniel N
Hi, I'm very new to rspec so please be patient with me. I've tried to take some of my tests out of the controller specs to check for things that are rendered. This has not worked so well, since my views have the controller method current_user in quite a few places. Is there any way that I ca

[rspec-users] Testing Rails Associations

2007-07-03 Thread Daniel N
Hi, I'm very new to rspec, so if this is not the right forum please let me know. I'm starting to spec my models first in an existing rails app, porting from a mix of Test::Unit, and simply_bdd amongst others. I'm at the point where I want to test that certain associations are present. What I'm