Skip to content

Commit

Permalink
Replace "offence" with "offense"
Browse files Browse the repository at this point in the history
  • Loading branch information
yujinakayama committed Feb 11, 2014
1 parent 2900726 commit 9d4381f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ notification: :failed # Display Growl notification after each run.
## Advanced Tips

If you're using a testing Guard plugin such as [`guard-rspec`](https://github.com/guard/guard-rspec) together with `guard-rubocop` in the TDD way (the red-green-refactor cycle),
you might be uncomfortable with the offence reports from RuboCop in the red-green phase:
you might be uncomfortable with the offense reports from RuboCop in the red-green phase:

* In the red-green phase, you're not necessarily required to write clean code – you just focus writing code to pass the test. It means, in this phase, `guard-rspec` should be run but `guard-rubocop` should not.
* In the refactor phase, you're required to make the code clean while keeping the test passing. In this phase, both `guard-rspec` and `guard-rubocop` should be run.
Expand Down
4 changes: 2 additions & 2 deletions lib/guard/rubocop/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ def summary_text
text = pluralize(summary[:inspected_file_count], 'file')
text << ' inspected, '

text << pluralize(summary[:offence_count], 'offence', no_for_zero: true)
text << pluralize(summary[:offense_count], 'offense', no_for_zero: true)
text << ' detected'
end

def failed_paths
failed_files = result[:files].reject do |file|
file[:offences].empty?
file[:offenses].empty?
end
failed_files.map do |file|
file[:path]
Expand Down
42 changes: 21 additions & 21 deletions spec/guard/rubocop/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@
},
"files": [{
"path": "lib/foo.rb",
"offences": []
"offenses": []
}, {
"path": "lib/bar.rb",
"offences": [{
"offenses": [{
"severity": "convention",
"message": "Line is too long. [81/79]",
"cop_name": "LineLength",
Expand All @@ -289,7 +289,7 @@
}
],
"summary": {
"offence_count": 2,
"offense_count": 2,
"target_file_count": 2,
"inspected_file_count": 2
}
Expand All @@ -301,7 +301,7 @@

describe '#result', :json_file do
it 'parses JSON file' do
expect(runner.result[:summary][:offence_count]).to eq(2)
expect(runner.result[:summary][:offense_count]).to eq(2)
end
end

Expand All @@ -310,7 +310,7 @@
allow(runner).to receive(:result).and_return(
{
summary: {
offence_count: 4,
offense_count: 4,
target_file_count: 3,
inspected_file_count: 2
}
Expand All @@ -320,7 +320,7 @@

it 'notifies summary' do
expect(Guard::Notifier).to receive(:notify) do |message, options|
expect(message).to eq('2 files inspected, 4 offences detected')
expect(message).to eq('2 files inspected, 4 offenses detected')
end
runner.notify(true)
end
Expand Down Expand Up @@ -356,7 +356,7 @@
allow(runner).to receive(:result).and_return(
{
summary: {
offence_count: offence_count,
offense_count: offense_count,
target_file_count: target_file_count,
inspected_file_count: inspected_file_count
}
Expand All @@ -366,7 +366,7 @@

subject(:summary_text) { runner.summary_text }

let(:offence_count) { 0 }
let(:offense_count) { 0 }
let(:target_file_count) { 0 }
let(:inspected_file_count) { 0 }

Expand All @@ -391,30 +391,30 @@
end
end

context 'when no offences are detected' do
let(:offence_count) { 0 }
it 'includes "no offences"' do
expect(summary_text).to include 'no offences'
context 'when no offenses are detected' do
let(:offense_count) { 0 }
it 'includes "no offenses"' do
expect(summary_text).to include 'no offenses'
end
end

context 'when an offence is detected' do
let(:offence_count) { 1 }
it 'includes "1 offence"' do
expect(summary_text).to include '1 offence'
context 'when an offense is detected' do
let(:offense_count) { 1 }
it 'includes "1 offense"' do
expect(summary_text).to include '1 offense'
end
end

context 'when 2 offences are detected' do
let(:offence_count) { 2 }
it 'includes "2 offences"' do
expect(summary_text).to include '2 offences'
context 'when 2 offenses are detected' do
let(:offense_count) { 2 }
it 'includes "2 offenses"' do
expect(summary_text).to include '2 offenses'
end
end
end

describe '#failed_paths', :json_file do
it 'returns file paths which have offences' do
it 'returns file paths which have offenses' do
expect(runner.failed_paths).to eq(['lib/bar.rb'])
end
end
Expand Down

0 comments on commit 9d4381f

Please # to comment.