Sha256: 2145623196ca77ea7a7ecff1235660a2ace2b3f0a7ce8280c8e848e7033dfe37

Contents?: true

Size: 855 Bytes

Versions: 5

Compression:

Stored size: 855 Bytes

Contents

require 'spec_helper'

describe KwBooksController do
  describe 'GET index (having an optional parameter)' do
    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'

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
action_args-1.3.0 spec/controllers/kwargs_controller_spec.rb
action_args-1.2.1 spec/controllers/kwargs_controller_spec.rb
action_args-1.2.0 spec/controllers/kwargs_controller_spec.rb
action_args-1.1.1 spec/controllers/kwargs_controller_spec.rb
action_args-1.1.0 spec/controllers/kwargs_controller_spec.rb