Rspec-rails-capybara js: true 导致 Mailers 延迟导致测试失败
Rspec-rails-capybara js: true causing delay in Mailers resulting in test failures
describe 'salary acceptance email' do
let!(:effective_date) { Date.current.next_week }
let(:salary) { FactoryGirl.create(:salary) }
it 'displays admin selected effective_date', js: true do
page.visit approval_path(salary)
page.uncheck('default_effective_date')
select effective_date.year.to_s, from: 'offer_effective_date_date_1i'
select I18n.t("date.month_names")[effective_date.month] , from: 'offer_effective_date_date_2i'
select effective_date.day.to_s, from: 'offer_effective_date_date_3i'
click_on 'Accept'
#binding.pry or wait_for_ajax - hack to let the test pass
expect(mail.body).to include_in_each_part(salary.amount)
expect(mail.body).to include_in_each_part(effective_date.strftime('%Y-%m-%d'))
end
end
这部分代码中没有任何 ajax 请求,除了 javascript hides/displays effective_date date_select 标记.
当我将 js: true 添加到规范 mail[=> ActionMailer::Base.deliveries
.last] returns nil 但如果允许测试等待一两秒钟,事情就会正常进行。我如何在没有 HACK 的情况下解决这个问题! :(
水豚版本:水豚 (1.1.3)
Webkit 版本:capybara-webkit (0.13.0)
我能够通过在点击接受后更改的页面上添加检查来实现此功能
describe 'salary acceptance email' do
let!(:effective_date) { Date.current.next_week }
let(:salary) { FactoryGirl.create(:salary) }
it 'displays admin selected effective_date', js: true do
page.visit approval_path(salary)
page.uncheck('default_effective_date')
select effective_date.year.to_s, from: 'offer_effective_date_date_1i'
select I18n.t("date.month_names")[effective_date.month] , from: 'offer_effective_date_date_2i'
select effective_date.day.to_s, from: 'offer_effective_date_date_3i'
click_on 'Accept'
expect(page).to have_content("Acceptance Completed Successfully")
expect(mail.body).to include_in_each_part(salary.amount)
expect(mail.body).to include_in_each_part(effective_date.strftime('%Y-%m-%d'))
end
end
感谢水豚队 :star: 。在 https://groups.google.com/forum/#!topic/ruby-capybara/EpbORzw7rq8
中查看更多详细信息
describe 'salary acceptance email' do
let!(:effective_date) { Date.current.next_week }
let(:salary) { FactoryGirl.create(:salary) }
it 'displays admin selected effective_date', js: true do
page.visit approval_path(salary)
page.uncheck('default_effective_date')
select effective_date.year.to_s, from: 'offer_effective_date_date_1i'
select I18n.t("date.month_names")[effective_date.month] , from: 'offer_effective_date_date_2i'
select effective_date.day.to_s, from: 'offer_effective_date_date_3i'
click_on 'Accept'
#binding.pry or wait_for_ajax - hack to let the test pass
expect(mail.body).to include_in_each_part(salary.amount)
expect(mail.body).to include_in_each_part(effective_date.strftime('%Y-%m-%d'))
end
end
这部分代码中没有任何 ajax 请求,除了 javascript hides/displays effective_date date_select 标记. 当我将 js: true 添加到规范 mail[=> ActionMailer::Base.deliveries .last] returns nil 但如果允许测试等待一两秒钟,事情就会正常进行。我如何在没有 HACK 的情况下解决这个问题! :(
水豚版本:水豚 (1.1.3)
Webkit 版本:capybara-webkit (0.13.0)
我能够通过在点击接受后更改的页面上添加检查来实现此功能
describe 'salary acceptance email' do
let!(:effective_date) { Date.current.next_week }
let(:salary) { FactoryGirl.create(:salary) }
it 'displays admin selected effective_date', js: true do
page.visit approval_path(salary)
page.uncheck('default_effective_date')
select effective_date.year.to_s, from: 'offer_effective_date_date_1i'
select I18n.t("date.month_names")[effective_date.month] , from: 'offer_effective_date_date_2i'
select effective_date.day.to_s, from: 'offer_effective_date_date_3i'
click_on 'Accept'
expect(page).to have_content("Acceptance Completed Successfully")
expect(mail.body).to include_in_each_part(salary.amount)
expect(mail.body).to include_in_each_part(effective_date.strftime('%Y-%m-%d'))
end
end
感谢水豚队 :star: 。在 https://groups.google.com/forum/#!topic/ruby-capybara/EpbORzw7rq8
中查看更多详细信息