如何编写集成测试模态

时间:2014-07-02 12:23:15

标签: jquery ruby-on-rails rspec xmlhttprequest

我在网上搜索了如何为模态编写集成测试但没有成功。 我正在使用Rspec。代码工作正常,在我的浏览器中正确呈现模态

我的控制器测试正在通过,代码在这里

describe "GET #failed" do
  it "renders the failure status view" do
    @tool = FactoryGirl.create(:tool)
    xhr :get, :failed, { :id => @tool.id, :format => 'js' }
    response.should render_template :failed
  end
end

但集成测试不起作用,代码在这里

describe "rendering the failure status modal", :xhr => true, :js => true do
  before{ click_link 'false'}
  it {should have content('Failure')}
end

目前测试没有通过,这是错误。我以前研究过它 并且所有解决方案都没有起作用

1) Tools Management Page 
 rendering the failure status modal 
 Failure/Error: before { visit '/tools' }
 Selenium::WebDriver::Error::WebDriverError:
 Could not find Firefox binary (os=linux).
 Make sure Firefox is installed or set the path 
 manually with Selenium::WebDriver::Firefox::Binary.path=

我还没有找到适用于模态的集成测试的工作解决方案

1 个答案:

答案 0 :(得分:1)

Capybara的默认javascript驱动程序是Selenium,它需要浏览器才能运行。

查看poltergeist phantomjs的水豚驱动程序{{3}}。 Phantomjs是一款无头浏览器,非常适合运行需要Javascript的集成测试。