Sha256: a858e1308f26e301e8996d531460902266f92daf3fc5bfd773dc45b946984042
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
# encoding: utf-8 # # This file is part of the brauser gem. Copyright (C) 2013 and above Shogun <shogun_panda@cowtech.it>. # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php. # require "spec_helper" describe Brauser::Definition do let(:definition) { ::Brauser::Definition.new(:tag, "Label", "ABC", /(abc)+/) } describe "#initialize" do it "should assign attributes" do other = ::Brauser::Definition.new("A", "B", "C", "D") expect(other.tag).to eq("A") expect(other.label).to eq("B") expect(other.primary).to eq("C") expect(other.secondary).to eq("D") end end describe "#match" do it "should apply the correct matcher and return the correct value" do expect(definition.match(:primary, nil, "ABC")).to eq("ABC") expect(definition.match(:primary, nil, "CDE")).to be_nil expect(definition.match(:secondary, nil, "abcabc")).to be_a(MatchData) expect(definition.match(:secondary, nil, "abx")).to be_nil end it "should support a block matcher" do definition.primary = Proc.new { |definition, a, b, c| a + b + c } expect(definition.match(:primary, nil, 1, 2, 3)).to eq(6) end it "should return nil when the matcher is not valid" do expect(definition.match(:tertiary)).to be_nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
brauser-3.2.1 | spec/brauser/definition_spec.rb |