Sha256: ae9dc32b77a03d96699232714c0a59706d3e14ac59c927fea739f87275d5ae33

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'
require 'parslet/rig/rspec'

module MARC::Spec
  module Parsing
    describe ClosedLcAlphaRange do
      attr_reader :range

      before(:each) do
        @range = ClosedLcAlphaRange.new
      end

      it 'parses a valid range' do
        valid_ranges = %w[
          a-b
          c-d
          e-f
          g-z
        ]
        aggregate_failures 'valid ranges' do
          valid_ranges.each do |r|
            expect(range).to parse(r)
          end
        end
      end

      it 'does not parse an invalid range' do
        invalid_ranges = %w[
          z-a
          b-a
          d-c
          x-f
        ]
        aggregate_failures 'invalid ranges' do
          invalid_ranges.each do |r|
            expect(range).not_to parse(r)
          end
        end
      end

      describe :to_s do
        it 'accepts a precedece argument' do
          prec = Parslet::Atoms::Precedence::OUTER
          expect(range.to_s(prec)).to eq('ClosedLcAlphaRange')
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-marc-spec-0.1.3 spec/marc/spec/parsing/closed_lc_alpha_range_spec.rb
ruby-marc-spec-0.1.2 spec/marc/spec/parsing/closed_lc_alpha_range_spec.rb
ruby-marc-spec-0.1.1 spec/marc/spec/parsing/closed_lc_alpha_range_spec.rb
ruby-marc-spec-0.1.0 spec/marc/spec/parsing/closed_lc_alpha_range_spec.rb