Sha256: e1bbdc533ca109e40347886792fba13cedcc5267f2934cbdc3060ca37b7cacab

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'
require 'support/test_classes'

describe Mutator::Helpers do
  subject { Mutator::Helpers }

  describe '.included' do
    let(:base) { Stateholder }

    it 'should not error' do
      expect { subject.included(base) }.to_not raise_error
    end
  end

  context 'when included' do
    subject { Stateholder.new }

    describe '#machine' do
      it 'should respond to it' do
        expect(subject).to respond_to :machine
      end

      it 'should return a Mutator::Stateholder object' do
        expect(subject.machine).to be_a Mutator::Stateholder
      end
    end

    [:initial_state, :second_state, :third_state].each do |state|
      describe ".#{state}" do
        it 'should respond to the method' do
          expect(subject.class).to respond_to state
        end

        it 'should call where on the stateholder' do
          expect(subject.class).to receive(:where).
                                    with(state: state).
                                    and_return(Stateholder.new)
          subject.class.public_send(state)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mutator-0.2.0 spec/lib/mutator/helpers_spec.rb
mutator-0.1.0 spec/lib/mutator/helpers_spec.rb