Sha256: 295144a3d9c89692d7c6ba049307af0ba0487b58e62ef7507d889ba5f1bf338d

Contents?: true

Size: 980 Bytes

Versions: 3

Compression:

Stored size: 980 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

module RailsBestPractices::Core
  describe Error do
    it 'should return error with filename, line number and message' do
      expect(Error.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 'should return short filename' do
      Runner.base_path = '../rails-bestpractices.com'
      expect(Error.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 'should return first line number' do
      expect(Error.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

3 entries across 3 versions & 1 rubygems

Version Path
rails_best_practices-1.20.0 spec/rails_best_practices/core/error_spec.rb
rails_best_practices-1.19.5 spec/rails_best_practices/core/error_spec.rb
rails_best_practices-1.19.4 spec/rails_best_practices/core/error_spec.rb