JS消息中有have_content

时间:2015-08-13 10:50:41

标签: ruby-on-rails ruby rspec gem

我需要检查toastr-rails中的文本消息。但在我的测试中,文字并未显示。如何用js运行rspec?或者我应该做点什么?

scenario "#email" do
  fill_in "user_email", with: "johndoe@mail.com"
  click_on "Save"
  expect(page).to have_content 'Your account has been updated successfully'
end

我的留言模板(toastr)

<% unless flash.empty? %>
<script type="text/javascript">
    <% flash.each do |f| %>
    <% type = f[0].to_s.gsub('alert', 'error').gsub('notice', 'info') %>
    toastr['<%= type %>']('<%= f[1] %>');
    <% end %>
</script>

1 个答案:

答案 0 :(得分:0)

我有同样的问题,这就是它的工作原理

  1. 在您的方案中使用[{"High Level Code (L1)"=>1, "High Level Sector Description"=>"Education", "Budget"=>11362}, {"High Level Code (L1)"=>2, "High Level Sector Description"=>"Health", "Budget"=>5524}]
  2. Capybara.javascript_driver
    1. 检查toastr生成的scenario "#email", :js => true do fill_in "user_email", with: "johndoe@mail.com" click_on "Save" expect(page).to have_content 'Your account has been updated successfully' end 内的消息
    2. div