Skip to content

Commit

Permalink
added spec for syntax error
Browse files Browse the repository at this point in the history
  • Loading branch information
europ committed Feb 21, 2018
1 parent 944fa1d commit 42f2d41
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions spec/pronto/rubocop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,46 @@ module Pronto
end
end

describe '#inspect' do
subject { rubocop.inspect(patches) }

let(:item_patch){ nil }
let(:item_line) { double(new_lineno: 1) }
let(:item_offense) { double(disabled?: false, cop_name: "Syntax", message: "message-text", status: :uncorrected, line: 9) }
let(:item_line_patch) { nil }
let(:item_delta_value) { nil }
let(:item_severity) { double(name: :error)}

before do
allow(rubocop).to receive(:patch ).and_return(patch)
allow(rubocop).to receive(:offences).and_return(array_of_offences)
allow(rubocop).to receive(:patches ).and_return(patch)

allow(item_patch).to receive(:added_lines).and_return(array_of_lines)

allow(item_line).to receive(:patch).and_return(line_patch)
allow(item_line).to receive(:commit_sha).and_return("123456789abcdefgh")
allow(line_patch).to receive(:delta).and_return(delta_value)
allow(item_delta_value).to receive(:new_file).and_return(file)
allow(item_offense).to receive(:severity).and_return(severity)
allow(item_severity).to receive(:name).and_return(:error)
end

context 'return offences' do
let(:patch) { item_patch }
let(:line_patch) { item_line_patch }
let(:delta_value) { item_delta_value }
let(:array_of_offences) { [ item_offense ] }
let(:array_of_lines) { [ item_line ] }
let(:file) { {:path => "file.rb"} }
let(:severity) { item_severity }

it 'syntax error offense' do
should == [[],Message.new("file.rb", patch.added_lines.last, :error, "message-text", nil, nil)]
end # it
end # context
end # describe

describe '#level' do
subject { rubocop.level(severity) }

Expand Down

0 comments on commit 42f2d41

Please sign in to comment.