Created
March 10, 2010 01:44
-
-
Save chikamichi/327391 to your computer and use it in GitHub Desktop.
rails3 + cucumber fail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gem list | |
*** LOCAL GEMS *** | |
abstract (1.0.0) | |
actionmailer (3.0.0.beta) | |
actionpack (3.0.0.beta) | |
activemodel (3.0.0.beta) | |
activerecord (3.0.0.beta) | |
activeresource (3.0.0.beta) | |
activesupport (3.0.0.beta, 2.3.5) | |
arel (0.2.1) | |
authlogic (2.1.3) | |
builder (2.1.2) | |
bundler (0.9.11, 0.9.10) | |
capybara (0.3.5) | |
cgi_multipart_eof_fix (2.5.0) | |
cucumber (0.6.3) | |
cucumber-rails (0.3.0) | |
culerity (0.2.9) | |
daemons (1.0.10) | |
database_cleaner (0.5.0) | |
devise (1.1.pre4) | |
diff-lcs (1.1.2) | |
erubis (2.6.5) | |
fastthread (1.0.7) | |
ffi (0.6.2) | |
gem-man (0.1.3) | |
gem_plugin (0.2.3) | |
gemcutter (0.5.0) | |
haml (2.2.20) | |
hoe (2.5.0) | |
i18n (0.3.5) | |
jnunemaker-validatable (1.8.1) | |
json_pure (1.2.2) | |
mail (2.1.3) | |
memcache-client (1.7.8) | |
mime-types (1.16) | |
mongo (0.19.1, 0.18.3) | |
mongo_ext (0.19.1, 0.18.3) | |
mongo_mapper (0.7.0) | |
mustache (0.6.0) | |
newgem (1.5.3) | |
nokogiri (1.4.1) | |
parallel (0.4.0) | |
polyglot (0.3.0) | |
rack (1.1.0) | |
rack-mount (0.5.1, 0.4.7) | |
rack-test (0.5.3) | |
rails (3.0.0.beta) | |
rails3-generators (0.4.0) | |
railties (3.0.0.beta) | |
rake (0.8.7) | |
RedCloth (4.2.3) | |
rspec (2.0.0.beta.3) | |
rspec-core (2.0.0.beta.3) | |
rspec-expectations (2.0.0.beta.3) | |
rspec-mocks (2.0.0.beta.3) | |
rspec-rails (2.0.0.beta.3) | |
rubigen (1.5.4) | |
rubyforge (2.0.4) | |
rubygems-update (1.3.6, 1.3.5) | |
selenium-webdriver (0.0.17) | |
sqlite3-ruby (1.2.5) | |
syntax (1.0.0) | |
term-ansicolor (1.0.4) | |
test-unit (2.0.7) | |
text-format (1.0.0) | |
text-hyphen (1.0.0) | |
thor (0.13.4) | |
treetop (1.4.4) | |
tzinfo (0.3.17) | |
warden (0.9.6) | |
webrat (0.7.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rvm list | |
rvm Rubies | |
ruby-1.8.7-p249 [ x86_64 ] | |
=> ruby-1.9.1-p378 [ x86_64 ] | |
System Ruby | |
system [ ] | |
$ ruby -v | |
ruby 1.9.1p378 (2010-01-10 revision 26273) [x86_64-linux] | |
$ rails -v | |
Rails 3.0.0.beta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/model/item.rb | |
class Item | |
#attr_accessible :name, :password,, :username | |
include ActiveModelBehavior # see my words on http://groups.google.com/group/mongomapper/browse_thread/thread/2a247f17a5d06dda | |
include MongoMapper::Document | |
key :name, String, :unique => true, :null => false | |
key :power, Integer | |
key :price, Integer | |
# I moved this into a lib and do include ActiveModelBehavior instead | |
#class << self | |
#def model_name | |
#@_model_name ||= ActiveModel::Name.new(self) | |
#end | |
#end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# created the app as in http://gist.github.com/327345 | |
# but added mongomapper in between (see mongodb.rb, mongodb.yml and item.rb) | |
$ cucumber | |
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 | |
#<Object:0xcad22c> | |
BasicObject | |
Kernel | |
undefined method `visit' for #<Object:0x15e42b8> (NoMethodError) | |
./features/step_definitions/web_steps.rb:25: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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# created the app as in http://gist.github.com/327345 | |
$ cucumber | |
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:1 | |
When I go to the homepage # features/step_definitions/web_steps.rb:22 | |
#<Cucumber::Rails::World:0x4326bfc> | |
ActionDispatch::IntegrationTest | |
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 | |
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.019s | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/mongodb.rb | |
include MongoMapper | |
db_config = YAML::load(File.read(File.join(Rails.root, "/config/mongodb.yml"))) | |
if db_config[Rails.env] && db_config[Rails.env]['adapter'] == 'mongodb' | |
mongo = db_config[Rails.env] | |
MongoMapper.connection = Mongo::Connection.new(mongo['host'] || 'localhost', | |
mongo['port'] || 27017, | |
:logger => Rails.logger) | |
MongoMapper.database = mongo['database'] | |
if mongo['username'] && mongo['password'] | |
MongoMapper.database.authenticate(mongo['username'], mongo['password']) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/mongodb.yml | |
base: &base | |
adapter: mongodb | |
database: rails3-test-cucumber-mm | |
development: | |
<<: *base | |
test: | |
<<: *base | |
database: rails3-test-cucumber-mm-test | |
production: | |
<<: *base | |
database: rails3-test-cucumber-mm-production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# changed features/step_definitions/web_steps.rb | |
# from: | |
When /^(?:|I )go to (.+)$/ do |page_name| | |
visit path_to(page_name) | |
end | |
# to: | |
When /^(?:|I )go to (.+)$/ do |page_name| | |
announce self.inspect | |
announce self.class.superclass.inspect | |
announce self.class.included_modules.join("\n") | |
visit path_to(page_name) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment