Sha256: be8863a7120242fe7f7a3c7663d4413ff66bae94c08693f77440cbb6baa005eb

Contents?: true

Size: 1.95 KB

Versions: 16

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) }
      it { instance.must_respond_to(:visible=) }
      it { 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

16 entries across 16 versions & 1 rubygems

Version Path
vedeu-0.6.19 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.18 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.17 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.16 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.15 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.14 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.13 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.12 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.11 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.10 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.9 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.8 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.7 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.6 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.5 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.4 test/lib/vedeu/models/toggleable_test.rb