Sha256: 26eeb6ef1df406593a0a2102a21a78dcd6a293f3bc40405005b3006d8ea4639d

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe KwKeyreqBooksController do
  describe 'GET index (having an optional parameter)' do
    context 'without giving any kw parameter (not even giving :required one)' do
      if ActionPack::VERSION::MAJOR >= 4
        it { expect { get :index }.to raise_error ActionController::BadRequest }
      else
        it { expect { get :index }.to raise_error ArgumentError }
      end
    end

    context 'without giving any kw parameter' do
      before { get :index, author_name: 'nari' }
      its(:response) { should be_success }
    end

    context 'with kw parameter defaults to non-nil value' do
      before { get :index, author_name: 'nari', page: 3 }
      subject { eval response.body }
      its([:author_name]) { should == 'nari' }
      its([:page]) { should == '3' }
      its([:q]) { should == nil }
    end

    context 'with kw parameter defaults to nil' do
      before { get :index, author_name: 'nari', q: 'Rails' }
      subject { eval response.body }
      its([:author_name]) { should == 'nari' }
      its([:page]) { should == '1' }
      its([:q]) { should == 'Rails' }
    end
  end
end if RUBY_VERSION >= '2.1'

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
action_args-1.5.4 spec/controllers/kwargs_keyreq_controller_spec.rb
action_args-1.5.3 spec/controllers/kwargs_keyreq_controller_spec.rb
action_args-1.5.2 spec/controllers/kwargs_keyreq_controller_spec.rb
action_args-1.5.1 spec/controllers/kwargs_keyreq_controller_spec.rb
action_args-1.4.0 spec/controllers/kwargs_keyreq_controller_spec.rb