spec/fear/extractor/pattern_spec.rb in fear-1.0.0 vs spec/fear/extractor/pattern_spec.rb in fear-1.1.0

- old
+ new

@@ -1,32 +1,34 @@ +# frozen_string_literal: true + RSpec.describe Fear::Extractor::Pattern do - describe '.new' do - context 'invalid syntax' do - subject { -> { described_class.new('[1, 2, 3') } } + describe ".new" do + context "invalid syntax" do + subject { -> { described_class.new("[1, 2, 3") } } - it 'shows where the error happens' do + it "shows where the error happens" do is_expected.to raise_error(Fear::PatternSyntaxError) { |error| lines = error.message.split("\n") - expect(lines[0]).to start_with('Expected one of') - .and(end_with('at line 1, column 9 (byte 9):')) + expect(lines[0]).to start_with("Expected one of") + .and(end_with("at line 1, column 9 (byte 9):")) - expect(lines[1]).to eq('[1, 2, 3') - expect(lines[2]).to eq('~~~~~~~~^') + expect(lines[1]).to eq("[1, 2, 3") + expect(lines[2]).to eq("~~~~~~~~^") } end end end - describe '#failure_reason' do - let(:pattern) { described_class.new('Some([:err, 444])') } + describe "#failure_reason" do + let(:pattern) { described_class.new("Some([:err, 444])") } - context 'not defined' do + context "not defined" do subject { pattern.failure_reason(Fear.some([:err, 445])) } - it { is_expected.to eq(<<-MSG.strip) } -Expected `445` to match: -Some([:err, 444]) -~~~~~~~~~~~~^ + it { is_expected.to eq(<<~MSG.strip) } + Expected `445` to match: + Some([:err, 444]) + ~~~~~~~~~~~~^ MSG end end end