2

これは私のオンラインでの最初の質問です。コメントしてください。質問を更新して明確にします。

私はWeb開発にまったく慣れておらず、現在、会社のプロジェクトのテストスイートに取り組んでいます。javascriptを含む関数の統合テストを行おうとしているところまではうまく機能していました。webkit(gitからバンドル)とセレンの両方を使ってみました。Webkitは次のエラーメッセージを出しました。

Wrote response false "Unable to load URL: http://127.0.0.1:56618/ because of error loading http://127.0.0.1:56618/: Connection closed" 
Cleaning database...done
Received "Reset" 
Started "Reset" 
Finished "Reset" 
Wrote response true "" 
  should see invalid message (FAILED - 1)
Failures:
  1) Users GET /sign_in with invalid account should see invalid message
 Failure/Error: visit root_path
 Capybara::Webkit::InvalidResponseError:
   Unable to load URL: http://127.0.0.1:56618/ because of error loading http://127.0.0.1:56618/: Connection closed

そして、Seleniumを使用するとき、FireFoxは次のことについて不平を言います。

Your Firefox profile cannot be loaded. It may be missing or inaccessible.

何が問題なのか、誰か手がかりがありますか?前もって感謝します!

私のsepc_helper.rb

Spork.prefork do
  ...
  ..
  .
  RSpec.configure do |config|
    config.use_transactional_fixtures = false
    config.before(:suite) { require "#{Rails.root}/db/seeds.rb" }
    config.before(:each) do
      if Capybara.current_driver == :rack_test
        DatabaseCleaner.strategy = :transaction                                                                               
      else
        DatabaseCleaner.strategy = :truncation
      end
      DatabaseCleaner.start
    end

    config.after(:each) do
      if Capybara.current_driver == :rack_test
        DatabaseCleaner.clean
      else
        DatabaseCleaner.clean
        load "#{Rails.root}/db/seeds.rb"
      end 
    end 

  end
end

Spork.each_run do
  ActiveRecord::Schema.verbose = false
  load "#{Rails.root.to_s}/db/schema.rb"
  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
end
4

1 に答える 1

2

よくわかりませんが、これを試すことができます。

spec_helper.rbファイルに以下のコードを追加します

require 'spork'
Spork.prefork do

   # This file is copied to spec/ when you run 'rails generate rspec:install'

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

  require 'rspec/rails'

  require 'rspec/autorun'

  require 'email_spec'


  # Add this to load Capybara integration:

  require 'capybara/rspec'
  require 'capybara/rails'

  # Database Cleaner
  #require 'database_cleaner'

  # DatabaseCleaner.strategy = :truncation


  # 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}

Spork.each_run do
end

データベースクリーナーのコメントを外す1つのことを行います。

于 2012-10-15T13:03:34.430 に答える