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