Sha256: 7f1baa09115d8eddddde70734d0fb187d42fd35d01a325bbbe818f6d53f62dcc

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

require_relative '../spec_helper'
require 'tailor/composite_observable'


class Tester
  include Tailor::CompositeObservable
end

describe Tailor::CompositeObservable do
  subject { Tester.new }

  describe ".define_observer" do
    context "observer = 'pants'" do
      before { Tailor::CompositeObservable.define_observer 'pants' }

      context "observer responds to #pants_update" do
        it "defines an instance method 'add_pants_observer' that takes 1 arg" do
          observer = double "Observer", respond_to?: true
          subject.add_pants_observer(observer)
        end
      end

      context "observer does not respond to #pants_update" do
        it "defines an instance method 'add_pants_observer' that takes 1 arg" do
          observer = double "Observer", respond_to?: false
          expect { subject.add_pants_observer(observer) }.
            to raise_error NoMethodError
        end
      end

      it "defines an instance method #notify_pants_observers" do
        expect { subject.notify_pants_observers }.
          to_not raise_error
      end

      it "defines an instance method #pants_changed" do
        expect { subject.pants_changed }.to_not raise_error
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tailor-1.0.1 spec/tailor/composite_observable_spec.rb
tailor-1.0.0 spec/tailor/composite_observable_spec.rb