Sha256: 0b17e5b48d2e65939a8f63c02ee26c3aea9c16a2fb1376db97d721e0a8482459

Contents?: true

Size: 1.64 KB

Versions: 4

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

module ApiTaster
  describe RoutesController do
    context "missing ApiTaster.routes" do
      it "#index" do
        Route.stub(:mappings).and_return(nil)
        get :index, :use_route => :api_taster

        response.should be_success
        assigns(:routes).should be_kind_of(Hash)
      end
    end

    it "#index" do
      get :index, :use_route => :api_taster

      assigns(:routes).should be_kind_of(Hash)
    end

    it "#show" do
      Route.stub(:find).and_return(Route.new)
      Route.stub(:params_for).and_return([])
      Route.stub(:comment_for).and_return([])

      get :show, :id => 1, :use_route => :api_taster

      assigns(:route).should be_kind_of(Route)
      assigns(:params).should be_kind_of(Array)
      assigns(:comment).should be_kind_of(Array)
    end

    it "#missing_definitions" do
      get :missing_definitions, :use_route => :api_taster

      assigns(:missing_definitions).should be_kind_of(Array)
    end

    it "#obsolete_definitions" do
      get :obsolete_definitions, :use_route => :api_taster

      assigns(:obsolete_definitions).should be_kind_of(Array)
    end

    context 'layout' do
      context 'when request is not XHR' do
        it 'renders application layout' do
          get :index, :use_route => :api_taster

          response.should render_template('api_taster/application')
        end
      end

      context 'when request is XHR' do
        before { request.stub(:xhr?) { true } }

        it 'does not render layout' do
          get :index, :use_route => :api_taster

          response.should_not render_template('api_taster/application')
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
api_taster-0.8.4 spec/controllers/api_taster/routes_controller_spec.rb
api_taster-0.8.3 spec/controllers/api_taster/routes_controller_spec.rb
api_taster-0.8.2 spec/controllers/api_taster/routes_controller_spec.rb
api_taster-0.8.1 spec/controllers/api_taster/routes_controller_spec.rb