Sha256: 28bb9e1c29fbbd5a338143a539523011f2db090f615a864679e69ff2f2320d9e

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe TrafficLight do
  let(:light) { TrafficLight.new }
  context 'Stop' do
    before(:each) do
      light.state = 'stop'
    end

    it 'should_use_stop_color' do
      assert_equal 'red', light.color
    end

    it 'should_pass_arguments_through' do
      assert_equal 'RED', light.color(:upcase!)
    end

    it 'should_pass_block_through' do
      color = light.color { |value| value.upcase! }
      assert_equal 'RED', color
    end

    it 'should_use_stop_capture_violations' do
      assert_equal true, light.capture_violations?
    end
  end

 context 'Proceed' do
    before(:each) do
      light.state = 'proceed'
    end

    it 'should_use_proceed_color' do
      assert_equal 'green', light.color
    end

    it 'should_use_proceed_capture_violations' do
      assert_equal false, light.capture_violations?
    end
  end

 context 'Caution' do
    before(:each) do
      light.state = 'caution'
    end

    it 'should_use_caution_color' do
      assert_equal 'yellow', light.color
    end

    it 'should_use_caution_capture_violations' do
      assert_equal true, light.capture_violations?
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
state_machines-0.0.2 spec/models/traffic_light_spec.rb
state_machines-0.0.1 spec/models/traffic_light_spec.rb