Permalink
Browse files

fix RuboCop offenses

  • Loading branch information...
1 parent 6ae1cf4 commit a56f8b170b9d372dcb342ab732677ad00da2b8d7 @e2 e2 committed Aug 1, 2016
View
@@ -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
View
@@ -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|
@@ -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
@@ -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'
@@ -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)
@@ -1,5 +1,5 @@
module Guard
module LiveReloadVersion
- VERSION = '2.5.1'
+ VERSION = '2.5.1'.freeze
end
end
@@ -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
@@ -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)
@@ -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
@@ -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
@@ -63,7 +63,6 @@
end.to change { reactor.connections_count }.from(0).to 1
end
end
-
end
def new_live_reactor(options = {})
@@ -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)
@@ -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)
@@ -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
@@ -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
View
@@ -5,7 +5,6 @@
require 'guard/livereload'
RSpec.configure do |config|
-
def ci?
ENV['CI'] == 'true'
end

0 comments on commit a56f8b1

Please sign in to comment.