Sha256: 3deb13b05268d0a6fca8cae77921e91e04d1318570eed66b036cec36568330ad

Contents?: true

Size: 995 Bytes

Versions: 7

Compression:

Stored size: 995 Bytes

Contents

# frozen_string_literal: true
require 'test_helper'
require 'rubycritic/core/location'

describe RubyCritic::Location do
  describe 'attribute readers' do
    before do
      @path = './foo.rb'
      @line = '42'
      @location = RubyCritic::Location.new(@path, @line)
    end

    it 'has a pathname' do
      @location.pathname.must_equal Pathname.new(@path)
    end

    it 'has a line number' do
      @location.line.must_equal @line.to_i
    end

    it 'has a file name' do
      @location.file_name.must_equal 'foo'
    end
  end

  it 'is comparable' do
    location1 = RubyCritic::Location.new('./foo', 42)
    location2 = RubyCritic::Location.new('./foo', 42)
    location1.must_equal location2
  end

  it 'is sortable' do
    location1 = RubyCritic::Location.new('./foo', 42)
    location2 = RubyCritic::Location.new('./bar', 23)
    location3 = RubyCritic::Location.new('./bar', 16)
    [location1, location2, location3].sort.must_equal [location3, location2, location1]
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rubycritic-3.2.0 test/lib/rubycritic/core/location_test.rb
rubycritic-3.1.3 test/lib/rubycritic/core/location_test.rb
rubycritic-3.1.2 test/lib/rubycritic/core/location_test.rb
rubycritic-3.1.1 test/lib/rubycritic/core/location_test.rb
rubycritic-3.1.0 test/lib/rubycritic/core/location_test.rb
rubycritic-3.0.0 test/lib/rubycritic/core/location_test.rb
rubycritic-2.9.4 test/lib/rubycritic/core/location_test.rb