[rspec-users] understanding rspec predicates

David Chelimsky dchelimsky at gmail.com
Mon Oct 10 22:05:02 EDT 2011


On Oct 10, 2011, at 8:17 PM, Patrick J. Collins wrote:

> I know I can do:
> 
> blah.should be_empty
> 
> or
> 
> blah.should have_key(:to_my_house)
> 
> ...
> 
> But, is there a way to do:
> 
> str = "lmaonade omg rotfcopter!"
> 
> str.should start_with("lmao")
> 
> Or is it just best to do:
> 
> str.starts_with?("lmao").should be_true

See

https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers/be-matchers

and

https://www.relishapp.com/rspec/rspec-expectations/docs/custom-matchers/define-matcher



More information about the rspec-users mailing list