Sha256: 8fd0a75fd9ad9d85b21aded5c5cf752d204749d30402865d5eebe1e017c29da0

Contents?: true

Size: 1.04 KB

Versions: 21

Compression:

Stored size: 1.04 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

21 entries across 21 versions & 1 rubygems

Version Path
rubycritic-2.6.0 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-2.5.0 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-2.4.1 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-2.4.0 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-2.3.0 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-2.2.0 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-2.1.0 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-2.0.0 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-1.4.0 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-1.3.0 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-1.2.1 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-1.2.0 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-1.1.1 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-1.1.0 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-1.0.2 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-1.0.1 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-1.0.0 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-0.0.16 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-0.0.15 test/lib/rubycritic/core/smells_array_test.rb
rubycritic-0.0.14 test/lib/rubycritic/core/smells_array_test.rb