Re: [rspec-users] response.body.should be_xml_with -- how to do nested xpath matches

2009-03-09 Thread Phlip
Zach Dennis wrote: XPath is merely the mechanism in which you're allowed to find particular elements on a page. After typing: xpath :input, :name = foo xpath :input, :name = bar xpath :input, :name = baz I would probably write my own wrapper so I could omit the redundant xpath call

[rspec-users] custom, nested HTML matchers in RSpec

2009-03-09 Thread Phlip
Zach Dennis wrote: response.body.should be_xml_with do form :action = '/users' do fieldset do legend Personal Information label First name input :type = 'text', :name = 'user[first_name]' end end end I like this a lot. Boom: http://gist.github.com/76136 it

Re: [rspec-users] Rails 2.2.2 Problem - button_to_function - nil.with_output_buffer

2009-03-09 Thread David Chelimsky
On Mon, Mar 9, 2009 at 4:44 AM, karmacoma oliver.bedd...@googlemail.com wrote: Hi, I am in the process of upgrading my rails application to be compatible with rails 2.2.2. All is going well apart from a few remaining issues. My problem is: I am experiencing a test failure with what seems to

Re: [rspec-users] Cucumber 0.2 final release date?

2009-03-09 Thread aslak hellesoy
On Fri, Mar 6, 2009 at 1:27 PM, Tom Ten thij li...@ruby-forum.com wrote: I'm afraid I can't give a release date. 0.2 is fixed(ish) scope, and therefore time can't be fixed at the same time. I have a lot of travel the next month, so it will take a least a month I'm afraid. I know I for

[rspec-users] Presentation Testing and CSS ids

2009-03-09 Thread James Byrne
Zach Dennis wrote: In my experience relying on the syntactic details of the page is extremely brittle and cumbersome. ... Some tags have both syntactic and semantic meaning, such as forms, labels, fieldsets, and anchor tags. Is it brittle to test for specific css selectors that are tied to

[rspec-users] Cucumber - RSpec matcher

2009-03-09 Thread James Byrne
I must be missing something obvious here but I cannot seem to see it. I have this step definition: When /entity named (.*) has a legal name (.*)/ do |name, legal| myentity = Entity.find_by_entity_common_name!(name.hll_keycase) myentity.entity_legal_name.should equal legal.hll_keycase end

Re: [rspec-users] Cucumber - RSpec matcher

2009-03-09 Thread Pat Maddox
Use should == instead of equal. == is equality, equal is object identity. You very rarely want to use equal. foo.equal? foo = false foo == foo = true Pat On Mar 9, 2009, at 10:18 AM, James Byrne wrote: I must be missing something obvious here but I cannot seem to see it. I have this

Re: [rspec-users] Cucumber - RSpec matcher

2009-03-09 Thread aslak hellesoy
On Mon, Mar 9, 2009 at 6:18 PM, James Byrne li...@ruby-forum.com wrote: I must be missing something obvious here but I cannot seem to see it. I have this step definition: When /entity named (.*) has a legal name (.*)/ do |name, legal| myentity =

Re: [rspec-users] Cucumber - RSpec matcher

2009-03-09 Thread Rich Morin
At 10:54 -0700 3/9/09, Pat Maddox wrote: Use should == instead of equal. == is equality, equal is object identity. You very rarely want to use equal. It's probably far too late to change this, but it might have made more sense to define same_obj_as?() for the object identity case, leaving

Re: [rspec-users] Cucumber - RSpec matcher

2009-03-09 Thread David Chelimsky
On Mon, Mar 9, 2009 at 2:32 PM, Rich Morin r...@cfcl.com wrote: At 10:54 -0700 3/9/09, Pat Maddox wrote: Use should == instead of equal.  == is equality, equal is object identity.  You very rarely want to use equal. It's probably far too late to change this, but it might have made more sense

Re: [rspec-users] Cucumber - RSpec matcher

2009-03-09 Thread James Byrne
Pat Maddox wrote: Use should == instead of equal. == is equality, equal is object identity. You very rarely want to use equal. foo.equal? foo = false foo == foo = true Pat Thanks. Although, if I recall correctly then I am advised to use the form x.should be == y . ;- --

[rspec-users] Question on SQL exceptions

2009-03-09 Thread James Byrne
To prevent duplicate values in the DBMS I use a unique index on those columns. I am testing that duplicate values cannot, in fact, be added. This is the cucumber scenario: Scenario: The legal name must be unique Given I do have a user named admin And the user named admin is

Re: [rspec-users] Question on SQL exceptions

2009-03-09 Thread James Byrne
James Byrne wrote: Q. To prevent duplicate values in the DBMS I use a unique index on those columns. I am testing that duplicate values cannot, in fact, be added. I thought, probably incorrectly, that when #save is called then any errors are returned to the controller to handle. This is

Re: [rspec-users] Presentation Testing and CSS ids

2009-03-09 Thread Phlip
James Byrne wrote: Zach Dennis wrote: In my experience relying on the syntactic details of the page is extremely brittle and cumbersome. ... Some tags have both syntactic and semantic meaning, such as forms, labels, fieldsets, and anchor tags. Is it brittle to test for specific css

Re: [rspec-users] Cucumber - RSpec matcher

2009-03-09 Thread James Byrne
David Chelimsky wrote: No, no, no :) 5.should == 5 6.should be 5 Read them aloud and they.should make(:sense). Cheers, David Perhaps it is my dialect, but what is wrong with: 5 should be equal to 5 which generally is how I read ==? Actually, I tend to read == (in Ruby) as is

Re: [rspec-users] Question on SQL exceptions

2009-03-09 Thread Pat Maddox
ActiveRecord doesn't know anything about db constraint errors. If one is violated, the error propagates up in the form of an exception. Put a validates_uniqueness_of :login_name on your User class, and you'll get the behavior you want. You can keep the db constraint in as a safety net

Re: [rspec-users] Question on SQL exceptions

2009-03-09 Thread James Byrne
Pat Maddox wrote: ActiveRecord doesn't know anything about db constraint errors. If one is violated, the error propagates up in the form of an exception. I realize that, but the exception is of the ActiveRecord:StatementInvalid class, which I should be able to catch in the controller with

Re: [rspec-users] Question on SQL exceptions

2009-03-09 Thread Scott Taylor
On Mar 9, 2009, at 4:53 PM, James Byrne wrote: Pat Maddox wrote: ActiveRecord doesn't know anything about db constraint errors. If one is violated, the error propagates up in the form of an exception. I realize that, but the exception is of the ActiveRecord:StatementInvalid class, which

Re: [rspec-users] Cucumber - RSpec matcher

2009-03-09 Thread David Chelimsky
On Mon, Mar 9, 2009 at 2:48 PM, James Byrne li...@ruby-forum.com wrote: David Chelimsky wrote: No, no, no :) 5.should == 5 6.should be 5 Read them aloud and they.should make(:sense). Cheers, David Perhaps it is my dialect, but what is wrong with:   5 should be equal to 5 which

Re: [rspec-users] Question on SQL exceptions

2009-03-09 Thread Tim Glen
ActiveRecord doesn't know anything about db constraint errors. If one is violated, the error propagates up in the form of an exception. I realize that, but the exception is of the ActiveRecord:StatementInvalid class, which I should be able to catch in the controller with a rescue clause.

Re: [rspec-users] Presentation Testing and CSS ids

2009-03-09 Thread Zach Dennis
On Mon, Mar 9, 2009 at 12:08 PM, James Byrne li...@ruby-forum.com wrote: Zach Dennis wrote: In my experience relying on the syntactic details of the page is extremely brittle and cumbersome. ... Some tags have both syntactic and semantic meaning, such as forms, labels, fieldsets, and anchor

Re: [rspec-users] custom, nested HTML matchers in RSpec

2009-03-09 Thread Phlip
http://gist.github.com/76136 response.body.should be_html_with{ form :action = '/users' do fieldset do legend 'Personal Information' label 'First name' input :type = 'text', :name = 'user[first_name]' end end } Has anyone

Re: [rspec-users] Cucumber - RSpec matcher

2009-03-09 Thread aslak hellesoy
On Mon, Mar 9, 2009 at 8:48 PM, James Byrne li...@ruby-forum.com wrote: David Chelimsky wrote: No, no, no :) 5.should == 5 6.should be 5 Read them aloud and they.should make(:sense). Cheers, David Perhaps it is my dialect, but what is wrong with: 5 should be equal to 5

Re: [rspec-users] custom, nested HTML matchers in RSpec

2009-03-09 Thread David Chelimsky
On Mon, Mar 9, 2009 at 6:20 PM, Phlip phlip2...@gmail.com wrote: http://gist.github.com/76136    response.body.should be_html_with{      form :action = '/users' do        fieldset do          legend 'Personal Information'          label 'First name'          input :type = 'text', :name =

Re: [rspec-users] custom, nested HTML matchers in RSpec

2009-03-09 Thread Pat Nakajima
Has anyone tried this? is it useful? It looks interesting, though it could be confused for trying to exactly mimic the actual markup, not just specify interesting parts. On Mon, Mar 9, 2009 at 7:20 PM, Phlip phlip2...@gmail.com wrote: http://gist.github.com/76136 response.body.should

Re: [rspec-users] Question on SQL exceptions

2009-03-09 Thread James Byrne
Tim Glen wrote: Just a stab in the dark, but I haven't seen any mention of calling save vs. save!. save just puts any errors in the model, save! will raise the exception if there are any errors. That may not be the case for ActiveRecord:StatementInvalid exception, but I thought i'd mention

Re: [rspec-users] custom, nested HTML matchers in RSpec

2009-03-09 Thread David Chelimsky
On Mon, Mar 9, 2009 at 6:49 PM, Pat Nakajima patnakaj...@gmail.com wrote: Has anyone tried this? is it useful? It looks interesting, though it could be confused for trying to exactly mimic the actual markup, not just specify interesting parts. What is the method name was be_html_including

Re: [rspec-users] Question on SQL exceptions

2009-03-09 Thread Tim Glen
Just a stab in the dark, but I haven't seen any mention of calling save vs. save!. save just puts any errors in the model, save! will raise the exception if there are any errors. That may not be the case for ActiveRecord:StatementInvalid exception, but I thought i'd mention it anyway. I

Re: [rspec-users] custom, nested HTML matchers in RSpec

2009-03-09 Thread Phlip
Pat Nakajima wrote: Has anyone tried this? is it useful? It looks interesting, though it could be confused for trying to exactly mimic the actual markup, not just specify interesting parts. It only specifies interesting parts. The gist writeup explained that, for example, it skipped

Re: [rspec-users] Question on SQL exceptions

2009-03-09 Thread Pat Maddox
On Mar 9, 2009, at 1:53 PM, James Byrne wrote: Pat Maddox wrote: ActiveRecord doesn't know anything about db constraint errors. If one is violated, the error propagates up in the form of an exception. I realize that, but the exception is of the ActiveRecord:StatementInvalid class, which

Re: [rspec-users] custom, nested HTML matchers in RSpec

2009-03-09 Thread Phlip
I haven't tried it yet, but it does seem very useful. The project I'm focused on right now is all json all the time, so I don't personally have a real world case for this at the moment. Anybody doing an app w/ html views willing to try this out? I put it into my current project today (as a