Sha256: 8e1f17a7320882ebe04f25e6e9dd6d944b5b2cfb169d9d62e867be3a099f7169

Contents?: true

Size: 1.95 KB

Versions: 23

Compression:

Stored size: 1.95 KB

Contents

require 'test_helper'

module Vedeu

  class ToggleableTestClass
    include Vedeu::Toggleable

    def initialize(boolean)
      @visible = boolean
    end

    def store
      self
    end
  end

  describe Toggleable do

    let(:described) { Vedeu::Toggleable }
    let(:instance) { Vedeu::ToggleableTestClass.new(visible) }
    let(:visible) { false }

    describe 'accessors' do
      it {
        instance.must_respond_to(:visible)
        instance.must_respond_to(:visible=)
        instance.must_respond_to(:visible?)
      }
    end

    describe '#hide' do
      subject { instance.hide }

      it {
        subject
        instance.instance_variable_get('@visible').must_equal(false)
      }

      it { Vedeu::ToggleableTestClass.must_respond_to(:hide_cursor) }
      it { Vedeu::ToggleableTestClass.must_respond_to(:hide_group) }
      it { Vedeu::ToggleableTestClass.must_respond_to(:hide_interface) }
    end

    describe '#show' do
      subject { instance.show }

      it {
        subject
        instance.instance_variable_get('@visible').must_equal(true)
      }

      it { Vedeu::ToggleableTestClass.must_respond_to(:show_cursor) }
      it { Vedeu::ToggleableTestClass.must_respond_to(:show_group) }
      it { Vedeu::ToggleableTestClass.must_respond_to(:show_interface) }
    end

    describe '#toggle' do
      subject { instance.toggle }

      it { Vedeu::ToggleableTestClass.must_respond_to(:toggle_cursor) }
      it { Vedeu::ToggleableTestClass.must_respond_to(:toggle_group) }
      it { Vedeu::ToggleableTestClass.must_respond_to(:toggle_interface) }

      context 'when the model is visible' do
        let(:visible) { true }

        it {
          subject
          instance.instance_variable_get('@visible').must_equal(false)
        }
      end

      context 'when the model is not visible' do
        it {
          subject
          instance.instance_variable_get('@visible').must_equal(true)
        }
      end
    end

  end # Toggleable

end # Vedeu

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
vedeu-0.6.42 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.41 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.40 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.39 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.38 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.37 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.36 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.35 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.34 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.33 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.32 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.31 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.30 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.29 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.28 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.27 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.26 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.25 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.24 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.23 test/lib/vedeu/models/toggleable_test.rb