0
在Rspec中,測試一個實例是否能夠調用方法x。方法定義的Rspec驗證 - 失敗/錯誤
DockingStation.rb
class DockingStation
def release_bike
end
end
Docking_spec.rb
require_relative '../lib/DockingStation'
describe DockingStation do
before(:each) do
@dockstat = DockingStation.new
end
describe "#DockingStation" do
it "Check release method" do
expect(@dockstat).to respond_to(:release_bike)
end
end
end
目前得到以下錯誤信息:
1) DockingStation#DockingStation Check release method
Failure/Error: expect(@dockstat).to respond_to(:release_bike)
expected #<DockingStation:0x007fa518a6da00> to respond to :release_bike
# ./spec/Docking_spec.rb:10:in `block (3 levels) in <top (required)>'
我很期待對於T他將Docking_spec.rb中的@dockstat實例化,以響應DockingStation.rb中定義的release_bike方法,但事實並非如此。
這對我有用 – Nathan
是的,我現在也工作,這是在require目錄內的一個問題 – Harry