我想做以下事情:
require 'rspec-expectations'
"bat".length.should eq(3)
# => NoMethodError: undefined method `eq' for main:Object
这样的事情可能吗?我怎么需要改变它?我需要'rspec-expectations'
吗?
答案 0 :(得分:2)
gem install interactive_rspec
然后
irspec
001> "bat".length.should eq(3)
.
Finished in 0.00006 seconds
1 example, 0 failures
=> true
答案 1 :(得分:1)
在irb:
require 'rspec-expectations'
include RSpec::Matchers
"bat".length.should eq(3)