2015-05-26 47 views
1
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 

没有在这部分代码不同的是有其中隐藏/显示EFFECTIVE_DATE date_select标签一个JavaScript任何AJAX请求邮件程序真引起的延迟。 当我添加js:true到规格邮件[=> ActionMailer :: Base.deliveries .last]时返回nil,但如果允许测试等待一秒钟或两秒钟,则可以正常工作。如何在没有HACK的情况下解决这个问题! :(Rspec的护栏-水豚JS:在导致测试失败

水豚版本:水豚(1.1.3)
的Webkit版本:水豚,WebKit的(0.13.0)

回答

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 

所有学分豚团队:星:在https://groups.google.com/forum/#!topic/ruby-capybara/EpbORzw7rq8

。检查出更多细节