Sha256: bb6ff71b7d179fdd76a3e1a678d1d06dc8fad6eab7e63fc8a907bab67f107b04

Contents?: true

Size: 1.32 KB

Versions: 30

Compression:

Stored size: 1.32 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)
      }
    end

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

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

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

      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

30 entries across 30 versions & 1 rubygems

Version Path
vedeu-0.6.3 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.2 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.1 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.6.0 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.5.13 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.5.12 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.5.11 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.5.10 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.5.9 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.5.8 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.5.7 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.5.6 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.5.5 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.5.4 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.5.3 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.5.2 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.5.1 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.5.0 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.4.65 test/lib/vedeu/models/toggleable_test.rb
vedeu-0.4.64 test/lib/vedeu/models/toggleable_test.rb