Re: [rspec-users] Assumption tests

2007-10-19 Thread Scott Taylor
On Oct 19, 2007, at 12:29 PM, Pat Maddox wrote: > On 10/19/07, Daniel Tenner <[EMAIL PROTECTED]> wrote: >>> If I read correctly, Daniel is suggesting that this is not behaviour >>> because he's equating behaviour with interaction. This example >>> checks >>> an outcome, not an interaction. >>>

Re: [rspec-users] Patch idea for rspec_on_rails

2007-10-19 Thread Ben Mabey
Thanks for the response. I understand your reasoning, especially about the whole BDD approach being an unproven/agreed on. And yes, you have made it really easy to make and distribute custom matchers. So thank you! I'll keep these extra matchers as a plugin for now. -Ben David Chelimsky wr

Re: [rspec-users] Patch idea for rspec_on_rails

2007-10-19 Thread David Chelimsky
On 10/19/07, Ben Mabey <[EMAIL PROTECTED]> wrote: > David Chelimsky wrote: > > On 10/19/07, Ben Mabey <[EMAIL PROTECTED]> wrote: > > > >> I would think that something like this should be worked into > >> rpsec_on_rails. Because it makes testing AR behavior very easy and > >> painless. One line of

Re: [rspec-users] Patch idea for rspec_on_rails

2007-10-19 Thread Ben Mabey
David Chelimsky wrote: > On 10/19/07, Ben Mabey <[EMAIL PROTECTED]> wrote: > >> I would think that something like this should be worked into >> rpsec_on_rails. Because it makes testing AR behavior very easy and >> painless. One line of code = One line of test code. >> > > I'd be hesitant

Re: [rspec-users] Patch idea for rspec_on_rails

2007-10-19 Thread David Chelimsky
On 10/19/07, Ben Mabey <[EMAIL PROTECTED]> wrote: > I would think that something like this should be worked into > rpsec_on_rails. Because it makes testing AR behavior very easy and > painless. One line of code = One line of test code. I'd be hesitant to include it in rspec_on_rails. I don't rea

Re: [rspec-users] Patch idea for rspec_on_rails

2007-10-19 Thread Russell Norris
I can see the good in simplicity there. I just liked the ability to say Foo.has_many(:bars).through(:foobars) in such a readable way. I did write methodology for a more terse listing of the options as Foo.has_many(:bars).with_options(:through => :bars) etc. RSL On 10/19/07, Jerrett Taylor <[EMAIL

Re: [rspec-users] Patch idea for rspec_on_rails

2007-10-19 Thread Ben Mabey
Cool. Well, it actually wasn't my code to begin with. I like the extension you have done, though, and will integrate it into the current set of matchers I'm using (I have done some tweaks of my own to the original code.) Thanks. -Ben Russell Norris wrote: > Ben, I actually looked through yr

Re: [rspec-users] Patch idea for rspec_on_rails

2007-10-19 Thread Russell Norris
Ben, I actually looked through yr code when coming up with this idea but tried to take it one notch "cooler", i guess. with the whole has_many(:foos).through(:bars) part. RSL On 10/19/07, Ben Mabey <[EMAIL PROTECTED]> wrote: > I've been using a set of matchers that does this plus adds more AR bas

Re: [rspec-users] Patch idea for rspec_on_rails

2007-10-19 Thread Ben Mabey
sorry.. I meant to say "spec code". :) Ben Mabey wrote: > I've been using a set of matchers that does this plus adds more AR basic > matchers (such as validate_presence_of, etc.. - by testing the > behavior.) I got the base of my matchers from this blog: > http://spicycode.com/2007/4/2/rspec-e

Re: [rspec-users] Patch idea for rspec_on_rails

2007-10-19 Thread Ben Mabey
I've been using a set of matchers that does this plus adds more AR basic matchers (such as validate_presence_of, etc.. - by testing the behavior.) I got the base of my matchers from this blog: http://spicycode.com/2007/4/2/rspec-expecation-matchers-part-ii I would think that something like thi

Re: [rspec-users] Patch idea for rspec_on_rails

2007-10-19 Thread Jerrett Taylor
We have a similar one, which works like: Foo.should have_association(:has_many, :conditions => "stuff", :through => :bazes) we started off with should have_many etc, but it became overcomplicated with all the various things that you may want - so we changed to have_association to make it sim

Re: [rspec-users] Side Effects in Stories

2007-10-19 Thread s.ross
On Oct 19, 2007, at 12:21 PM, Jonathan Linowes wrote: > from my specs on restful_authentication's models/user_observer_spec.rb > > context "A UserObserver" do > setup do > @user = mock('user') > @user_observer = UserObserver.instance > end > > specify "should call UserNotifier.delive

Re: [rspec-users] Side Effects in Stories

2007-10-19 Thread Ben Mabey
Yeah, you have two options really. The first is to do what linoj said and mock out the mailer that you are using. The other way, which Pat, was referring to was to actually check the mail queue. I generally do both. The reason being is that I want to make sure that I am using the correct ma

Re: [rspec-users] Side Effects in Stories

2007-10-19 Thread Jonathan Linowes
On Oct 19, 2007, at 3:30 PM, Ben Mabey wrote: > yes, upon closer inspection, (as in http://www.vaporbase.com/postings/ Rspec_1.0_and_Restful_Authentication) in spec_helper.rb def set_mailer_in_test ActionMailer::Base.delivery_method = :test ActionMailer::Base.perform_deliveries = true

Re: [rspec-users] Side Effects in Stories

2007-10-19 Thread Jonathan Linowes
On Oct 19, 2007, at 1:54 PM, s.ross wrote: On Oct 18, 2007, at 6:09 AM, Daniel N wrote: 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

Re: [rspec-users] Stubbing a Kernel method?

2007-10-19 Thread Scott Taylor
On Oct 19, 2007, at 12:18 PM, Paul Dlug wrote: > Is it possible to stub a Kernel method? I'm specifically interested in > the 'open' method to test some code using open-uri. I've tried: > > Kernel.should_receive(:open).with('filename').and_return('data') > > However, this doesn't seem to work. An

Re: [rspec-users] Side Effects in Stories

2007-10-19 Thread Pat Maddox
On 10/19/07, s.ross <[EMAIL PROTECTED]> wrote: > > > > On Oct 18, 2007, at 6:09 AM, Daniel N wrote: > > > 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 > > a

Re: [rspec-users] Patch idea for rspec_on_rails

2007-10-19 Thread Daniel Tenner
I would like it :-) On 19 Oct 2007, at 19:45 19 Oct 2007, Russell Norris wrote: > I recently wrote a matcher for testing AR associations which allows > you to specify things like: > > Foo.should have_many(:bars).through(:bazes) > > I'm pretty darned proud of it and a couple of people have sug

[rspec-users] Patch idea for rspec_on_rails

2007-10-19 Thread Russell Norris
I recently wrote a matcher for testing AR associations which allows you to specify things like: Foo.should have_many(:bars).through(:bazes) I'm pretty darned proud of it and a couple of people have suggested that I should submit it to the rspec_on_rails project. Before I go to the trouble of

Re: [rspec-users] Side Effects in Stories

2007-10-19 Thread s.ross
On Oct 18, 2007, at 6:09 AM, Daniel N wrote: 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 i

Re: [rspec-users] Stubbing a Kernel method?

2007-10-19 Thread Pat Maddox
On 10/19/07, Paul Dlug <[EMAIL PROTECTED]> wrote: > Is it possible to stub a Kernel method? I'm specifically interested in > the 'open' method to test some code using open-uri. I've tried: > > Kernel.should_receive(:open).with('filename').and_return('data') > > However, this doesn't seem to work. A

Re: [rspec-users] Assumption tests

2007-10-19 Thread Pat Maddox
On 10/19/07, Daniel Tenner <[EMAIL PROTECTED]> wrote: > > If I read correctly, Daniel is suggesting that this is not behaviour > > because he's equating behaviour with interaction. This example checks > > an outcome, not an interaction. > > > > That's right, one of my axioms is that "specifying" in

[rspec-users] Stubbing a Kernel method?

2007-10-19 Thread Paul Dlug
Is it possible to stub a Kernel method? I'm specifically interested in the 'open' method to test some code using open-uri. I've tried: Kernel.should_receive(:open).with('filename').and_return('data') However, this doesn't seem to work. Any suggestions would be appreciated. --Paul __

Re: [rspec-users] Any tips on teaching BDD with RSpec?

2007-10-19 Thread Ashley Moran
On Oct 18, 2007, at 11:42 am, Alastair Moore wrote: > Oh, incidently, I found a couple of useful links: > > http://video.google.com/videoplay?docid=8135690990081075324 Watched that ages ago - it's good but looks really old school compared to the new syntax! > http://www.oreilly.com/pub/a/rub

Re: [rspec-users] Assumption tests

2007-10-19 Thread Daniel Tenner
> If I read correctly, Daniel is suggesting that this is not behaviour > because he's equating behaviour with interaction. This example checks > an outcome, not an interaction. > That's right, one of my axioms is that "specifying" involves behaviour/interaction, not state/outcome. The reason fo

Re: [rspec-users] Assumption tests

2007-10-19 Thread David Chelimsky
On 10/19/07, Jonathan Linowes <[EMAIL PROTECTED]> wrote: > But dont you really just want to test the behavior of the class? The object, not the class. > (whereas the validator call is an implementation) > such as > > it "should require digits" do >p = PhoneNumber.new( :digits => nil ) >

Re: [rspec-users] Assumption tests

2007-10-19 Thread Jonathan Linowes
But dont you really just want to test the behavior of the class? (whereas the validator call is an implementation) such as it "should require digits" do p = PhoneNumber.new( :digits => nil ) p.should_not be_valid p.errors.on(:digits).should == "can't be blank" end On Oct 19,

Re: [rspec-users] first cut at blockless given/when/then

2007-10-19 Thread David Chelimsky
On 10/19/07, Wincent Colaiuta <[EMAIL PROTECTED]> wrote: > >> Another alternative combining your suggestion with what Pat > >> mentioned: > >> > >> step_matchers do |match| > >>match.given ... > >>match.when ... > >>match.then ... > >> end > > > > That's nice, except we don't want metho

[rspec-users] Assumption tests

2007-10-19 Thread Daniel Tenner
Hi all, I've been thinking about the whole validator/relationship speccing issue, and I came up with a suggestion, which I'd love to get some feedback on. The full article is available at http://www.inter-sections.net/ 2007/10/19/what-to-test-and-specify-and-where-to-do-it/ , with the rele

Re: [rspec-users] first cut at blockless given/when/then

2007-10-19 Thread Wincent Colaiuta
El 19/10/2007, a las 0:41, "David Chelimsky" <[EMAIL PROTECTED]> escribió: > On 10/18/07, Wincent Colaiuta <[EMAIL PROTECTED]> wrote: >> El 18/10/2007, a las 18:42, "David Chelimsky" <[EMAIL PROTECTED]> >> escribió: >> >>> Easier to type, sure. I'm not in love w/ the names yet though >>> becau

[rspec-users] spec:models depends on development db:migration

2007-10-19 Thread Keith McDonnell
Hi David, If you give me some direction I'll try & submit a patch. Keith ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

[rspec-users] Feeding the framework ?

2007-10-19 Thread Keith McDonnell
Thanks for the tip & sympathy. I reinstalled rspec from scratch with a fresh project to investigate the error. Turns out that the `rake spec:models` clones the test db from the dev environment! I incorrectly assumed that the test db was migrated up & down independently. I mailed a work around

[rspec-users] Mocking models provided in Rails plugins

2007-10-19 Thread Keith McDonnell
Hi Dan, You might find these links helpful when spec'ing restful auth http://www.vaporbase.com/postings/Rspec_1.0_and_Restful_Authentication http://jonathan.tron.name/articles/2007/01/02/rspec-on-rails-restful-authentication http://www.caboo.se/articles/2006/10/29/rspec-on-rails Keith

Re: [rspec-users] Mocking models provided in Rails plugins

2007-10-19 Thread Robert Evans
Dan, you can take a look at what *court3nay did, here: * ** http://sample.caboo.se/empty_rails_app/trunk/spec/controllers/session_controller_spec.rb Robert On 10/18/07, Brandon Keepers <[EMAIL PROTECTED]> wrote: > > Dan, > > On Oct 18, 2007, at 6:14 PM, Dan Croak wrote: > > > Hey folks, > > > >