Skip to content

Instantly share code, notes, and snippets.

@swarut
Created September 24, 2012 08:58
Show Gist options
  • Save swarut/3775015 to your computer and use it in GitHub Desktop.
Save swarut/3775015 to your computer and use it in GitHub Desktop.
Ruby : Stub pattern for injecting statement to where() method #ruby #test #stub
before do
User.stub(:where) do |like_query, bind_param|
case bind_param
when 'Bob%' then [bob]
when 'Jane%' then [jane]
else []
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment