Skip to content

Commit

Permalink
Style: Rubocop fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jfelchner committed Mar 26, 2015
1 parent 4532278 commit d80a25b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 32 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Expand Up @@ -6,6 +6,10 @@ inherit_from:
Style/IndentationWidth:
Enabled: false

Metrics/LineLength:
Exclude:
- 'spec/**/*.rb'

Style/EmptyLinesAroundBlockBody:
Exclude:
- 'spec/**/*.rb'
2 changes: 1 addition & 1 deletion Rakefile
@@ -1,2 +1,2 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
require 'bundler/gem_tasks'
43 changes: 23 additions & 20 deletions lib/fuubar.rb
Expand Up @@ -2,17 +2,17 @@
require 'rspec/core/formatters/base_text_formatter'
require 'ruby-progressbar'

RSpec.configuration.add_setting :fuubar_progress_bar_options, :default => {}
RSpec.configuration.add_setting :fuubar_progress_bar_options, default: {}

class Fuubar < RSpec::Core::Formatters::BaseTextFormatter
DEFAULT_PROGRESS_BAR_OPTIONS = { :format => ' %c/%C |%w>%i| %e ' }
DEFAULT_PROGRESS_BAR_OPTIONS = { format: ' %c/%C |%w>%i| %e ' }

RSpec::Core::Formatters.register self, :start,
:message,
:example_passed,
:example_pending,
:example_failed,
:dump_failures
:message,
:example_passed,
:example_pending,
:example_failed,
:dump_failures

attr_accessor :progress,
:passed_count,
Expand All @@ -22,20 +22,21 @@ class Fuubar < RSpec::Core::Formatters::BaseTextFormatter
def initialize(*args)
super

self.progress = ProgressBar.create(DEFAULT_PROGRESS_BAR_OPTIONS.
merge(:throttle_rate => continuous_integration? ? 1.0 : nil).
merge(:total => 0,
:output => output,
:autostart => false))
self.progress = ProgressBar.create(
DEFAULT_PROGRESS_BAR_OPTIONS.
merge(throttle_rate: continuous_integration? ? 1.0 : nil).
merge(total: 0,
output: output,
autostart: false))
end

def start(notification)
progress_bar_options = DEFAULT_PROGRESS_BAR_OPTIONS.
merge(:throttle_rate => continuous_integration? ? 1.0 : nil).
merge(throttle_rate: continuous_integration? ? 1.0 : nil).
merge(configuration.fuubar_progress_bar_options).
merge(:total => notification.count,
:output => output,
:autostart => false)
merge(total: notification.count,
output: output,
autostart: false)

self.progress = ProgressBar.create(progress_bar_options)
self.passed_count = 0
Expand All @@ -47,13 +48,13 @@ def start(notification)
with_current_color { progress.start }
end

def example_passed(notification)
def example_passed(_notification)
self.passed_count += 1

increment
end

def example_pending(notification)
def example_pending(_notification)
self.pending_count += 1

increment
Expand All @@ -78,7 +79,7 @@ def message(notification)
end
end

def dump_failures(notification)
def dump_failures(_notification)
#
# We output each failure as it happens so we don't need to output them en
# masse at the end of the run.
Expand Down Expand Up @@ -120,6 +121,8 @@ def configuration
end

def continuous_integration?
@continuous_integration ||= !(ENV['CONTINUOUS_INTEGRATION'].nil? || ENV['CONTINUOUS_INTEGRATION'] == '' || ENV['CONTINUOUS_INTEGRATION'] == 'false')
@continuous_integration ||= !(ENV['CONTINUOUS_INTEGRATION'].nil? ||
ENV['CONTINUOUS_INTEGRATION'] == '' ||
ENV['CONTINUOUS_INTEGRATION'] == 'false')
end
end
22 changes: 11 additions & 11 deletions spec/fuubar_spec.rb
Expand Up @@ -49,8 +49,8 @@

before(:each) do
RSpec.configuration.fuubar_progress_bar_options = {
:length => 40,
:throttle_rate => 0.0,
length: 40,
throttle_rate: 0.0,
}

ENV.delete('CONTINUOUS_INTEGRATION')
Expand Down Expand Up @@ -84,7 +84,7 @@

context 'and continuous integration is enabled' do
before do
RSpec.configuration.fuubar_progress_bar_options = {:length => 40}
RSpec.configuration.fuubar_progress_bar_options = { length: 40 }
ENV['CONTINUOUS_INTEGRATION'] = 'true'
end

Expand All @@ -99,8 +99,8 @@
before do
formatter.start(start_notification)

throttle = formatter.progress.instance_variable_get(:@throttle)
throttle_rate = throttle.instance_variable_set(:@period, 0.0)
throttle = formatter.progress.instance_variable_get(:@throttle)
_throttle_rate = throttle.instance_variable_set(:@period, 0.0)

output.rewind

Expand All @@ -115,7 +115,7 @@

context 'and continuous integration is not enabled' do
before do
RSpec.configuration.fuubar_progress_bar_options = {:length => 40}
RSpec.configuration.fuubar_progress_bar_options = { length: 40 }
ENV['CONTINUOUS_INTEGRATION'] = 'false'
end

Expand All @@ -130,8 +130,8 @@
before do
formatter.start(start_notification)

throttle = formatter.progress.instance_variable_get(:@throttle)
throttle_rate = throttle.instance_variable_set(:@period, 0.0)
throttle = formatter.progress.instance_variable_get(:@throttle)
_throttle_rate = throttle.instance_variable_set(:@period, 0.0)

output.rewind

Expand All @@ -149,9 +149,9 @@
before(:each) do
formatter
RSpec.configuration.fuubar_progress_bar_options = {
:length => 40,
:throttle_rate => 0.0,
:format => '%c',
length: 40,
throttle_rate: 0.0,
format: '%c',
}
end

Expand Down

0 comments on commit d80a25b

Please sign in to comment.