3

I am a complete newbie with ruby and am starting out using cucumber-nagios for some BDD testing.

I have installed cucumber-nagios on my Mac Pro using the instructions here:

http://auxesis.github.com/cucumber-nagios/

My Mac is running Snow Leapord 10.6.6 and has ruby 1.8.7 installed.

I have created some simple features to mechanize form submission. However try as I might whenever I submit a form the values of the form fields are not being passed with the request. No errors are returned (apart from the error reported for the final step dealing with the expected response page).

Thinking that perhaps the forms were too complicated I used a very simple form on the w3 site as the most simple test case possible.

http://www.w3schools.com/html/html_forms.asp

The form being submitted to is this:

Username:

and these are my feature steps:

When I go to "http://www.w3schools.com/html/html_forms.asp"

And I fill in "user" with "Chinese"

And I press "Submit"

Then I should see "user=Chinese"

The filling in of the form is done using the standard step code supplied with cucumber-nagios in http_steps.rb =>

When /^I fill in "(.*) with "(.*)"$/ do | field, value|
    fill_in(field, :with => value)
end

When running

cucumber-nagios features/form.feature

all the steps pass except the final one, and the HTML response states I didn't submit any data with my form.

I turned on webrat logging but this does not give any helpful information.

As I said, I have tried similar code on other web sites and forms with exactly the same results.

The only thing I can think of is that I am missing some vital part of the whole cucumber-nagios set-up. Do I need to create and configure a database for example as you do with Rails applications? Excuse my ignorance.

Rimian
  • 36,864
  • 16
  • 117
  • 117

1 Answers1

1

I was having the same issue, and we tracked it down to webrat not POSTing the form properly.

Whilst it's not an elegant solution, we found that telling webrat it was in Rails mode fixed the problem.

Add the following code to your features/support/env.rb file, which is generated by cucumber-nagios when you create a new project.

Webrat.configure do |config|
 config.mode = :rails
 config.open_error_files = false
end

I wrote a blog article called Checking form Submissions with Cucumber-Nagios which explains the answer in greater detail.

mlambie
  • 7,467
  • 6
  • 34
  • 41