Re: [rspec-users] Stories - Use view matchers rather than assigns[].should?

2008-04-10 Thread Pat Maddox
On Wed, Apr 9, 2008 at 8:20 PM, Tim Haines <[EMAIL PROTECTED]> wrote: > Thanks Pat and David. I'm implementing paging (via will_paginate) and > thought I should start with a story. I think I grok what you're saying Pat > - the stories should only be looking at "externally" visible stuff - i.e. >

Re: [rspec-users] Stories - Use view matchers rather than assigns[].should?

2008-04-10 Thread David Chelimsky
On Apr 10, 2008, at 11:20 AM, Pat Maddox wrote: > On Wed, Apr 9, 2008 at 8:20 PM, Tim Haines <[EMAIL PROTECTED]> wrote: >> Thanks Pat and David. I'm implementing paging (via will_paginate) >> and >> thought I should start with a story. I think I grok what you're >> saying Pat >> - the storie

Re: [rspec-users] Stories - Use view matchers rather than assigns[].should?

2008-04-10 Thread Ashley Moran
On 10 Apr 2008, at 17:00, David Chelimsky wrote: > otooh - having some scenarios logging in using a post and some by > poking around under the hood creates an untested logical binding > between the post and the poking. This has the same risk associated > with it that raises so much concern about

Re: [rspec-users] Stories - Use view matchers rather than assigns[].should?

2008-04-10 Thread Pat Maddox
On Thu, Apr 10, 2008 at 9:21 AM, Ashley Moran <[EMAIL PROTECTED]> wrote: > > On 10 Apr 2008, at 17:00, David Chelimsky wrote: > > > otooh - having some scenarios logging in using a post and some by > > poking around under the hood creates an untested logical binding > > between the post and the

Re: [rspec-users] Stories - Use view matchers rather than assigns[].should?

2008-04-10 Thread David Chelimsky
On Apr 10, 2008, at 12:48 PM, Pat Maddox wrote: > Keep in mind that not every step of every story needs to > be a round-trip request. It's even good to write some stories that > don't make requests at all! I definitely agree with this, however I do see a difference between accessing models dire

Re: [rspec-users] Multi-line steps

2008-04-10 Thread Glenn Ford
On Apr 9, 2008, at 5:04 PM, Pat Maddox wrote: > On 4/9/08, Ashley Moran <[EMAIL PROTECTED]> wrote: >> >> On 9 Apr 2008, at 14:14, aslak hellesoy wrote: >> >>> Just a style comment: I usually strive for a single When (in this >>> case >>> Fred uploads the csv file). >>> The other ones are Givens

[rspec-users] mock_model

2008-04-10 Thread Anthony Broad-Crawford
Our company just had an interesting conversation around mock_model and I want to ask the same question to this audience. When creating mock_models what is the purpose of passing in the class constant? user = mock_model(User) To the best that we can tell the method mock_model doesn't actuall

Re: [rspec-users] mock_model

2008-04-10 Thread Pat Maddox
On Thu, Apr 10, 2008 at 10:30 AM, Anthony Broad-Crawford <[EMAIL PROTECTED]> wrote: > Our company just had an interesting conversation around mock_model and I > want to ask the same question to this audience. When creating mock_models > what is the purpose of passing in the class constant? > > use

Re: [rspec-users] mock_model

2008-04-10 Thread Ashley Moran
On 10 Apr 2008, at 18:54, Pat Maddox wrote: > stub_model, available in RSpec trunk, may be more to your liking. You > can read about it at > http://rubyforge.org/pipermail/rspec-devel/2008-March/004782.html From the linked post: > Also - right now it checks the hash against the model's attribut

Re: [rspec-users] Multi-line steps

2008-04-10 Thread Ashley Moran
On 10 Apr 2008, at 18:28, Glenn Ford wrote: > Given database is in this state > When user does this stuff in browser > Then database should be in this new state I like the way you phrased this Glenn. Maybe the distinction is that Given is everything outside the control of the user, or, if th

Re: [rspec-users] mock_model

2008-04-10 Thread David Chelimsky
On Thu, Apr 10, 2008 at 4:55 PM, Ashley Moran <[EMAIL PROTECTED]> wrote: > David: +1 for stub_model, but could you make it autodetect if the stub > is for an attribute or a method? It would be nice to do away with > the :attr and :stub distinction. Not sure what you mean here - that is handled

Re: [rspec-users] Multi-line steps

2008-04-10 Thread aslak hellesoy
On Thu, Apr 10, 2008 at 7:28 PM, Glenn Ford <[EMAIL PROTECTED]> wrote: > > On Apr 9, 2008, at 5:04 PM, Pat Maddox wrote: > > > On 4/9/08, Ashley Moran <[EMAIL PROTECTED]> wrote: > >> > >> On 9 Apr 2008, at 14:14, aslak hellesoy wrote: > >> > >>> Just a style comment: I usually strive for a si

Re: [rspec-users] Stories - Use view matchers rather than assigns[].should?

2008-04-10 Thread Ashley Moran
On 10 Apr 2008, at 17:59, David Chelimsky wrote: > I definitely agree with this, however I do see a difference between > accessing models directly through their API (which I do) and accessing > the internals of the request cycle (which I don't). Ok that's what I was doing - not interfering with

Re: [rspec-users] Multi-line steps

2008-04-10 Thread Rick DeNatale
On Thu, Apr 10, 2008 at 5:25 PM, aslak hellesoy <[EMAIL PROTECTED]> wrote: > > This is a very "technical" way to express a scenario. It wouldn't make > much sense to a typical domain expert (unless they know about > databases). > I generally try to write scenarios using the domain language, >

Re: [rspec-users] Multi-line steps

2008-04-10 Thread Glenn Ford
>> This actually sounds more confusing to me when viewed in the context >> of my own stories, and it seems similar to what's going on here. I >> write a lot about the user's interaction with the site and what >> should >> happen, so I have a lot of stories that look like: >> >> Given database is

Re: [rspec-users] Stories - Use view matchers rather than assigns[].should?

2008-04-10 Thread Pat Maddox
On Thu, Apr 10, 2008 at 2:57 PM, Ashley Moran <[EMAIL PROTECTED]> wrote: > Sorry wasn't clear what I meant. I was thinking something like >Given ... >When I run User.create!(:foo => "bar") >Then the Users page should have a row with "bar" in the "foo" column Gah, that looks hideous.

Re: [rspec-users] mock_model

2008-04-10 Thread Ashley Moran
On 10 Apr 2008, at 22:28, David Chelimsky wrote: > Not sure what you mean here - that is handled transparently by > stub_model so you don't have to make any such distinction. Take a look > at > http://github.com/dchelimsky/rspec-rails/tree/master/lib/spec/rails/example/rails_example_group.rb > an

Re: [rspec-users] Stories - Use view matchers rather than assigns[].should?

2008-04-10 Thread Ashley Moran
On 10 Apr 2008, at 23:06, Pat Maddox wrote: >> Given ... >> When I run User.create!(:foo => "bar") >> Then the Users page should have a row with "bar" in the "foo" >> column > > Gah, that looks hideous. I think you misunderstood the point - it's supposed to look hideous :) What I meant

Re: [rspec-users] Stories - Use view matchers rather than assigns[].should?

2008-04-10 Thread Pat Maddox
On Thu, Apr 10, 2008 at 3:30 PM, Ashley Moran <[EMAIL PROTECTED]> wrote: > > On 10 Apr 2008, at 23:06, Pat Maddox wrote: > > >> Given ... > >> When I run User.create!(:foo => "bar") > >> Then the Users page should have a row with "bar" in the "foo" > >> column > > > > Gah, that looks h

Re: [rspec-users] Stories - Use view matchers rather than assigns[].should?

2008-04-10 Thread Ashley Moran
On 10 Apr 2008, at 23:38, Pat Maddox wrote: > I don't know what you mean by a special set of stories. In the > example I gave, the Given steps would most likely be implemented as AR > calls - not as separate requests. The When and Then would likely be > implemented as an HTTP request and an ass

[rspec-users] Creating stories for the second resource. Very wet approach

2008-04-10 Thread Tim Haines
Hi y'all I'm about to start writing up the stories for my second resource. The second resource is so similar to the first that I feel a good way for me to start might be to copy and paste the stories and edit from there. This seems very anti-dry though. Am I missing something obvious, or would

[rspec-users] newbq: Organizing your stories

2008-04-10 Thread Tim Haines
Hi, I'm a little unhappy with how my stories are organised, and am wondering if anyone has found any particular method nicest. I'm working within an admin namespace, and currently have a plain text story file for each controller in the admin folder. I also have a steps subfolder, with one step f

Re: [rspec-users] newbq: Organizing your stories

2008-04-10 Thread Pat Maddox
On Thu, Apr 10, 2008 at 5:46 PM, Tim Haines <[EMAIL PROTECTED]> wrote: > Hi, > > I'm a little unhappy with how my stories are organised, and am wondering if > anyone has found any particular method nicest. I'm working within an admin > namespace, and currently have a plain text story file for each

Re: [rspec-users] how to stub the :current_user and any methods associated with it

2008-04-10 Thread newbie
Thanks for the direction. I'm glad to hear that I'm going in the right direction. I just have a final question and I seem to be hitting a stub/mocking road block at the moment. In my controller I have this... def index @entries = current_user.entries end How would I rspec this out correctly? This

Re: [rspec-users] Multi-line steps

2008-04-10 Thread Rick DeNatale
On Thu, Apr 10, 2008 at 6:10 PM, Glenn Ford <[EMAIL PROTECTED]> wrote: Quoting Aslak > > Given the customers joe, paul and lisa are registered users > > When a user signs up as lisa > > Then the user should be informed that the name is taken > > And the user lisa should not be able to log in >

Re: [rspec-users] Stories - Use view matchers rather than assigns[].should?

2008-04-10 Thread Rick DeNatale
On Thu, Apr 10, 2008 at 6:38 PM, Pat Maddox <[EMAIL PROTECTED]> wrote: > On Thu, Apr 10, 2008 at 3:30 PM, Ashley Moran > > But say that actually, "Given a user named Pat" and "Given the user > > is 22 years old" are implemented as DB API calls - in this case is > > there merit to having a s

Re: [rspec-users] Stories - Use view matchers rather than assigns[].should?

2008-04-10 Thread Kamal Fariz
> When I create a user with foo="bar" > > is better because it doesn't expose the implementation. Just the > model concept and any relevant attributes. I hide model details from Stories by using webrat and form field labels. When I create a user with Username: kamal, Password: test And click sub

Re: [rspec-users] Stories - Use view matchers rather than assigns[].should?

2008-04-10 Thread Tim Haines
I read about webrat and stories 30 mins ago - http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/- good article. Tim. On 11/04/2008, Kamal Fariz <[EMAIL PROTECTED]> wrote: > > > When I create a user with foo="bar" > > > > is better because it doesn't expose the implem

Re: [rspec-users] newbq: Organizing your stories

2008-04-10 Thread Zach Dennis
On Thu, Apr 10, 2008 at 8:46 PM, Tim Haines <[EMAIL PROTECTED]> wrote: > Hi, > > I'm a little unhappy with how my stories are organised, and am wondering > if anyone has found any particular method nicest. I'm working within an > admin namespace, and currently have a plain text story file for eac