我試圖測試使用AJAX調用控制器操作的鏈接。從本質上講,當用戶點擊「關注」,他將與該公司相關聯,並且渲染部分將與JS執行。 的問題是,它工作正常,當我嘗試在發展,但它並沒有在測試中作出迴應。我一直在嘗試很多方法,而且看起來這個調用永遠不會到達控制器。Rspec的不執行AJAX調用
在這裏,您可以看到測試:
#spec/integration/following_spec.rb
it "should add the company to the ones followed by the user", :js => true do
find("#current_company").click_link "Follow"
sleep 2
@user.companies_followed.include?(@company).should be_true
end
的觀點:
#app/views/companies/_follow_button.html.slim
= link_to change_follow_state_company_path(@company), :method => :put, :remote => true, :id => "follow", :class => "btn_block light" do
' Follow
而且測試配置:
#spec/integration_helper.rb
require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
require 'capybara/rails'
Dir[Rails.root.join("spec/integration/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.use_transactional_fixtures = true
config.before do
clear_email_queue
end
end
Rails.cache.clear
什麼是測試日誌? – 2012-04-27 11:48:46
@Gawyn:你找到了解決方案嗎?我也有同樣的問題.. – Alan 2012-11-30 07:33:22