Skip to content

Instantly share code, notes, and snippets.

@t-oginogin
Created May 21, 2014 11:13
Show Gist options
  • Select an option

  • Save t-oginogin/d4f8399f95a8ed21bec0 to your computer and use it in GitHub Desktop.

Select an option

Save t-oginogin/d4f8399f95a8ed21bec0 to your computer and use it in GitHub Desktop.
Railsでgetやpost経由のテスト時、スタブに渡された引数の値を確認する(MiniTest) ref: http://qiita.com/t_oginogin/items/431ced39fcdb77f0bb48
res = nil
mock = MiniTest::Mock.new
mock.expect(:call, nil) do |arg1|
res = arg1
end
Foo.stub(:foo, mock) do
get :test # 内部でFoo.fooを呼ぶ処理
do
assert_equal 'baz', res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment