Created
September 24, 2012 08:58
-
-
Save swarut/3775015 to your computer and use it in GitHub Desktop.
Ruby : Stub pattern for injecting statement to where() method #ruby #test #stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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