Capybara在<top(required)=“”>'</top>中获得错误`block(2级)

时间:2012-01-07 20:03:24

标签: selenium tdd capybara rails-3.1

花了一整天的时间来处理这个问题。

非常简单的测试。我想访问主页并检查它是否有文本“匹配”。

require 'spec_helper'

describe "Sign in" do
  it "should sign in with correct data", :js => true do
    visit root_path
    page.should have_content("Match")
  end
end

运行rake规范:我得到的请求:

1) Sign in should sign in with correct data
     Failure/Error: visit root_path
     Timeout::Error:
       Timeout::Error
     # ./spec/requests/signin_spec.rb:5:in `block (2 levels) in <top (required)>'

无法修复它。无论有没有spork和后卫,它都无法工作,让我发疯:(

我的环境:

的Gemfile:

group :test, :development do 
  gem 'rspec-rails', '2.7.0' , :branch => 'rails3'
  gem 'capybara'
  gem 'guard'
  gem 'guard-rspec'
  gem 'guard-spork'
  gem 'growl'
  gem 'launchy'
  gem 'growl_notify', :require => false if RUBY_PLATFORM =~/darwin/i
  gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~/darwin/i
end

spec_helper.rb:

require 'rubygems'
require 'spork'


Spork.prefork do 

  ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../../config/environment", __FILE__)

  require 'rspec/rails'
  # Add this to load Capybara integration:
  require 'capybara/rspec'
  require 'capybara/rails'


  # Requires supporting ruby files with custom matchers and macros, etc,
  # in spec/support/ and its subdirectories.
  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

  RSpec.configure do |config|
    # Loading more in this block will cause your tests to run faster. However,
    # if you change any configuration or code from libraries loaded here, you'll
    # need to restart spork for it take effect.
    # == Mock Framework
    #
    # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
    #
    # config.mock_with :mocha
    # config.mock_with :flexmock
    # config.mock_with :rr
    config.mock_with :rspec

    # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
    config.fixture_path = "#{::Rails.root}/spec/fixtures"

    # If you're not using ActiveRecord, or you'd prefer not to run each of your
    # examples within a transaction, remove the following line or assign false
    # instead of true.
    config.use_transactional_fixtures = false

    # If true, the base class of anonymous controllers will be inferred
    # automatically. This will be the default behavior in future versions of
    # rspec-rails.
    config.infer_base_class_for_anonymous_controllers = false



    #config.treat_symbols_as_metadata_keys_with_true_values = true
    #config.filter_run :focus => true
    #config.run_all_when_everything_filtered = true
  end  
end

Spork.each_run do
  # This code will be run each time you run your specs.
  FactoryGirl.reload
end

0 个答案:

没有答案