Sha256: 8e79723642935be26a4cc71ce505da49c600c01b232d035b655b98b78545a0a9

Contents?: true

Size: 1010 Bytes

Versions: 7

Compression:

Stored size: 1010 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

module RailsBestPractices::Core
  describe Error do
    it 'returns error with filename, line number and message' do
      expect(
        described_class.new(
          filename: 'app/models/user.rb', line_number: '100', message: 'not good', type: 'BogusReview'
        ).to_s
      ).to eq('app/models/user.rb:100 - not good')
    end

    it 'returns short filename' do
      Runner.base_path = '../rails-bestpractices.com'
      expect(
        described_class.new(
          filename: '../rails-bestpractices.com/app/models/user.rb',
          line_number: '100',
          message: 'not good',
          type: 'BogusReview'
        ).short_filename
      ).to eq('app/models/user.rb')
    end

    it 'returns first line number' do
      expect(
        described_class.new(
          filename: 'app/models/user.rb', line_number: '50,70,100', message: 'not good', type: 'BogusReview'
        ).first_line_number
      ).to eq('50')
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rails_best_practices-1.23.2 spec/rails_best_practices/core/error_spec.rb
rails_best_practices-1.23.1 spec/rails_best_practices/core/error_spec.rb
rails_best_practices-1.23.0 spec/rails_best_practices/core/error_spec.rb
rails_best_practices-1.22.1 spec/rails_best_practices/core/error_spec.rb
rails_best_practices-1.22.0 spec/rails_best_practices/core/error_spec.rb
rails_best_practices-1.21.0 spec/rails_best_practices/core/error_spec.rb
rails_best_practices-1.20.1 spec/rails_best_practices/core/error_spec.rb