Sha256: b39fb6b88374115d0f2508b161ca08fcc8c2468188dcc9065087f92fff387ece

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'
require_relative 'spec_helper_mocha'
require 'kaminari_rspec'
include KaminariRspec::TestHelpers

describe 'KaminariRspec::TestHelpers::' do

  describe 'discover_mock_framework' do

    context 'when the mock framework is mocha' do

      it 'should return mocha' do
        discover_mock_framework.should == :mocha
      end

    end

  end


  describe 'stub_pagination' do

    context 'when passed a nil resource' do

      it 'returns nil' do
        result = stub_pagination(nil)
        result.should be_nil
      end

    end

    context 'when passed a non nil resource' do

      # we check for total_count, to know if the stubbing was successful, no need to check for each
      # method individually
      it 'has the total_count method stubbed' do
        resource = Object.new
        result = stub_pagination(resource, :mock => :mocha, :total_count => 23)
        result.total_count.should == 23
      end

      context 'and an unknown mocking framework' do

        it 'raises an error' do
          resource = Object.new
          expect { stub_pagination(resource, :mock => :my_mock)}.to raise_error(ArgumentError)

        end

      end

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kaminari-rspec-0.16.1 spec/lib/kaminari_rspec/mocha/test_helpers_spec.rb
kaminari-rspec-0.14.1 spec/lib/kaminari_rspec/mocha/test_helpers_spec.rb
kaminari-rspec-0.14.1.b1 spec/lib/kaminari_rspec/mocha/test_helpers_spec.rb
kaminari-rspec-0.14.1.b0 spec/lib/kaminari_rspec/mocha/test_helpers_spec.rb