PageRenderTime 27ms CodeModel.GetById 17ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/spec/rails_best_practices/core/error_spec.rb

http://github.com/flyerhzm/rails_best_practices
Ruby | 35 lines | 30 code | 4 blank | 1 comment | 0 complexity | 18cd1306c5f9d47b4e5369a6018d0365 MD5 | raw file
 1# frozen_string_literal: true
 2
 3require 'spec_helper'
 4
 5module RailsBestPractices::Core
 6  describe Error do
 7    it 'returns error with filename, line number and message' do
 8      expect(
 9        described_class.new(
10          filename: 'app/models/user.rb', line_number: '100', message: 'not good', type: 'BogusReview'
11        ).to_s
12      ).to eq('app/models/user.rb:100 - not good')
13    end
14
15    it 'returns short filename' do
16      Runner.base_path = '../rails-bestpractices.com'
17      expect(
18        described_class.new(
19          filename: '../rails-bestpractices.com/app/models/user.rb',
20          line_number: '100',
21          message: 'not good',
22          type: 'BogusReview'
23        ).short_filename
24      ).to eq('app/models/user.rb')
25    end
26
27    it 'returns first line number' do
28      expect(
29        described_class.new(
30          filename: 'app/models/user.rb', line_number: '50,70,100', message: 'not good', type: 'BogusReview'
31        ).first_line_number
32      ).to eq('50')
33    end
34  end
35end