Sha256: 1f7c42c849d22effb7276bdeac9c7156625ac516a4cb94cb1a13b72a906e5db8

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe Dashing::WidgetsController do

  let(:redis) { double }

  before do
    stub_redis(redis)
    @routes = Dashing::Engine.routes
  end

  describe 'GET "show"' do

    def action(params = {})
      get :show, params
    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
    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.5.0 spec/controllers/dashing/widgets_controller_spec.rb
dashing-rails-2.4.5 spec/controllers/dashing/widgets_controller_spec.rb
dashing-rails-2.4.4 spec/controllers/dashing/widgets_controller_spec.rb
dashing-rails-2.4.3 spec/controllers/dashing/widgets_controller_spec.rb
dashing-rails-2.4.2 spec/controllers/dashing/widgets_controller_spec.rb