Ruby on rails 使用poltergeist、rspec、capybara、spork guard和rails 3.2.12在子域上登录

Ruby on rails 使用poltergeist、rspec、capybara、spork guard和rails 3.2.12在子域上登录,ruby-on-rails,ruby-on-rails-3,capybara,rspec-rails,poltergeist,Ruby On Rails,Ruby On Rails 3,Capybara,Rspec Rails,Poltergeist,我无法让我的测试在子域上登录用户 更新 require 'spec_helper' feature 'home' do let(:user) {FactoryGirl.create(:user)} let!(:firm) {user.firm} let(:project) {FactoryGirl.create(:project, firm:firm)} let(:statistics) {"http://#{firm.subdomain}

我无法让我的测试在子域上登录用户

更新

require 'spec_helper'
feature 'home' do

  let(:user)        {FactoryGirl.create(:user)}
  let!(:firm)       {user.firm} 
  let(:project)     {FactoryGirl.create(:project, firm:firm)}
  let(:statistics)  {"http://#{firm.subdomain}.lvh.me:3001/statistics"} 
  let(:timesheet)   {"http://#{firm.subdomain}.example.com/timesheets/#{user.id}"}
  let(:account)     {"http://#{firm.subdomain}.lvh.me:3001/account"}

    before(:each) do 
      login_as(user, :scope => :user, :domains => :all)  
    end

    scenario "Statistics" do 
     visit statistics
     page.should have_content("Stats for users")
     page.should have_content(user.name) 
    end 
    scenario 'account' do 
     visit account
      page.should have_content("Memeber since: ") 
    end
    scenario "Statistics select", js: true do
      login_as(user, :scope => :user, :domains => :all) 
      visit statistics
      page.should have_content(firm.name)
      page.should have_content(user.name)
      page.current_url.should == statistics
      page.select("Stats for projects", :from => "stats")
       save_and_open_page
      page.should have_content(project.name)
    end    
end
我又试着和赛琳娜玩了。现在我在test.log中发现了这个错误

PG::Error: ERROR:  deadlock detected
DETAIL:  Process 15762 waits for AccessExclusiveLock on relation 2994754 of database 2952965; blocked by process 15020.
Process 15020 waits for ShareLock on transaction 93977; blocked by process 15762.
我猜
spec\u helper.rb
rails s-e test-p3001
都在不同程度上扰乱了测试数据库,这让postgresql痛哭流涕

但是,如果不在测试环境中启动rails服务器,如何在需要身份验证的子域上测试javascript

原始问题

此规范为我提供了

require 'spec_helper'
feature 'home' do

  let(:user)        {FactoryGirl.create(:user)}
  let!(:firm)       {user.firm} 
  let(:project)     {FactoryGirl.create(:project, firm:firm)}
  let(:statistics)  {"http://#{firm.subdomain}.lvh.me:3001/statistics"} 
  let(:timesheet)   {"http://#{firm.subdomain}.example.com/timesheets/#{user.id}"}
  let(:account)     {"http://#{firm.subdomain}.lvh.me:3001/account"}

    before(:each) do 
      login_as(user, :scope => :user, :domains => :all)  
    end

    scenario "Statistics" do 
     visit statistics
     page.should have_content("Stats for users")
     page.should have_content(user.name) 
    end 
    scenario 'account' do 
     visit account
      page.should have_content("Memeber since: ") 
    end
    scenario "Statistics select", js: true do
      login_as(user, :scope => :user, :domains => :all) 
      visit statistics
      page.should have_content(firm.name)
      page.should have_content(user.name)
      page.current_url.should == statistics
      page.select("Stats for projects", :from => "stats")
       save_and_open_page
      page.should have_content(project.name)
    end    
end
此错误

..F   
Failures:

  1) home Statistics select
     Failure/Error: page.should have_content(firm.name)
       expected there to be text "name6" in "Please sign in. You need to sign in or register before continuing. Email Password Remember me Forgot your password?"
     # ./spec/features/home/statistics_spec.rb:30:in `block (2 levels) in <top (required)>'
     # ./spec/support/active_record.rb:13:in `block (3 levels) in <top (required)>'
     # ./spec/support/active_record.rb:12:in `block (2 levels) in <top (required)>'

Finished in 4.77 seconds
3 examples, 1 failure
require 'spork'
Spork.prefork do

  ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'database_cleaner'
require 'rspec/autorun'
require 'factory_girl'
require 'ruby-debug'
require 'capybara/rspec'
require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist
include Warden::Test::Helpers
Warden.test_mode!

Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

RSpec.configure do |config|
  config.include Devise::TestHelpers, :type => :controller

  config.extend ControllerMacros, :type => :controller
  config.include ControllerMacros, :type => :feature

  config.include RequestMacros, :type => :request
  config.mock_with :rspec

  config.use_transactional_examples = false
  config.use_transactional_fixtures = false
  config.before(:suite) do
    DatabaseCleaner.strategy = :truncation
  end

  config.before(:each) do
    DatabaseCleaner.start
  end

  config.after(:each) do
    DatabaseCleaner.clean
  end
  config.infer_base_class_for_anonymous_controllers = false
 end 

 Spork.each_run do
   FactoryGirl.reload  
 end
end