我有水豚,當我運行我的精選測試提出了一個錯誤,它說測試環境中的待定遷移,但是當運行其他類型的測試一切都很好。我已經在測試環境中運行了所有的遷移,我已經在測試和開發環境中運行rails。我如何設置水豚與鐵軌4
這是我的Gemfile
group :development, :test do
.... other gems ....
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'database_cleaner'
gem 'capybara', '~> 2.5.0'
gem 'capybara-webkit', '~> 1.7.1'
gem 'selenium-webdriver'
gem 'poltergeist'
gem 'launchy-rails', '~> 0.0.1'
end
這是我的測試
# spec/features/sign_in_spec.rb
require 'rails_helper'
feature 'Visitor signs up' do
it "signs me in", :type => :feature do
visit new_user_session_path
puts "page: #{page.html.inspect}"
save_and_open_page
end
end
謝謝!
UPDATE:
我只是嘗試使用這個命令:
bin/rake db:drop db:create db:migrate RAILS_ENV=test
一切都確定了該命令。然後,我跑我的服務器: rails s -e test
同樣的錯誤, 「的ActiveRecord :: PendingMigrationError」 http://localhost:3000/
然後我跑遷移命令 斌/耙分貝:遷移RAILS_ENV =測試
但它提出了一個錯誤「ActiveRecord :: StatementInvalid:PG :: DuplicateTable:ERROR:relation」users「already exists」
和我運行功能測試時出現同樣的錯誤。
這裏是我的助手:https://gist.github.com/israelb/e2f4b10ba5f94e1e8df2
能否請您提供您的'rails_helper.rb'和' spec_helper.rb'? – jverban
運行建議的bin/rake數據庫會發生什麼情況:migrate RAILS_ENV = tests? –
爲什麼你甚至在測試環境中運行'rails s'? O_o –