Skip to content

Instantly share code, notes, and snippets.

@chikamichi
Created March 10, 2010 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chikamichi/327885 to your computer and use it in GitHub Desktop.
Save chikamichi/327885 to your computer and use it in GitHub Desktop.
# no explicit reference to web_steps
# that is, features/authentication/step_definitions/authentication_steps.rb contains:
Given /^I am not authenticated$/ do
# do nothing
end
$ cucumber features/authentication/authentication.feature
Using the default profile...
Feature: User authentication
To ensure the safety of the application
As a would-be player
I must register as a user
Scenario: Fail Login # features/authentication/authentication.feature:6
Given I am not authenticated # features/authentication/step_definitions/authentication_steps.rb:3
When I go to the homepage # features/authentication/authentication.feature:8
Then I should be redirect to the login form # features/authentication/authentication.feature:9
1 scenario (1 undefined)
3 steps (2 undefined, 1 passed)
0m0.002s
You can implement step definitions for undefined steps with these snippets:
When /^I go to the homepage$/ do
pending # express the regexp above with the code you wish you had
end
Then /^I should be redirect to the login form$/ do
pending # express the regexp above with the code you wish you had
end
# with explicit reference to web_steps in order to try getting rid of the undefined step "When I go to the homepage"
# that is, features/authentication/step_definitions/authentication_steps.rb contains:
require File.expand_path(File.dirname(__FILE__) + '/../../step_definitions/web_steps')
Given /^I am not authenticated$/ do
# do nothing
end
$ cucumber features/authentication/authentication.feature
Using the default profile...
Feature: User authentication
To ensure the safety of the application
As a would-be player
I must register as a user
Scenario: Fail Login # features/authentication/authentication.feature:6
Given I am not authenticated # features/authentication/step_definitions/authentication_steps.rb:3
When I go to the homepage # features/step_definitions/web_steps.rb:22
String
"the homepage"
#<Object:0xc1c98c>
--
WORLD:
Object
WithinHelpers
NavigationHelpers
Cucumber::RbSupport::RbWorld
Kernel
undefined method `visit' for #<Object:0xc1c98c> (NoMethodError)
./features/step_definitions/web_steps.rb:32:in `/^(?:|I )go to (.+)$/'
features/authentication/authentication.feature:8:in `When I go to the homepage'
Then I should be redirect to the login form # features/authentication/authentication.feature:9
Failing Scenarios:
cucumber features/authentication/authentication.feature:6 # Scenario: Fail Login
1 scenario (1 failed)
3 steps (1 failed, 1 undefined, 1 passed)
0m0.003s
You can implement step definitions for undefined steps with these snippets:
Then /^I should be redirect to the login form$/ do
pending # express the regexp above with the code you wish you had
end
$ cucumber features/authentication.feature
Using the default profile...
Feature: User authentication
To ensure the safety of the application
As a would-be player
I must register as a user
Scenario: Fail Login # features/authentication.feature:6
Given I am not authenticated # features/step_definitions/authentication_steps.rb:3
When I go to the homepage # features/step_definitions/web_steps.rb:22
String
"the homepage"
#<Cucumber::Rails::World:0x5bc2978>
--
WORLD:
Cucumber::Rails::World
WithinHelpers
NavigationHelpers
Capybara
Cucumber::Web::Tableish
Cucumber::RbSupport::RbWorld
ActionDispatch::Integration::Runner
ActiveRecord::TestFixtures
ActiveSupport::Testing::Pending
ActiveSupport::Testing::Deprecation
ActiveSupport::Testing::Assertions
ActiveSupport::Testing::SetupAndTeardown::ForClassicTestUnit
ActiveSupport::Callbacks
ActiveSupport::Testing::SetupAndTeardown
ActiveSupport::Testing::Default
Test::Unit::Util::BacktraceFilter
Test::Unit::Assertions
Test::Unit::Priority
Test::Unit::NotificationHandler
Test::Unit::TestCaseNotificationSupport
Test::Unit::OmissionHandler
Test::Unit::TestCaseOmissionSupport
Test::Unit::PendingHandler
Test::Unit::TestCasePendingSupport
Test::Unit::FailureHandler
Test::Unit::ErrorHandler
Test::Unit::ExceptionHandler
Test::Unit::Fixture
Test::Unit::Attribute
InstanceExecHelper
JSON::Ext::Generator::GeneratorMethods::Object
ActiveSupport::Dependencies::Loadable
Arel::Sql::ObjectExtensions
Arel::ObjectExtensions
Kernel
Then I should be redirect to the login form # features/authentication.feature:9
1 scenario (1 undefined)
3 steps (1 undefined, 2 passed)
0m0.217s
You can implement step definitions for undefined steps with these snippets:
Then /^I should be redirect to the login form$/ do
pending # express the regexp above with the code you wish you had
end
# in each case, features/step_definitions/web_steps.rb contains:
When /^(?:|I )go to (.+)$/ do |page_name|
announce page_name.class.inspect
announce page_name.inspect
announce self.inspect
announce "--"
announce "WORLD:\n #{self.class}"
world = self
(class << self; self; end).instance_eval do
world.announce " #{included_modules.join("\n ")}"
end
visit path_to(page_name)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment