Sha256: 0364f4bd7c2d15240a8871c1c5a2c3470071a4cdff238b15e02ef38ba4310853

Contents?: true

Size: 1.8 KB

Versions: 20

Compression:

Stored size: 1.8 KB

Contents

require 'test_helper'

module Vedeu

  module Colours

  describe Repository do

      let(:described) { Vedeu::Colours::Repository }
      let(:instance)  { described.new }
      let(:storage)   { {} }

      describe '#initialize' do
        it { instance.must_be_instance_of(described) }
        it { instance.instance_variable_get('@storage').must_equal(storage) }
      end

      describe 'accessors' do
        it { instance.must_respond_to(:storage) }
      end

      describe '#register' do
        let(:colour)          { 'ff0000' }
        let(:escape_sequence) { 'fake_escape_sequence' }

        subject { instance.register(colour, escape_sequence) }

        it { subject.must_equal('fake_escape_sequence') }
      end

      describe '#registered?' do
        let(:colour) {}

        subject { instance.registered?(colour) }

        context 'when the colour is registered' do
          let(:colour) { '#aa0000' }

          before { instance.register(colour, 'fake_escape_sequence') }

          it { subject.must_equal(true) }
        end

        context 'when the colour is not registered' do
          it { subject.must_equal(false) }
        end
      end

      describe '#reset!' do
        subject { instance.reset! }

        it { subject.must_be_instance_of(Hash) }

        it { subject.must_equal({}) }
      end

      describe '#retrieve' do
        let(:colour) {}

        subject { instance.retrieve(colour) }

        context 'when the colour can be found' do
          let(:colour) { '#bb0000' }

          before { instance.register(colour, 'fake_escape_sequence') }

          it { subject.must_equal('fake_escape_sequence') }
        end

        context 'when the colour cannot be found' do
          it { subject.must_equal('') }
        end
      end

    end # Repository

  end # Colours

end # Vedeu

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
vedeu-0.7.4 test/lib/vedeu/colours/repository_test.rb
vedeu-0.7.3 test/lib/vedeu/colours/repository_test.rb
vedeu-0.7.2 test/lib/vedeu/colours/repository_test.rb
vedeu-0.7.1 test/lib/vedeu/colours/repository_test.rb
vedeu-0.7.0 test/lib/vedeu/colours/repository_test.rb
vedeu-0.6.71 test/lib/vedeu/colours/repository_test.rb
vedeu-0.6.70 test/lib/vedeu/colours/repository_test.rb
vedeu-0.6.69 test/lib/vedeu/colours/repository_test.rb
vedeu-0.6.68 test/lib/vedeu/colours/repository_test.rb
vedeu-0.6.67 test/lib/vedeu/colours/repository_test.rb
vedeu-0.6.66 test/lib/vedeu/colours/repository_test.rb
vedeu-0.6.65 test/lib/vedeu/colours/repository_test.rb
vedeu-0.6.64 test/lib/vedeu/colours/repository_test.rb
vedeu-0.6.63 test/lib/vedeu/colours/repository_test.rb
vedeu-0.6.62 test/lib/vedeu/colours/repository_test.rb
vedeu-0.6.61 test/lib/vedeu/colours/repository_test.rb
vedeu-0.6.60 test/lib/vedeu/colours/repository_test.rb
vedeu-0.6.59 test/lib/vedeu/colours/repository_test.rb
vedeu-0.6.58 test/lib/vedeu/colours/repository_test.rb
vedeu-0.6.57 test/lib/vedeu/colours/repository_test.rb