timpone
timpone

Reputation: 19969

is a one-line test like this possible in rspec

I'd like to do something like the following:

require 'rspec-expectations'
"bat".length.should eq(3)
# => NoMethodError: undefined method `eq' for main:Object

Is something like this possible? How would I need to change it? Would I need to require 'rspec-expectations'?

Upvotes: 0

Views: 109

Answers (2)

Shawn Balestracci
Shawn Balestracci

Reputation: 7540

In irb:

require 'rspec-expectations'
include RSpec::Matchers

"bat".length.should eq(3)

Upvotes: 1

Patrick Oscity
Patrick Oscity

Reputation: 54704

Try interactive_rspec:

gem install interactive_rspec

then

irspec
001> "bat".length.should eq(3)
.

Finished in 0.00006 seconds
1 example, 0 failures
=> true

Upvotes: 2

Related Questions