rails-capybara js: true导致Mailers延迟,导致测试失败


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请求,除了有一个隐藏/显示effecve_date date_select标记的javascript。当我将js: true添加到spec mail[=> ActionMailer:: base . delivery . js: true.last]返回nil,但如果允许测试等待一到两秒钟,事情就会正常工作。我如何解决这个没有HACK !(版本:Capybara (1.1.3)
Webkit版本:capybara-webkit (0.13.0)

我能够通过在点击accept

后更改的页面上添加检查来获得此工作
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/#中的更多详细信息!主题/ruby-capybara EpbORzw7rq8

相关内容

  • 没有找到相关文章

最新更新