Sha256: 0cdbd65805ac31eed3a7acbf3a7291661be173ed905a2554989406644b0844dc
Contents?: true
Size: 1.37 KB
Versions: 6
Compression:
Stored size: 1.37 KB
Contents
require 'spec_helper' module EndState describe Guard do subject(:guard) { Guard.new(object, state, params) } let(:object) { OpenStruct.new(failure_messages: [], success_messages: []) } let(:state) { :a } let(:params) { {} } before do object.failure_messages = [] object.success_messages = [] end describe '#add_error' do it 'adds an error' do guard.add_error('error') expect(object.failure_messages).to eq ['error'] end end describe '#add_success' do it 'adds an success' do guard.add_success('success') expect(object.success_messages).to eq ['success'] end end describe 'will_allow?' do it 'returns false' do expect(guard.will_allow?).to be false end end describe 'allowed?' do context 'will_allow? returns true' do before { allow(guard).to receive(:will_allow?).and_return(true) } it 'calls passed and returns true' do expect(guard).to receive(:passed) expect(guard.allowed?).to be true end end context 'will_allow? returns false' do before { allow(guard).to receive(:will_allow?).and_return(false) } it 'calls failed and returns false' do expect(guard).to receive(:failed) expect(guard.allowed?).to be false end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems