Module: KaminariRspec::TestHelpers
- Defined in:
- lib/kaminari_rspec/test_helpers.rb
Instance Method Summary collapse
-
#stub_pagination(resource, options = {}) ⇒ Object
Stubs the paginations method on the resource passed.
Instance Method Details
#stub_pagination(resource, options = {}) ⇒ Object
Stubs the paginations method on the resource passed.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kaminari_rspec/test_helpers.rb', line 17 def stub_pagination(resource, ={}) return nil unless resource [:current_page] ||= 1 [:per_page] ||= 25 mock_framework = [:mock] || discover_mock_framework values = calculate_values(resource, ) wrapped_resource = wrap_resource(resource, ) case mock_framework when :rspec then stub_pagination_with_rspec(wrapped_resource, values) when :rr then stub_pagination_with_rr(wrapped_resource, values) when :mocha then stub_pagination_with_mocha(wrapped_resource, values) when :flexmock then stub_pagination_with_flexmock(wrapped_resource, values) when :nothing then resource else raise ArgumentError, "Invalid mock argument #{[:mock]} / framework not supported" end end |