Sha256: f7e2e1f6762c769fd559c7e204b2860de1c9f7f8204732c017f71ff5b5494419

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'test_helper'
require 'rubycritic/core/smell'

describe 'Array of Smells' do
  it 'is sortable' do
    location1 = RubyCritic::Location.new('./foo', 42)
    location2 = RubyCritic::Location.new('./bar', 23)
    location3 = RubyCritic::Location.new('./bar', 16)
    smell1 = RubyCritic::Smell.new(locations: [location1])
    smell2 = RubyCritic::Smell.new(locations: [location2])
    smell3 = RubyCritic::Smell.new(locations: [location3])
    [smell1, smell2, smell3].sort.must_equal [smell3, smell2, smell1]
  end

  it 'implements set intersection' do
    smell1 = RubyCritic::Smell.new(context: '#bar')
    smell2 = RubyCritic::Smell.new(context: '#bar')
    smell3 = RubyCritic::Smell.new(context: '#foo')
    ([smell1, smell3] & [smell2]).must_equal [smell1]
  end

  it 'implements set union' do
    smell1 = RubyCritic::Smell.new(context: '#bar')
    smell2 = RubyCritic::Smell.new(context: '#bar')
    smell3 = RubyCritic::Smell.new(context: '#foo')
    ([smell1, smell3] | [smell2]).must_equal [smell1, smell3]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubycritic-2.9.3 test/lib/rubycritic/core/smells_array_test.rb