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
Post a Comment