我敢肯定这是一个令人难以置信的愚蠢问题,但我是Cucumber,Ruby和Rspec的新手,我正在为一些非常基础的事情而苦苦挣扎。在Rspec中使用期望匹配器
我安装了RSpec的宝石,我想用期望的匹配: 预期(实际)。为了EQ(预期)
好像我应该能够仅仅需要rspec的/期望,然后执行这些命令,但它不起作用。
我错过了什么?
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
感谢您的任何帮助。
'test = describe“basic rspec feasure”do it“should do my bidding”do expect(:a).to eq(: a)结束;如果测试通过,结束''test.run'将是真的 – ivanxuu