cucumber + webrat with Lift (switch off auto generation of name/id attrs)

View: New views
4 Messages — Rating Filter:   Alert me  

cucumber + webrat with Lift (switch off auto generation of name/id attrs)

by ben-274 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

I love how Lift generates name/id attributes on form values - its a
great security feature.
But it does tend to make acceptance frameworks like cucumber+webrat
impossible to use.

For those not familar with cucumber+webrat, it is an acceptance
framework for testing, amongst other things, websites.
So if we were writing a test to submit a form, we would write a test
script which looked something like :

  fill_in "my_form_text_input_name", :with => inputValue
  click_button "Submit"

where the html would be :

 <input type="text" name="my_form_text_input_name" />

With Lift generating these automatic name/id attributes, it makes the
above impossible.

So my question is : Is it possible to turn this auto-generation off
for use when testing and then turn it back on for production ?

Thanks,
Ben
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: cucumber + webrat with Lift (switch off auto generation of name/id attrs)

by Naftoli Gugenheim :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Can't you go by input id instead of input name?
You can use the _id_> arrow to set the bind name as the id
Template:
  <pre:label />
Snippet:
  bind("pre", xhtml, "label" _id_>SHtml.text( ... ) )
Should produce
<input id="label" ... />


On Fri, Oct 30, 2009 at 3:00 PM, ben <ben@...> wrote:

Hi,

I love how Lift generates name/id attributes on form values - its a
great security feature.
But it does tend to make acceptance frameworks like cucumber+webrat
impossible to use.

For those not familar with cucumber+webrat, it is an acceptance
framework for testing, amongst other things, websites.
So if we were writing a test to submit a form, we would write a test
script which looked something like :

 fill_in "my_form_text_input_name", :with => inputValue
 click_button "Submit"

where the html would be :

 <input type="text" name="my_form_text_input_name" />

With Lift generating these automatic name/id attributes, it makes the
above impossible.

So my question is : Is it possible to turn this auto-generation off
for use when testing and then turn it back on for production ?

Thanks,
Ben



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: cucumber + webrat with Lift (switch off auto generation of name/id attrs)

by bearfeeder :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Fri, Oct 30, 2009 at 12:00 PM, ben <ben@...> wrote:

Hi,

I love how Lift generates name/id attributes on form values - its a
great security feature.
But it does tend to make acceptance frameworks like cucumber+webrat
impossible to use.

For those not familar with cucumber+webrat, it is an acceptance
framework for testing, amongst other things, websites.
So if we were writing a test to submit a form, we would write a test
script which looked something like :

 fill_in "my_form_text_input_name", :with => inputValue
 click_button "Submit"

where the html would be :

 <input type="text" name="my_form_text_input_name" />

With Lift generating these automatic name/id attributes, it makes the
above impossible.

So my question is : Is it possible to turn this auto-generation off
for use when testing and then turn it back on for production ?

Yes.  When you run Lift apps in test mode, the field names are stable (they do not change from request to request).
 

Thanks,
Ben




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: cucumber + webrat with Lift (switch off auto generation of name/id attrs)

by ben-274 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

Thanks very much, that's exactly what I'm after !

For anyone reading this and wondering how to put Lift in test mode,
here is one way if you're using maven+jetty :

mvn jetty:run -Drun.mode=test


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---