Cucumber login problem

Hello all,
I am facing a weird problem.I am just trying to login but after entering
correct parameters it is showing error as invalid username and password.
I think there is some configuration or fixtures problem because if i try
to login from GUI then it is working fine(using same database)
Following are the detailed list of gems and code.
Rspec (1.3.0, 1.1.12)
Rspec-rails (1.3.2, 1.1.12)
cucumber (0.6.3)
cucumber-rails (0.3.0)
Webrat (0.5.3, 0.4.3)

config/environments/cucumber.rb

Edit at your own peril - it’s recommended to regenerate this file

in the future when you upgrade to a newer version of Cucumber.

IMPORTANT: Setting config.cache_classes to false is known to

break Cucumber’s use_transactional_fixtures method.

For more information see

https://rspec.lighthouseapp.com/projects/16211/tickets/165
config.cache_classes = true

Log error messages when you accidentally call methods on nil.

config.whiny_nils = true

Show full error reports and disable caching

config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false

Disable request forgery protection in test environment

config.action_controller.allow_forgery_protection = false

Tell Action Mailer not to deliver emails to the real world.

The :test delivery method accumulates sent emails in the

ActionMailer::Base.deliveries array.

config.action_mailer.delivery_method = :test

config.gem ‘cucumber-rails’, :lib => false, :version => ‘>=0.3.0’
unless File.directory?(File.join(Rails.root,
‘vendor/plugins/cucumber-rails’))
config.gem ‘database_cleaner’, :lib => false, :version => ‘>=0.5.0’
unless File.directory?(File.join(Rails.root,
‘vendor/plugins/database_cleaner’))
config.gem ‘webrat’, :lib => false, :version => ‘>=0.5.3’
unless File.directory?(File.join(Rails.root, ‘vendor/plugins/webrat’))
config.gem ‘rspec’, :lib => false, :version => ‘>=1.3.0’
unless File.directory?(File.join(Rails.root, ‘vendor/plugins/rspec’))
config.gem ‘rspec-rails’, :lib => false, :version => ‘>=1.3.2’
unless File.directory?(File.join(Rails.root,
‘vendor/plugins/rspec-rails’))

features/support/env.rb

IMPORTANT: This file is generated by cucumber-rails - edit at your own

peril.

It is recommended to regenerate this file in the future when you

upgrade to a

newer version of cucumber-rails. Consider adding your own code to a

new file

instead of editing this one. Cucumber will automatically load all

features/**/*.rb

files.

ENV[“RAILS_ENV”] ||= “test”
require File.expand_path(File.dirname(FILE) +
‘/…/…/config/environment’)

require ‘cucumber/formatter/unicode’ # Remove this line if you don’t
want Cucumber Unicode support
require ‘cucumber/rails/rspec’
require ‘cucumber/rails/world’
require ‘cucumber/rails/active_record’
require ‘cucumber/web/tableish’

require ‘webrat’
require ‘webrat/core/matchers’

Webrat.configure do |config|
config.mode = :rails
config.open_error_files = false # Set to true if you want error pages
to pop up in the browser
end

Before do
Fixtures.reset_cache
fixtures_folder = File.join(RAILS_ROOT, ‘spec’, ‘fixtures’)
fixtures = Dir[File.join(fixtures_folder, ‘*.yml’)].map {|f|
File.basename(f, ‘.yml’) }
Fixtures.create_fixtures(fixtures_folder, fixtures)
end

If you set this to false, any error raised from within your app will

bubble

up to your step definition and out to cucumber unless you catch it

somewhere

on the way. You can make Rails rescue errors and render error pages on

a

per-scenario basis by tagging a scenario or feature with the

@allow-rescue tag.

If you set this to true, Rails will rescue all errors and render error

pages, more or less in the same way your application would behave in

the

default production environment. It’s not recommended to do this for

all

of your scenarios, as this makes it hard to discover errors in your

application.
ActionController::Base.allow_rescue = false

If you set this to true, each scenario will run in a database

transaction.

You can still turn off transactions on a per-scenario basis, simply

tagging

a feature or scenario with the @no-txn tag. If you are using Capybara,

tagging with @culerity or @javascript will also turn transactions off.

If you set this to false, transactions will be off for all scenarios,

regardless of whether you use @no-txn or not.

Beware that turning transactions off will leave data in your database

after each scenario, which can lead to hard-to-debug failures in

subsequent scenarios. If you do this, we recommend you create a Before

block that will explicitly put your database in a known state.

Cucumber::Rails::World.use_transactional_fixtures = true

How to clean your database when transactions are turned off. See

http://github.com/bmabey/database_cleaner for more info.

if defined?(ActiveRecord::Base)
begin
require ‘database_cleaner’
DatabaseCleaner.strategy = :truncation
rescue LoadError => ignore_if_database_cleaner_not_present
end
end

features/manage_users.feature
Given a registered user
When he clicks on login link
And after filling all the details
Then the user should be logged in

features/step_definitions/user_steps.rb
Given /^a registered user$/ do
visit ‘/login’
end

When /^he clicks on login link$/ do
visit ‘/login’
fill_in(“login”, :with => “test”)
fill_in(“password”, :with => “test123”)
click_button “Log in”
p current_url
p response.body
end

Then /^that user should get created$/ do
@user = User.find_by_login(“test”)
@user.test.should == “test”
end

This is my whole scenario.Now if i see the current url it says
‘/session’ which actually should be ‘/users’ and in response.body it
says ‘invalid username and password’

Also in my database list of users are already present
Please suggest

On Apr 29, 2010, at 9:54 AM, Amit K. wrote:

Webrat (0.5.3, 0.4.3)

Tell Action Mailer not to deliver emails to the real world.

config.gem ‘webrat’, :lib => false, :version => ‘>=0.5.3’

It is recommended to regenerate this file in the future when you

Webrat.configure do |config|
Fixtures.create_fixtures(fixtures_folder, fixtures)
@allow-rescue tag.

If you set this to true, each scenario will run in a database

after each scenario, which can lead to hard-to-debug failures in

rescue LoadError => ignore_if_database_cleaner_not_present
Given /^a registered user$/ do
end
Also in my database list of users are already present
Please suggest

Please post cucumber issues to http://groups.google.com/group/cukes.

Good luck!

David

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs