kid*_*rax 5 selenium solr rspec ruby-on-rails sunspot
我有一个使用硒运行的积分测试.在我之前我用solr构建了一些对象和索引.我可以在subnsspot solr测试日志中看到该活动.然后在我的测试中我执行搜索并得到错误,因为我的太阳黑子solr服务器没有运行.那是因为它正在运行RAILS_ENV = test.
这是我之前的每一个:
before :each do
Sunspot.remove_all!(Residential)
Sunspot.commit
@prop1 = FactoryGirl.create(:residential, { subdivision: "Steiner Ranch", street_name: "propone" })
@prop1.index!
@prop2 = FactoryGirl.create(:residential, { subdivision: "Jester Estates", street_name: "proptwo" })
@prop2.index!
@prop3 = FactoryGirl.create(:residential, { subdivision: "Cypress Ranch", street_name: "propthree" })
@prop3.index!
end
Run Code Online (Sandbox Code Playgroud)
这是我的测试:
it "single word", :js => true do
visit '/'
fill_in 'subdivision', :with => 'cypress'
page.should_not have_content('propone')
page.should_not have_content('proptwo')
page.should have_content('propthree')
end
Run Code Online (Sandbox Code Playgroud)
知道搜索在开发环境而不是测试环境中运行的原因吗?我将ENV ["RAILS_ENV"] || ='test'作为spec_helper中的第一行.
我有同样的问题.事实证明我运行的Rails应用程序实际上在配置文件中指定了ENV ["RAILS_ENV"] ='development'(因为我们使用乘客,所以是Apache配置文件).
如果是这种情况,那么你可以更换
ENV["RAILS_ENV"] ||= 'test'
Run Code Online (Sandbox Code Playgroud)
同
ENV["RAILS_ENV"] = 'test'
Run Code Online (Sandbox Code Playgroud)
在您的spec_helper中.
我这样做了
| 归档时间: |
|
| 查看次数: |
6657 次 |
| 最近记录: |