Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby rspec使用参数和返回固定值的新语法存根方法_Ruby_Rspec_Rspec3 - Fatal编程技术网

Ruby rspec使用参数和返回固定值的新语法存根方法

Ruby rspec使用参数和返回固定值的新语法存根方法,ruby,rspec,rspec3,Ruby,Rspec,Rspec3,我想用参数1存根对象A以响应接下来的消息,并返回B字符串 我想用新的rspec语法A.allow编写A.stub:next.with1.and_returnB行。。。但是我找不到添加with part的位置这就是新语法的工作原理: allow(A).to receive(:next).with(1).and_return("B") allow(A).to receive(:next).with(1).and_return("B")

我想用参数1存根对象A以响应接下来的消息,并返回B字符串


我想用新的rspec语法A.allow编写A.stub:next.with1.and_returnB行。。。但是我找不到添加with part的位置这就是新语法的工作原理:

allow(A).to receive(:next).with(1).and_return("B")
allow(A).to receive(:next).with(1).and_return("B")