Sha256: 50028f3106a8cbde91211a91c099c73d710e3789630ec334664651a3ea2c626a

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

describe Dashing::WidgetsController do

  let(:redis) { double }

  before do
    stub_redis(redis)
  end

  describe 'GET "show"' do

    def action(params = {})
      get :show, params.merge(use_route: :dashing)
    end

    context 'when default template exists' do

      it 'responds success' do
        action(name: 'text')
        expect(response).to be_success
      end

    end

    context 'when template exists in main app' do

      it 'responds success' do
        action(name: 'foo')
        expect(response).to be_success
      end

    end

    context 'when template does not exist' do

      it { expect { action }.to raise_error }
      it { expect { action(name: 'bar') }.to raise_error }

    end

  end

  describe 'PUT "update"' do

    def action(params = {})
      put :update, params.merge(use_route: :dashing)
    end

    context 'when valid' do

      before do
        expect(redis).to receive(:publish)
      end

      it 'responds success' do
        action(name: 'foo')
        expect(response).to be_success
      end

    end

    context 'when not valid' do

      it { expect { action }.to raise_error }

    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dashing-rails-2.4.1 spec/controllers/dashing/widgets_controller_spec.rb
dashing-rails-2.4.0 spec/controllers/dashing/widgets_controller_spec.rb
dashing-rails-2.3.2 spec/controllers/dashing/widgets_controller_spec.rb
dashing-rails-2.3.1 spec/controllers/dashing/widgets_controller_spec.rb
dashing-rails-2.3.0 spec/controllers/dashing/widgets_controller_spec.rb