[rspec-users] Changes in specs for routes in rspec 1.1.99.x

2009-03-02 Thread Juanma Cervera
Trying the next release of rspec, I have had to make changes in the existing specs for routing. I have written an script with sed that makes this automatically (two files) spec/upgrade.sed /route_for/s/id => 1/id => "1"/g /route_for.*create/s/== \(["'].*["']\)/== {:path => \1, :m

Re: [rspec-users] [cucumber] noob Q deleteing from a list.

2009-03-02 Thread Joseph Wilk
John Ivanoff wrote: Thanks for all the help. With the puts response.body I was able so see what was going on. I know that I am now deleting the third frooble Now when Then I should see the following froobles: I get this error -- Then I should see the following

Re: [rspec-users] Cucumber for large projects

2009-03-02 Thread aidy lewis
Hi Tom, We have written an extension that counts your tests and provides a link(s) to the failure backtrace in the Cucumber HTML. There seem to be issues when Cucumber writes to the HTML over around 800 steps, so we are waiting for version 0.2. Aidy On 26/02/2009, Tom ten Thij wrote: > We will

Re: [rspec-users] testing multiple sessions in cucumber/webrat

2009-03-02 Thread Bart Zonneveld
On 28-feb-2009, at 21:04, Joe Van Dyk wrote: Is it possible to have a scenario where you are testing the interaction between two different session? If you mean something along these lines: User A uploads a picture, User B logs in to see the picture uploaded by User A that is possible. I us

Re: [rspec-users] Is there a way to generate spec for existing controllers?

2009-03-02 Thread Bart Zonneveld
On 2-mrt-2009, at 4:08, Phlip wrote: David Chelimsky wrote: ty wrote: We just start using RSpec and rspec_on_rails for a existing Rails project. No unit tests, right? After run script/generate rspec. It only generate the structure folders. We've got quite a few controllers and models.

Re: [rspec-users] be_valid (validates_format_of ..., :on => :create)

2009-03-02 Thread Bart Zonneveld
On 28-feb-2009, at 11:45, MAwiniarski wrote: Greetings, How to write Example which will check if model's variable's format is valid using :on => :create, like this: class User < ActiveRecord::Base ... validates_format_of :email, :with => /.../, :on => :create ... Using following code

Re: [rspec-users] [rails] An authorization question

2009-03-02 Thread Andrew Premdas
Personally I think this should be in the model layer. As you've pointed it you get alot of repetition if its in the controller layer. But putting business logic in the controller layer goes against the fundamentals of MVC, and is a bit of a Rails anti-pattern (fat controller). So given that the ru

[rspec-users] Feature Size-Scope-Scale

2009-03-02 Thread James Byrne
The more I work with BDD the more I realize how different this is from my previous experience. I now consider that part of the difficulty I have lies in establishing the proper scale for the features that I propose. My question lies in that vein. What size should a feature be? I have read a gre

Re: [rspec-users] Feature Size-Scope-Scale

2009-03-02 Thread Bart Zonneveld
On 2-mrt-2009, at 16:07, James Byrne wrote: The more I work with BDD the more I realize how different this is from my previous experience. I now consider that part of the difficulty I have lies in establishing the proper scale for the features that I propose. My question lies in that vein. W

Re: [rspec-users] be_valid (validates_format_of ..., :on => :create)

2009-03-02 Thread David Chelimsky
On Mon, Mar 2, 2009 at 8:20 AM, Bart Zonneveld wrote: > > On 28-feb-2009, at 11:45, MAwiniarski wrote: > >> Greetings, >> >> How to write Example which will check if model's variable's >> format is valid using :on => :create, like this: >> >> class User < ActiveRecord::Base >> ... >>  validates_fo

Re: [rspec-users] Cucumber Feature Scenario critique

2009-03-02 Thread James Byrne
Andrew Premdas wrote: > James, > > I'd question whether you need to give a monkey's about 'entity'. Whilst > it maybe an essential concept in the overall legal framework that doesn't > mean it has to be in YOUR world. If your software is about recording services > provided to some client and re

Re: [rspec-users] be_valid (validates_format_of ..., :on => :create)

2009-03-02 Thread Bart Zonneveld
On 2-mrt-2009, at 16:50, David Chelimsky wrote: On Mon, Mar 2, 2009 at 8:20 AM, Bart Zonneveld wrote: On 28-feb-2009, at 11:45, MAwiniarski wrote: Greetings, How to write Example which will check if model's variable's format is valid using :on => :create, like this: class User < ActiveR

Re: [rspec-users] Feature Size-Scope-Scale

2009-03-02 Thread Stephen Eley
On Mon, Mar 2, 2009 at 10:07 AM, James Byrne wrote: > > I have read a great deal about scaling features in terms of hours of > work.  However, at my present level of inefficiency, that will probably > result in features that are too small just as I now believe that the > features I have now are to

Re: [rspec-users] be_valid (validates_format_of ..., :on => :create)

2009-03-02 Thread David Chelimsky
On Mon, Mar 2, 2009 at 10:23 AM, Bart Zonneveld wrote: > > On 2-mrt-2009, at 16:50, David Chelimsky wrote: > >> On Mon, Mar 2, 2009 at 8:20 AM, Bart Zonneveld >> wrote: >>> >>> On 28-feb-2009, at 11:45, MAwiniarski wrote: >>> Greetings, How to write Example which will check if mode

Re: [rspec-users] be_valid (validates_format_of ..., :on => :create)

2009-03-02 Thread Mark Wilden
On Mon, Mar 2, 2009 at 8:23 AM, Bart Zonneveld wrote: > > On a second note, I noticed rspec default generated model specs now use > Model.create!(@valid_attributes) as their default "all is valid" test. > What's the advantage of this approach? I just write @model.attributes = > @valid_attributes;

Re: [rspec-users] [cucumber] Cucumber and Chronic

2009-03-02 Thread Mark Wilden
On Sun, Mar 1, 2009 at 9:07 PM, Stephen Eley wrote: > > For date testing, I've just discovered and successfully used Notahat's > "time_travel" plugin: > http://github.com/notahat/time_travel/ We have just been stubbing Time.now, but I'll think about time_travel. One advantage would be not having

Re: [rspec-users] Cucumber Feature Scenario critique

2009-03-02 Thread Mark Wilden
On Mon, Mar 2, 2009 at 7:31 AM, James Byrne wrote: > Whether or not a client is a > stand-alone design element or is dependent upon a superior element of > abstraction is really quite beside the point insofar as the presentation > of the system to the user is concerned. I like to focus on that k

Re: [rspec-users] [rails] An authorization question

2009-03-02 Thread James Byrne
Andrew Premdas wrote: > So given that the rules should be in the model then the question is > which part of the model should have this responsibility and how do > you call it. > Three choices come to mind here > > 1) Place the rule inside User > 2) Place the rule inside the affected model > 3)

Re: [rspec-users] [rails] An authorization question

2009-03-02 Thread Mark Wilden
On Mon, Mar 2, 2009 at 10:39 AM, James Byrne wrote: > > I am not sure that this is really "pollution".  One of the things that > was pointed out to me on the Ruby list when I first began transitioning > to OO was the mantra "ask" don't "tell". Actually, it's the other way around. http://www.prag

Re: [rspec-users] [rails] An authorization question

2009-03-02 Thread James Byrne
James Byrne wrote: > > I am not sure that this is really "pollution". One of the things that > was pointed out to me on the Ruby list when I first began transitioning > to OO was the mantra "ask" don't "tell". It seems to me that in an OO > authorization scheme one might properly ask the use

Re: [rspec-users] [rails] An authorization question

2009-03-02 Thread James Byrne
Mark Wilden wrote: > > Actually, it's the other way around. > > http://www.pragprog.com/articles/tell-dont-ask > I have read this article and it leaves me rather more confused than not. I gather that I am missing something fundamental. Consider that when I write x.to_s I am telling the obje

Re: [rspec-users] [rails] An authorization question

2009-03-02 Thread James Byrne
Mark Wilden wrote: > > > Actually, it's the other way around. > > http://www.pragprog.com/articles/tell-dont-ask Sigh... -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/li

Re: [rspec-users] [rails] An authorization question

2009-03-02 Thread Phlip
James Byrne wrote: Is this a semantic confusion on my part? Should I consider that what I do with x.exists? is tell the object to answer a question? Consider... if x.exists? x.important_method() else # nothing! end Now lets upgrade the variable x. Sometimes it points to a thin

Re: [rspec-users] [rails] An authorization question

2009-03-02 Thread r_j_h_box-sf
- Original Message > From: James Byrne > Mark Wilden wrote: > > Actually, it's the other way around. > > > > http://www.pragprog.com/articles/tell-dont-ask > > I have read this article and it leaves me rather more confused than not. That's the danger of oversimplification. Anoth

Re: [rspec-users] [rails] An authorization question

2009-03-02 Thread James Byrne
unknown wrote: > >> sam.authorized?(controller_or_model, action)? > > I'll suggest that it's the controllers who are responsible for telling > what role or other requirements need to be satisfied to get their > services, and that it's the job of the user object (maybe by delegating > to some

Re: [rspec-users] [rails] An authorization question

2009-03-02 Thread Zach Dennis
On Mon, Mar 2, 2009 at 4:50 PM, Zach Dennis wrote: > On Mon, Mar 2, 2009 at 3:59 PM, James Byrne wrote: >> unknown wrote: >> >>> sam.authorized?(controller_or_model, action)? >>> >>> I'll suggest that it's the controllers who are responsible for telling >>> what role or other requirements ne

Re: [rspec-users] [rails] An authorization question

2009-03-02 Thread Zach Dennis
On Mon, Mar 2, 2009 at 3:59 PM, James Byrne wrote: > unknown wrote: > >> >>> sam.authorized?(controller_or_model, action)? >> >> I'll suggest that it's the controllers who are responsible for telling >> what role or other requirements need to be satisfied to get their >> services, and that it's th

Re: [rspec-users] Rspecing an enumerator from outside-in woes

2009-03-02 Thread Shot (Piotr Szotkowski)
Once again – thanks a ton for your response! I wish ‘The RSpec Book’ answered my use cases; I bought it hoping I’ll learn all this stuff from it, but it seems the most interesting chapters are not written yet. :) Matt Wynne: > Assuming you wanted to keep your focus on the Decomposer class, but

Re: [rspec-users] Is there a way to generate spec for existing controllers?

2009-03-02 Thread Zach Dennis
On Sun, Mar 1, 2009 at 10:08 PM, Phlip wrote: > David Chelimsky wrote: > >> ty wrote: > >>> We just start using RSpec and rspec_on_rails for a existing Rails >>> project. > > No unit tests, right? > >>> After run script/generate rspec. It only generate the structure >>> folders. >>> We've got quit

Re: [rspec-users] Rspecing an enumerator from outside-in woes

2009-03-02 Thread Matt Wynne
On 2 Mar 2009, at 23:32, Shot (Piotr Szotkowski) wrote: Once again – thanks a ton for your response! I wish ‘The RSpec Book’ answered my use cases; I bought it hoping I’ll learn all this stuff from it, but it seems the most interesting chapters are not written yet. :) Matt Wynne: Assuming

Re: [rspec-users] Cucumber for large projects

2009-03-02 Thread Matt Wynne
On 26 Feb 2009, at 15:33, Tom ten Thij wrote: We will be using Cucumber for a fairly large project. Are there any areas that cucumber is lacking when there are many scenarios? I believe the best candidate for showing our client the scenario results is the html output. It strikes me that that b

Re: [rspec-users] [cucumber] Cucumber and Chronic

2009-03-02 Thread Tim Walker
Absolutely. I'd respectfully suggest that this is more a requirement of the way the step definition or test fixture that implements the feature needs to behave than the intent of describing time based logic in a natural language such that product owners, ba's etc. can write them (i.e. Cucumber, Fit

Re: [rspec-users] [rails] An authorization question

2009-03-02 Thread Stephen Eley
On Mon, Mar 2, 2009 at 5:16 PM, Zach Dennis wrote: > > Forgot to mention what we did do. We ended up with the following... > > def index >  if user.has_role?("admin") >    user.in_role("admin").invoices >  elsif user.has_role?("associate") >    user.in_role("associate").invoices >  else >    raise

Re: [rspec-users] [rails] An authorization question

2009-03-02 Thread Stephen Eley
On Sat, Feb 28, 2009 at 5:26 PM, Chris Flipse wrote: > > Half of my problem right now is that I'm not even sure what layer to put > model specific authentication!  If it's in the controller layer, it's > repeated logic in every controller that touches the model in question.  If > it's in the model

Re: [rspec-users] [rails] An authorization question

2009-03-02 Thread Zach Dennis
On Mon, Mar 2, 2009 at 11:35 PM, Stephen Eley wrote: > On Mon, Mar 2, 2009 at 5:16 PM, Zach Dennis wrote: >> >> Forgot to mention what we did do. We ended up with the following... >> >> def index >> if user.has_role?("admin") >>user.in_role("admin").invoices >> elsif user.has_role?("associa

Re: [rspec-users] [rails] An authorization question

2009-03-02 Thread Mark Wilden
On Mon, Mar 2, 2009 at 8:35 PM, Stephen Eley wrote: > �...@invoices = Invoice.by_role(user) It doesn't seem right to me that invoices know about users and roles. I think of invoices are being closer to the metal -- closer to the essence of the application -- than petty concerns like authorizatio

Re: [rspec-users] [rails] An authorization question

2009-03-02 Thread Stephen Eley
On Tue, Mar 3, 2009 at 1:04 AM, Mark Wilden wrote: > On Mon, Mar 2, 2009 at 8:35 PM, Stephen Eley wrote: > >> �...@invoices = Invoice.by_role(user) > > It doesn't seem right to me that invoices know about users and roles. > > I would try something like >  user.role.invoices Heh. Which is what Z