Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一些看起来像这样的 Ruby 代码:
Something.create do |x| x.foo = bar end
我想编写一个使用 double 代替块参数 x 的测试,这样我就可以调用:
x_double.should_receive(:foo).with("whatever").
这可能吗?
specify 'something' do x = double x.should_receive(:foo=).with("whatever") Something.should_receive(:create).and_yield(x) # call the relevant method end