Topic: Basic testing with Capybara

Hi all,

this must be something very simple, but I can't seem to find wha'ts wrong with my code.

I have a very simple form that works fine when I play with it with the browser.
When I test it with cucumber, the step that presses the submit button aparently does nothing since all subsequent "then" steps fail, founding none of the sucess messages that should appear.

I put a simple debug message that shows the html code of the forum after the submit button is pressed and it shows the unsubmited form html.

Any thoughts?

I really apreciate your help.

Thanks in advance

Re: Basic testing with Capybara

For someone that might be having the same problem:
I was using "click_on" method to push the submit button. It didn't raise any error, but it didn't submit the form.
I replaced it with "find_button(button).click" and now it works.

Even so I have the feeling that the first form should work.

my Gemfile:

gem 'rails'
gem 'mysql'
gem 'devise'
gem 'cancan'
gem 'cucumber'
gem 'rspec'
#rake 0.9 breaks rails
gem 'rake', "0.8.7"
gem 'jquery-rails'

group :test do
  # Pretty printed test output
  # gem 'turn', :require => false
  gem 'minitest'
  gem 'database_cleaner'
  gem 'capybara'
  gem 'cucumber-rails'
  gem 'rspec'

Any ideas?

Re: Basic testing with Capybara

I use click_button. Here's an example:

let(:submit) { "Submit post" }

before do
  fill_in "Content", with: "Foobar"

it "should create a post" do
  expect { click_button submit }.to change(Post, :count).by(1)

Hope that helps.