ruby on rails - Using regular expressions with Capybara -


in below capybara test want check user can see number after 'temperature:' when visit root path of rails application. value stored in instance variable @temperature retrieved api , displayed user when page refreshed.

how can put ruby regular expression 'temperature: \d' spec below?

spec:

require "rails_helper" feature "user sees temperature"   scenario "success"     visit root_path     expect(page).to have_css 'p', text: 'temperature: \d'   end end 

view:

<p>temperature: <%= @temperature %></p> 

this right, have use regex syntax (//) instead of string 1 (''):

expect(page).to have_css('p', text: /temperature: \d/) 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -