Created
September 30, 2008 12:54
-
-
Save zdennis/13804 to your computer and use it in GitHub Desktop.
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
require File.dirname(__FILE__) + '/../spec_helper' | |
class Foo | |
def self.per_page | |
10 | |
end | |
end | |
describe Foo do | |
should_have_per_page 10 | |
end |
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
Spec::Runner.configure do |config| | |
# ... other config stuff | |
config.include WillPaginateMacros | |
end |
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
module WillPaginateMacros | |
def self.included(klass) | |
klass.extend ClassMethods | |
end | |
module ClassMethods | |
def should_have_per_page(count) | |
klass = self.described_type | |
context "#{klass}" do | |
it "should respond to per_page" do | |
klass.should respond_to(:per_page) | |
end | |
it "should have #{count} per page" do | |
klass.per_page.should == count | |
end | |
end | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment