From 42f2d4183268d609b80f064882f59a53dce5aba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20T=C3=B3th?= Date: Tue, 20 Feb 2018 13:47:13 +0100 Subject: [PATCH] added spec for syntax error --- spec/pronto/rubocop_spec.rb | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/spec/pronto/rubocop_spec.rb b/spec/pronto/rubocop_spec.rb index 71a56cb..1367f3f 100644 --- a/spec/pronto/rubocop_spec.rb +++ b/spec/pronto/rubocop_spec.rb @@ -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) }