Sha256: 92ae7c1d57b78199509662fefe0519242171ded24d1a094fc4dc63ba1e4423e9

Contents?: true

Size: 1.03 KB

Versions: 11

Compression:

Stored size: 1.03 KB

Contents

require "test_helper"
require "rubycritic/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

11 entries across 11 versions & 1 rubygems

Version Path
rubycritic-0.0.12 test/lib/rubycritic/smells_array_test.rb
rubycritic-0.0.11 test/lib/rubycritic/smells_array_test.rb
rubycritic-0.0.10 test/lib/rubycritic/smells_array_test.rb
rubycritic-0.0.9 test/lib/rubycritic/smells_array_test.rb
rubycritic-0.0.8 test/lib/rubycritic/smells_array_test.rb
rubycritic-0.0.7 test/lib/rubycritic/smells_array_test.rb
rubycritic-0.0.6 test/lib/rubycritic/smells_array_test.rb
rubycritic-0.0.5 test/lib/rubycritic/smells_array_test.rb
rubycritic-0.0.4 test/lib/rubycritic/smells_array_test.rb
rubycritic-0.0.3 test/lib/rubycritic/smells_array_test.rb
rubycritic-0.0.2 test/lib/rubycritic/smells_array_test.rb