2012-12-27 1 views
3

rspec을 통해 레일 앱에 BDD를 통합하려고합니다. 나는 모니터링 프로세스를 가속화하기 위해 가드 및 스포크 레일을 사용하고 있습니다. 이 오류가 무엇입니까 : 나는 rake db:test:prepare를 실행닫힌 데이터베이스에서 호출 준비 rspec

An error occurred in an after hook 
ActiveRecord::StatementInvalid: ArgumentError: prepare called on a closed database: 
rollback transaction occurred at /Users/davidhahn/.rvm/gems/ruby-1.9.3-p286/gems/sqlite3-1.3.6/lib/sqlite3/database.rb:91:in initialize 

을 그리고 오류없이 달렸다. sqlite를 사용하고 있기 때문에 user_man_test.sqlite 파일이 db/에 있는지 확인했습니다. 제대로 spork를 구성하려고 도움 대신에 지출 시간의

+0

나는 내가 sqlite3의 구성에 뭔가 잘못되었다고 생각하게하는 오류를 수정 한 mysql로 ​​변경했다. –

답변

2

에 대한

require 'rubygems' 
require 'spork' 
Spork.prefork do 
    ENV["RAILS_ENV"] ||= 'test' 
    require File.expand_path("../../config/environment", __FILE__) 
    require 'rspec/rails' 
    require 'rspec/autorun' 
    Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} 
    RSpec.configure do |config| 
    config.fixture_path = "#{::Rails.root}/spec/fixtures" 
    config.use_transactional_fixtures = true 
    config.infer_base_class_for_anonymous_controllers = false 
    config.order = "random" 
    end 
end 
Spork.each_run do 
    # This code will be run each time you run your specs. 
end 

가 ~
감사 :

require 'spec_helper' 

describe "Authentication" do 
    describe "Login Page" do             
    it "should have the h1 'Welcome to User Management'" do     
     visit '/log_in'              
     page.should have_selector('h1', text: 'Welcome to User Management') 
    end                  
    end                  

    describe "Login" do              
    before { visit '/log_in' }            

    describe "with invalid information" do         
     before { click_button "Login" }          

     it { should have_selector('h1', text: 'Welcome to User Management') } 
     it { should have_selector('div.alert.alert-error', text: 'Invalid') } 
    end                  
    end                  
end 

내 spec_helper.rb의 모습 : 내 테스트는 단순한 통합 테스트입니다 , 나는 당신에게 Zeus을 보라고 조언 할 것이다. 이 질문에 정확히 답변하지 못해서 죄송합니다. 그러나 거의 1 년 동안 스포크로 보냈고, 새로운 테스트 보석을 추가 할 때마다 설정하는 데 수고 할 문제가 많았습니다. 스위치를 만들 때 모든 것이 마술처럼 작동했습니다. 내 경험상 제우스의 성능은 스포크보다 훨씬 낫다.)

+0

조언 해 주셔서 감사합니다. 나는 실제로 가드와 스포크를 모두 사용하지 않고 있지만 제우스를 시도 할 것입니다. –

+0

@DavidHahn 귀하의 질문에 대한 답변이 있으면 답변으로 받아 들여 다른 사람들이 귀하의 질문을 해결할 수 있도록해야합니다. – tomeduarte

관련 문제