【发布时间】:2013-08-22 00:59:38
【问题描述】:
我很确定这是一个非常愚蠢的问题,但我是 Cucumber、Ruby 和 Rspec 的新手,我正在努力解决一些非常基本的问题。
我安装了 rspec gem,我想使用期望匹配器: 期望(实际).to eq(预期)
似乎我应该能够简单地要求 rspec/expectations 然后执行这些命令,但是它不起作用。
我错过了什么?
1.9.3-p448 :001 > require 'rspec'
=> true
1.9.3-p448 :002 > require 'rspec/expectations'
=> true
1.9.3-p448 :003 > expected = "this"
=> "this"
1.9.3-p448 :004 > actual = "this"
=> "this"
1.9.3-p448 :005 > expect(actual).to eq(expected)
NoMethodError: undefined method `expect' for main:Object
from (irb):5
from /Users/lpc/.rvm/rubies/ruby-1.9.3-p448/bin/irb:16:in `<main>'
奇怪的是“应该”可以正常工作。
1.9.3-p448 :006 > expected.should == actual
=> true
感谢您的帮助。
【问题讨论】:
标签: rspec