Skip to content

Instantly share code, notes, and snippets.

@NobbZ
Created November 12, 2011 11:45
Show Gist options
  • Save NobbZ/1360422 to your computer and use it in GitHub Desktop.
Save NobbZ/1360422 to your computer and use it in GitHub Desktop.
These is the cucumber scenario and the corresponding steps that I have the problem with
# Scenario: Creating a product
# Given I am logged in with role "admin"
# When I follow "Admin-Panel"
# And I follow "new product"
# Then I should see "Please enter the new product data"
Given /^I am logged in with role "([^"]*)"$/ do |role|
Factory.create(:user, name: "root")
log_in "root"
end
Given /^I am viewing "([^"]*)"$/ do |path|
visit path
end
When /^I follow "([^"]*)"$/ do |link_text|
click_link link_text
end
Then /^I should see "([^"]*)"$/ do |text|
has_content? text
end
def log_in(name, pass = "secret")
visit "sessions#new"
fill_in "name", :with => name
fill_in "password", :with => pass
click_button "LogIn"
end
# The errormessage:
# Given I am logged in with role "admin"
# Scenario: Creating a product # features/products_admin.feature:6
# Given I am logged in with role "admin" # features/step_definitions/steps.rb:20
# And I am viewing "admin/products" # features/step_definitions/steps.rb:16
# undefined method `is_admin?' for nil:NilClass (NoMethodError)
# ./app/controllers/application_controller.rb:31:in `is_admin?'
# ./app/controllers/application_controller.rb:16:in `require_admin'
# ./features/step_definitions/steps.rb:17:in `/^I am viewing "([^"]*)"$/'
# features/products_admin.feature:8:in `And I am viewing "admin/products"'
# When I follow "Neues Produkt" # features/step_definitions/steps.rb:33
# Then I should see "Bitte neue Produktdaten eingeben" # features/step_definitions/steps.rb:49
# changes:
# - Added the log_in method
# - Altered the "Visit"-step with a "Follow"-one, now it seems to work, but why is that so? Why is the session canceled when using visit?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment