Sha256: b9ca221f3e048f26dc5d1cf34f91c55b3dcd2f8a53a65145b942f4950f85de4c

Contents?: true

Size: 939 Bytes

Versions: 3

Compression:

Stored size: 939 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Rubocop::Cop::Lint::Syntax do
  describe '.offences_from_diagnostic' do
    subject(:offence) { described_class.offence_from_diagnostic(diagnostic) }
    let(:diagnostic) { Parser::Diagnostic.new(level, message, location) }
    let(:level) { :warning }
    let(:message) { 'This is a message' }
    let(:location) { double('location').as_null_object }

    it 'returns an offence' do
      expect(offence).to be_a(Rubocop::Cop::Offence)
    end

    it "sets diagnostic's level to offence's severity" do
      expect(offence.severity).to eq(level)
    end

    it "sets diagnostic's message to offence's message" do
      expect(offence.message).to eq(message)
    end

    it "sets diagnostic's location to offence's location" do
      expect(offence.location).to eq(location)
    end

    it 'sets Sytanx as cop name' do
      expect(offence.cop_name).to eq('Syntax')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubocop-0.15.0 spec/rubocop/cop/lint/syntax_spec.rb
rubocop-0.14.1 spec/rubocop/cop/lint/syntax_spec.rb
rubocop-0.14.0 spec/rubocop/cop/lint/syntax_spec.rb