minitest と rails と capybara を使用していますが、次のテストでこのエラーが発生します...
undefined method `visit' for #<Page:0x007f8bf3697630>
STDERR:
Exception `NoMethodError' at /Users/trace/.rvm/gems/ruby-1.9.3-p194@application.1/gems/activemodel-3.1.8/lib/active_model/attribute_methods.rb:385:in `method_missing'
/Users/trace/.rvm/gems/ruby-1.9.3-p194@application.1/gems/activerecord-3.1.8/lib/active_record/attribute_methods.rb:60:in `method_missing'
/Users/trace/.rvm/gems/ruby-1.9.3-p194@application.1/gems/capybara-2.0.1/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
test/support/utilities.rb:2:in `sign_in_user'
test/integration/pages_intergration_test.rb:12:in `block (4 levels) in <top (required)>'
/Users/trace/.rvm/gems/ruby-1.9.3-p194@application.1/gems/mocha-0.9.12/lib/mocha/integration/mini_test/version_201_to_202.rb:27:in `run'
ここに私のファイルがありますtest/integration/pages_intergration_test.rb
require "minitest_helper"
describe "Pages integration" do
let(:page) { FactoryGirl.create(:page }
describe "Page Management tool" do
describe "Visiting a page" do
let(:user) { FactoryGirl.create(:user)}
it "Should see the welcome message" do
sign_in_user(admin_user)
should have_content("Welcome")
end
end
end
end
そして私のファイルtest/support/utilities.rb
def sign_in_user(user)
visit root_path
fill_in "EMAIL ADDRESS", with: user.email
fill_in "PASSWORD", with: user.password
click_button "SIGN IN"
end
そして、ここに私のminitest.rbがあります...ここで何か間違ったことをしたかもしれない場合に備えて
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require "minitest/autorun"
require "minitest/rails"
require "minitest/rails/capybara"
require "active_support/testing/setup_and_teardown"
require 'turn'
require 'factory_girl'
Dir[Rails.root.join("test/support/**/*.rb")].each {|f| require f}
Dir.glob(File.dirname(__FILE__) + "/factories/*").each do |factory|
require factory
end
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
class MiniTest::Rails::ActiveSupport::TestCase
before :each do
DatabaseCleaner.start
end
after :each do
DatabaseCleaner.clean
end
end
class IntegrationTest < MiniTest::Spec
include Rails.application.routes.url_helpers
include Capybara::DSL
register_spec_type(/integration$/, self)
before :each do
DatabaseCleaner.start
end
after :each do
DatabaseCleaner.clean
Capybara.reset_sessions!
Capybara.use_default_driver
end
end
class HelperTest < MiniTest::Spec
include ActiveSupport::Testing::SetupAndTeardown
include ActionView::TestCase::Behavior
register_spec_type(/Helper$/, self)
before :each do
DatabaseCleaner.start
end
after :each do
DatabaseCleaner.clean
end
end
何が問題なのかについてのアイデア...