Created
October 20, 2011 10:26
-
-
Save moretea/1300840 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # Use this to stub sphinx like this: | |
| # Product.stub(:search).and_return(MockSphinx::ProductStubber.new(products)) | |
| module MockSphinx | |
| class ProductStubber | |
| def initialize products | |
| @products = products | |
| end | |
| # Swallow all following scope calls | |
| def method_missing name, *args, &block | |
| self | |
| end | |
| # Gets called by rails | |
| def map | |
| @products.map{ |p| yield p} | |
| end | |
| # Return everything in one page | |
| def total_pages | |
| 1 | |
| end | |
| def count | |
| @products.length | |
| end | |
| alias :length :count | |
| # No, we're not empty :) | |
| def empty? | |
| false | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment