Sha256: 719beb3d1dce59ee67c9f0faccd4e8a042fb116a64362e7544e1470b353bb626
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
require 'device_map' RSpec.describe DeviceMap::Pattern do let(:priority) { 1 } let(:higher_priority) { priority + 1 } let(:keyword) { 'keyword' } let(:longer_keyword) { 'longer_keyword' } let(:device_id) { 'device_id' } it 'is comparable by keyword size' do pattern1 = described_class.new(keyword, device_id, priority) pattern2 = described_class.new(longer_keyword, device_id, priority) expect(pattern1).to be < pattern2 end it 'is comparable by priority' do pattern1 = described_class.new(keyword, device_id, higher_priority) pattern2 = described_class.new(longer_keyword, device_id, priority) expect(pattern1).to be > pattern2 end it 'can be equal to other pattern' do pattern1 = described_class.new(keyword, device_id, priority) pattern2 = described_class.new(keyword, device_id, priority) expect(pattern1).to eq pattern2 end describe '#matches?' do let(:pattern) do described_class.new(keyword, device_id, priority) end let(:other_keywords) { ['anything', 'else'] } it 'returns true if given keywords contain all pattern keywords' do given_keywords = other_keywords + pattern.keywords expect(pattern.matches?(given_keywords)).to eq true end it 'returns false if given keywords do not contain all pattern keywords' do expect(pattern.matches?(other_keywords)).to eq false end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
device_map-0.1.2 | spec/pattern_spec.rb |
device_map-0.1.1 | spec/pattern_spec.rb |
device_map-0.1.0 | spec/pattern_spec.rb |