Sha256: 8e82e689ab9bc5472d6f6bbe8c322e9e0f910752ffd39cab46a0d1c7e4f785fa

Contents?: true

Size: 1.68 KB

Versions: 3

Compression:

Stored size: 1.68 KB

Contents

require 'spec_helper'

describe Controll::Event do
  let(:clazz) { Controll::Event }

  describe '.initialize name, *args' do
    context 'implicit notice' do
      subject { Controll::Event.new 'sign_in' }  

      its(:name)    { should == :sign_in }
      its(:type)    { should == :notice }
      its(:options) { should be_blank }
    end

    context 'explicit notice' do
      subject { Controll::Event.new 'sign_in', :notice }  

      its(:name)    { should == :sign_in }
      its(:type)    { should == :notice }
      its(:options) { should be_blank }
    end

    context 'explicit error and options' do
      subject { Controll::Event.new 'sign_in', :error, {:a => 7} }  

      its(:name)    { should == :sign_in }
      its(:type)    { should == :error }
      its(:options) { should == {:a => 7} }
    end

    context 'explicit warning type in options' do
      subject { Controll::Event.new 'sign_in', {:type => :warning, :a => 7} }  

      its(:name)    { should == :sign_in }
      its(:type)    { should == :warning }
      its(:options) { should == {:a => 7} }

      describe '.warning?' do
        its(:warning?) { should be_true }
        its(:notice?) { should be_false }
      end
    end
  end

  context 'class methods' do
    subject { clazz }

    describe '.valid_types' do
      its(:valid_types) { should = %w{notice error warning success} }
    end

    describe '.valid_types=' do
      before do
        clazz.valid_types = [:notice]
      end
      its(:valid_types) { should = [:notice] }
    end

    describe '.add_valid_type' do
      before do
        clazz.add_valid_types :remote, :invalid
      end
      its(:valid_types) { should include(:remote, :invalid) }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
controll-0.3.2 spec/controll/event_spec.rb
controll-0.3.1 spec/controll/event_spec.rb
controll-0.3.0 spec/controll/event_spec.rb