Sha256: b0af5405aa170b077f675cd5148ca99eb4c42448588544d4c454eb31f8256b74

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

require "spec_helper"

describe ApplicationController do
  controller do
    add_breadcrumb 'root', '/'
    add_breadcrumb 'nil', nil
    add_breadcrumb -> c { c.examples_url }, -> c { c.examples_path }

    def index
      add_breadcrumb 'examples', controller: 'examples', action: 'index', only_path: true
      add_breadcrumb 'example', example_path(123)
      render text: 'test'
    end
  end

  describe '#index' do
    subject do
      get :index
    end

    context '.add_breadcrumb' do
      it 'having breadcrumbs' do
        should be_success
        assigns(:breadcrumbs)[0][:name].should eq('root')
        assigns(:breadcrumbs)[0][:url].should eq('/')
      end

      it 'url has nil value' do
        should be_success
        assigns(:breadcrumbs)[1][:name].should eq('nil')
        assigns(:breadcrumbs)[1][:url].should be_nil
      end

      it 'execute lambda in controller instance context' do
        should be_success
        assigns(:breadcrumbs)[2][:name].should eq('http://test.host/examples')
        assigns(:breadcrumbs)[2][:url].should eq('/examples')
      end
    end

    context '#add_breadcrumb' do
      it 'url options' do
        should be_success
        assigns(:breadcrumbs)[3][:name].should eq('examples')
        assigns(:breadcrumbs)[3][:url].should eq('/examples')
      end

      it 'example_path' do
        should be_success
        assigns(:breadcrumbs)[4][:name].should eq('example')
        assigns(:breadcrumbs)[4][:url].should eq('/examples/123')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
breadcrumble-3.0.1 spec/controllers/application_controller_spec.rb