# Cucumber + authlogic trouble

**URL:** <https://www.ruby-forum.com/t/cucumber-authlogic-trouble/165152>\
**Category:** Rails\
**Created:** [April 9, 2009, 4:34pm UTC](https://www.ruby-forum.com/t/cucumber-authlogic-trouble/165152 "2009-04-09T16:34:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![scottnj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@scottnj](https://www.ruby-forum.com/u/scottnj)\
**Post date:** [April 9, 2009, 4:34pm UTC](https://www.ruby-forum.com/t/cucumber-authlogic-trouble/165152/1 "2009-04-09T16:34:39Z")

</div>

i am trying to learn testing for rails apps.  
i followed the two authlogic tutorials (basic authlogic setup and  
password reset) and now i am trying to add some integration tests with  
cucumber (i know you are supposed to do the tests 1st, but i am just  
trying to figure out how things work).

i found this app  
[http://github.com/hectoregm/rails-templates/tree/master](http://github.com/hectoregm/rails-templates/tree/master)  
with a bunch of cucumber/webrat tests setup for authlogic so i started  
applying them to my app

the app works fine when i do everything in the web browser, but i can  
not figure out why it doesn’t work with the tests. when it creates a  
user account it should go to the show account page and flash “account  
registered”, but instead it is creating a user in the database (good),  
going to my home page(bad), and the flash is “logout  
successful”(bad).

anyone have any guidance on what might be going wrong or how to  
troubleshoot this?

# from my feature file

Scenario: Allow an anonymous user to create account  
Given “hector” is an anonymous user  
When I go to the registration form  
And I fill in “login” with “hector”  
And I fill in “email” with “removed\_email\_address@domain.invalid”  
And I fill in “password” with “secret”  
And I fill in “password confirmation” with “secret”  
And I press “Register”  
Then I should have a successful registration

# the relevent steps

Given /“(.\*)” is an anonymous user/ do |name| # registration\_steps.rb  
visit ‘/logout’  
visit ‘/’  
end

When /^I go to (.+)$/ do |page\_name| # webrat\_steps.rb  
visit path\_to(page\_name)  
end

when /the registration form/ # paths.rb  
new\_account\_path

When /^I fill in “([^"]_)" with "([^"]_)”$/ do |field, value| #  
webrat\_steps.rb  
fill\_in(field, :with =\> value)  
end

When /^I press “([^"]\*)”$/ do |button| # webrat\_steps.rb  
click\_button(button)  
end

Then /^I should have a successful registration$/ do #  
registration\_steps.rb  
When ‘I should see “Account registered!”’  
end

Then /^I should see “([^"]\*)”$/ do |text| # webrat\_steps.rb  
response.should contain(text)  
end

# output from running “cucumber features”

Feature: Registration  
As a anonymous user  
I want be able to register  
So that can be productive and be cool

Scenario: Allow an anonymous user to create account # features/  
registration.feature:13  
Given “hector” is an anonymous user # features/  
step\_definitions/registration\_steps.rb:1  
When I go to the registration form # features/  
step\_definitions/webrat\_steps.rb:10  
And I fill in “login” with “hector” # features/  
step\_definitions/webrat\_steps.rb:22  
And I fill in “email” with “removed\_email\_address@domain.invalid” # features/  
step\_definitions/webrat\_steps.rb:22  
And I fill in “password” with “secret” # features/  
step\_definitions/webrat\_steps.rb:22  
And I fill in “password confirmation” with “secret” # features/  
step\_definitions/webrat\_steps.rb:22  
And I press “Register” # features/  
step\_definitions/webrat\_steps.rb:14  
Then I should have a successful registration # features/  
step\_definitions/registration\_steps.rb:54  
expected the following element’s content to include “Account  
registered!”:  
home: index  
Source code | Setup tutorial | Password reset tutorialOpenID  
tutorial | Authlogic Repo | Authlogic Doc  
Authlogic Example App  
1 user currently logged inRegister |  
Log In |  
Forgot password  
Logout successful!  
Home Page  
(Spec::Expectations::ExpectationNotMetError)  
./features/step\_definitions/webrat\_steps.rb:94:in `/^I should see "([^\"]*)"$/' features/registration.feature:21:in `Then I should have a  
successful registration’

1 scenario  
1 failed step  
7 passed steps

---

<div class="post-metadata">

**Author:** ![scottnj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@scottnj](https://www.ruby-forum.com/u/scottnj)\
**Post date:** [April 9, 2009, 6:06pm UTC](https://www.ruby-forum.com/t/cucumber-authlogic-trouble/165152/2 "2009-04-09T18:06:53Z")

</div>

Scott Nj wrote:

> i am trying to learn testing for rails apps.  
> i followed the two authlogic tutorials (basic authlogic setup and  
> password reset) and now i am trying to add some integration tests with  
> cucumber (i know you are supposed to do the tests 1st, but i am just  
> trying to figure out how things work).

I cannot say what is causing your problem from the info given, but I  
suspect that you have a problem with a controller somewhere; probably in  
the authentication setup in application.rb.

You likely will get better responses, or at least more focused ones, by  
posting to either the respec list/forums:

RSpec

removed\_email\_address@domain.invalid  
[http://www.ruby-forum.com/forum/32](http://www.ruby-forum.com/forum/32)

or on the authlogic forums.

Authlogic

removed\_email\_address@domain.invalid  
[http://groups.google.com/group/authlogic?hl=en](http://groups.google.com/group/authlogic?hl=en)
