在Rspec中,测试实例是否能够调用方法x。
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)>'
我期望在Docking_spec.rb中实例化的对象@dockstat响应DockingStation.rb中定义的release_bike方法,但事实并非如此。
答案 0 :(得分:-1)
require_relative '../DockingStation'