ruby on rails - Compare string to regex in rspec?` -


i doing

expect(@link.url_address == 'abc').to be_true 

but url_address might have other text after abc trying

expect(@link.url_address =~ 'abc').to be_true 

but getting

failure/error: expect(@link.url_address =~ /abc/).to be_true    expected  respond `true?` 

i tried

expect(@link.url_address).to =~ /abc/ 

but get

 failure/error: expect(@link.url_address).to =~ /abc/  argumenterror:    expect syntax not support operator matchers, must pass matcher `#to`. 

try this:

expect(@link.url_address).to match(/abc/) 

source: https://github.com/rspec/rspec-expectations#regular-expressions


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -