Sha256: 5b6a541015258bc2b03458384bdc27882322a2fdf0ee010d20cf9673056197eb

Contents?: true

Size: 1.76 KB

Versions: 6

Compression:

Stored size: 1.76 KB

Contents

require_relative '../../spec_helper'

require_relative '../../../lib/lucid/sequence/sequence_group'

module Sequence
  describe SequenceGroup do

    let(:singleton) { SequenceGroup.instance() }

    context 'starting state' do
      it 'should be empty' do
        expect(singleton.sequence_steps).to be_empty
      end
    end
    
    context 'basic operation' do
      let(:example_steps) do
        example = <<-EXAMPLE
          Given the login page
          When  the username is "<username>"
          And   the password is "<password>"
          And   login is clicked
        EXAMPLE
      end

      it 'should accept the addition of a new sequence phrase' do
        phrase = '[enter credentials]'
        args = [phrase, example_steps, true]
        expect { singleton.add_sequence(*args) }.not_to raise_error
        expect(singleton).to have(1).sequence_steps
      end
      
      it 'should not accept the addition of an existing sequence phrase' do
        phrase = '[enter credentials]'
        args = [phrase, example_steps, true]
        msg = "A sequence with phrase '[enter credentials]' already exists."
        expect { singleton.add_sequence(*args) }.to raise_error(Sequence::DuplicateSequenceError, msg)
      end

      it 'should return the steps of a sequence phrase' do
        phrase = '[enter credentials]'
        input_values = [['username', 'jnyman'], ['password', 'thx1138']]
        generated = singleton.generate_steps(phrase, input_values)
        expected = <<-EXAMPLE
          Given the login page
          When  the username is "jnyman"
          And   the password is "thx1138"
          And   login is clicked
        EXAMPLE
        expect(generated).to eq(expected)
      end
    end
    
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lucid-0.4.1 spec/lucid/sequences/sequence_group_spec.rb
lucid-0.4.0 spec/lucid/sequences/sequence_group_spec.rb
lucid-0.3.3 spec/lucid/sequences/sequence_group_spec.rb
lucid-0.3.0 spec/lucid/sequences/sequence_group_spec.rb
lucid-0.2.1 spec/lucid/sequences/sequence_group_spec.rb
lucid-0.2.0 spec/lucid/sequences/sequence_group_spec.rb