我敢肯定這是一個令人難以置信的愚蠢問題,但我是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