Sha256: 19f0b8d2158b61e0d221f5c5a2b7d650d2656b3f38440fa2416d51686845062c

Contents?: true

Size: 802 Bytes

Versions: 36

Compression:

Stored size: 802 Bytes

Contents

require 'spec_helper'

RSpec.describe('passing options to parse') do
  it 'raises if if parsing from a Regexp and options are passed' do
    expect { RP.parse(/a+/, options: ::Regexp::EXTENDED) }.to raise_error(
      ArgumentError,
      'options cannot be supplied unless parsing a String'
    )
  end

  it 'sets options if parsing from a String' do
    root = RP.parse('a+', options: ::Regexp::MULTILINE | ::Regexp::EXTENDED)

    expect(root.options).to eq(m: true, x: true)
  end

  it 'allows options to not be supplied when parsing from a Regexp' do
    root = RP.parse(/a+/ix)

    expect(root.options).to eq(i: true, x: true)
  end

  it 'has an empty option-hash when parsing from a String and passing no options' do
    root = RP.parse('a+')

    expect(root.options).to be_empty
  end
end

Version data entries

36 entries across 26 versions & 7 rubygems

Version Path
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/regexp_parser-2.1.1/spec/parser/options_spec.rb
cocRb-0.1.0 .bundle/ruby/3.0.0/gems/regexp_parser-2.1.1/spec/parser/options_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/regexp_parser-1.8.2/spec/parser/options_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/regexp_parser-2.0.3/spec/parser/options_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/regexp_parser-1.8.2/spec/parser/options_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/2.7.0/gems/regexp_parser-2.1.1/spec/parser/options_spec.rb
regexp_parser-2.1.1 spec/parser/options_spec.rb
regexp_parser-2.1.0 spec/parser/options_spec.rb
regexp_parser-2.0.3 spec/parser/options_spec.rb
regexp_parser-2.0.2 spec/parser/options_spec.rb
regexp_parser-2.0.1 spec/parser/options_spec.rb
tdiary-5.1.4 vendor/bundle/ruby/2.7.0/gems/regexp_parser-1.8.2/spec/parser/options_spec.rb
regexp_parser-2.0.0 spec/parser/options_spec.rb
regexp_parser-1.8.2 spec/parser/options_spec.rb
regexp_parser-1.8.1 spec/parser/options_spec.rb
regexp_parser-1.8.0 spec/parser/options_spec.rb