Sha256: 1d59d620011c81347b24d811d5a87190f5afc9a47d25b3eba5110c7c382ac385
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
# frozen_string_literal: true RSpec.describe Fear::Extractor::ValueMatcher, "Symbol" do let(:parser) { Fear::Extractor::GrammarParser.new } let(:matcher) { parser.parse(pattern).to_matcher } describe "#defined_at?" do subject { matcher } context "no quotas" do let(:pattern) { ":foo" } it { is_expected.to be_defined_at(:foo) } it { is_expected.not_to be_defined_at("foo") } it { is_expected.not_to be_defined_at(:boo) } it { is_expected.not_to be_defined_at(2) } end context "double quotas" do let(:pattern) { %(:"foo") } it { is_expected.to be_defined_at(:foo) } it { is_expected.not_to be_defined_at("foo") } it { is_expected.not_to be_defined_at(:boo) } it { is_expected.not_to be_defined_at(2) } end context "single quotas" do let(:pattern) { %(:'foo') } it { is_expected.to be_defined_at(:foo) } it { is_expected.not_to be_defined_at("foo") } it { is_expected.not_to be_defined_at(:boo) } it { is_expected.not_to be_defined_at(2) } end end describe "#call" do subject { matcher.(other) } let(:pattern) { ":foo" } context "defined" do let(:other) { :foo } it { is_expected.to eq({}) } end end describe "#failure_reason" do subject { matcher.failure_reason(other) } context "match" do let(:other) { :foo } let(:pattern) { ":foo" } it { is_expected.to eq(Fear.none) } end context "does not match" do let(:other) { :bar } let(:pattern) { ":foo" } it { is_expected.to eq(Fear.some(<<~ERROR.strip)) } Expected `:bar` to match: :foo ^ ERROR end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fear-1.2.0 | spec/fear/extractor/value_matcher_symbol_spec.rb |
fear-1.1.0 | spec/fear/extractor/value_matcher_symbol_spec.rb |