Skip to content

Commit

Permalink
fix RuboCop offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
e2 committed Aug 1, 2016
1 parent 6ae1cf4 commit a56f8b1
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
group :specs, halt_on_fail: true do
guard :rspec, cmd: 'bundle exec rspec', failed_mode: :keep, all_on_start: true do
watch(%r{spec/.+_spec.rb})
watch(%r{lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch(%r{lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { 'spec' }
watch('lib/guard/livereload/templates/Guardfile') { 'spec/lib/guard/livereload/template_spec.rb' }
end

guard :rubocop, all_on_start: false, cli: '--rails' do
watch(%r{.+\.rb$}) { |m| m[0] }
watch(/.+\.rb$/) { |m| m[0] }
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
watch(%r{(?:.+/)?\.rubocop_todo\.yml$}) { |m| File.dirname(m[0]) }
end
Expand Down
8 changes: 4 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require "bundler/gem_tasks"
require 'bundler/gem_tasks'

require "rspec/core/rake_task"
require 'rspec/core/rake_task'

def ci?
ENV["CI"] == "true"
ENV['CI'] == 'true'
end

RSpec::Core::RakeTask.new(:spec) do |t|
Expand All @@ -13,7 +13,7 @@ end
default_tasks = [:spec]

unless ci?
require "rubocop/rake_task"
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop)
default_tasks << :rubocop
end
Expand Down
2 changes: 1 addition & 1 deletion guard-livereload.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.homepage = 'https://rubygems.org/gems/guard-livereload'
s.license = 'MIT'

s.files = `git ls-files`.split($/)
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
s.test_files = s.files.grep(%r{^spec/})
s.require_path = 'lib'

Expand Down
4 changes: 2 additions & 2 deletions lib/guard/livereload/reactor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def _connect(ws)
)
@web_sockets << ws
rescue
Compat::UI.error $!
Compat::UI.error $!.backtrace
Compat::UI.error $ERROR_INFO
Compat::UI.error $ERROR_INFO.backtrace
end

def _disconnect(ws)
Expand Down
2 changes: 1 addition & 1 deletion lib/guard/livereload/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Guard
module LiveReloadVersion
VERSION = '2.5.1'
VERSION = '2.5.1'.freeze
end
end
2 changes: 1 addition & 1 deletion lib/guard/livereload/websocket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def dispatch(data)
path = payload
stream_file_data(path).callback { close_connection_after_writing }
else
fail "Unknown response type: #{type.inspect}"
raise "Unknown response type: #{type.inspect}"
end
end
end
Expand Down
11 changes: 5 additions & 6 deletions spec/lib/guard/livereload/reactor_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RSpec.describe Guard::LiveReload::Reactor do
let(:paths) { %w[stylesheets/layout.css stylesheets/style.css] }
let(:paths) { %w(stylesheets/layout.css stylesheets/style.css) }

before do
allow(Guard::Compat::UI).to receive(:info)
Expand All @@ -10,8 +10,8 @@

describe '#reload_browser(paths = [])' do
it 'displays a message' do
expect(Guard::Compat::UI).to receive(:info).
with('Reloading browser: stylesheets/layout.css stylesheets/style.css')
expect(Guard::Compat::UI).to receive(:info)
.with('Reloading browser: stylesheets/layout.css stylesheets/style.css')
new_live_reactor.reload_browser(paths)
end

Expand All @@ -21,8 +21,8 @@
end

it 'optionally pushes notification' do
expect(Guard::Compat::UI).to receive(:notify).
with(kind_of(String), have_key(:title))
expect(Guard::Compat::UI).to receive(:notify)
.with(kind_of(String), have_key(:title))
new_live_reactor(notify: true).reload_browser(paths)
end

Expand Down Expand Up @@ -63,7 +63,6 @@
end.to change { reactor.connections_count }.from(0).to 1
end
end

end

def new_live_reactor(options = {})
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/guard/livereload/snippet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

before do
allow(File).to receive(:expand_path) do |*args|
fail "stub called for File.expand_path(#{args.map(&:inspect) * ','})"
raise "stub called for File.expand_path(#{args.map(&:inspect) * ','})"
end

allow(IO).to receive(:read) do |*args|
fail "stub called for IO.read(#{args.map(&:inspect) * ','})"
raise "stub called for IO.read(#{args.map(&:inspect) * ','})"
end

allow(IO).to receive(:read).with(template).and_return(contents)
Expand Down
16 changes: 8 additions & 8 deletions spec/lib/guard/livereload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

before do
allow(File).to receive(:expand_path) do |*args|
fail "stub called for File.expand_path(#{args.map(&:inspect) * ','})"
raise "stub called for File.expand_path(#{args.map(&:inspect) * ','})"
end

allow(File).to receive(:expand_path).
with('../../../js/livereload.js.erb', anything).
and_return('/foo/js/livereload.js.erb')
allow(File).to receive(:expand_path)
.with('../../../js/livereload.js.erb', anything)
.and_return('/foo/js/livereload.js.erb')

allow(Guard::LiveReload::Snippet).to receive(:new).and_return(snippet)

Expand Down Expand Up @@ -93,8 +93,8 @@
end

it 'evalutes the default snippet' do
expect(Guard::LiveReload::Snippet).to receive(:new).
with('/foo/js/livereload.js.erb', anything).and_return(snippet)
expect(Guard::LiveReload::Snippet).to receive(:new)
.with('/foo/js/livereload.js.erb', anything).and_return(snippet)
subject
end
end
Expand All @@ -107,8 +107,8 @@
end

it 'evalutes the provided snippet' do
expect(Guard::LiveReload::Snippet).to receive(:new).
with('foo/bar.js.erb', anything).and_return(snippet)
expect(Guard::LiveReload::Snippet).to receive(:new)
.with('foo/bar.js.erb', anything).and_return(snippet)
subject
end
end
Expand Down
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
require 'guard/livereload'

RSpec.configure do |config|

def ci?
ENV['CI'] == 'true'
end
Expand Down

0 comments on commit a56f8b1

Please sign in to comment.