好吧我不知道我錯過了建立水豚,但在測試訪問鏈接似乎不工作。所以我有一個3.2的應用程序,我有我的specs_helper設置像這樣:水豚訪問不工作
require "spork"
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'factory_girl'
require 'capybara/rspec'
require 'capybara/rails'
Capybara.javascript_driver = :selenium
Capybara.default_wait_time = 5
include Devise::TestHelpers # see spec/support/devise.rb
include CarrierWave::Test::Matchers
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
include New_spec_helpers
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.mock_with :rspec
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = false
config.before :each do
Capybara.default_selector = :css
if Capybara.current_driver == :rack_test
DatabaseCleaner.strategy = :transaction
else
DatabaseCleaner.strategy = :truncation
end
DatabaseCleaner.start
end
config.after do
DatabaseCleaner.clean
end
end
end
Spork.each_run do
FactoryGirl.factories.clear
FactoryGirl.define do
sequence(:code) { |n| "code#{n}" }
sequence(:title) { |n| "title#{n}" }
end
Dir[Rails.root.join("spec/factories/**/*.rb")].each{|f| load f}
PortfolioNew::Application.reload_routes!
end
然後我的測試設置是這樣的:
before(:each) do
build_projects
visit(projects_path)
end
it "test js" , :js=>true do
current_path.should == projects_path
end
但是,所有我得到的回報是:
Failure/Error: current_path.should == projects_path
expected: "/projects"
got: nil (using ==)
我檢查了我的路線和項目路徑絕對正確並且正常工作。什麼問題是會受到歡迎
很高興您設法解決問題!網絡釣魚/水豚的事情可以是一個真正的痛苦... – 2012-08-13 21:24:36
歡呼它是讓我瘋狂! :) – 2012-08-13 21:42:11