diff --git a/.rubocop.yml b/.rubocop.yml index 7bc3a8ed..9b43aef3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -25,8 +25,6 @@ Style/RegexpLiteral: Enabled: false Style/PercentLiteralDelimiters: Enabled: false -Style/BlockDelimiters: - Enabled: false Style/Lambda: Enabled: false Style/SingleLineBlockParams: diff --git a/lib/capistrano/application.rb b/lib/capistrano/application.rb index db187143..3958881a 100644 --- a/lib/capistrano/application.rb +++ b/lib/capistrano/application.rb @@ -104,46 +104,46 @@ module Capistrano def version ["--version", "-V", "Display the program version.", - lambda { |_value| + lambda do |_value| puts "Capistrano Version: #{Capistrano::VERSION} (Rake Version: #{Rake::VERSION})" exit - } + end ] end def dry_run ["--dry-run", "-n", "Do a dry run without executing actions", - lambda { |_value| + lambda do |_value| Configuration.env.set(:sshkit_backend, SSHKit::Backend::Printer) - } + end ] end def roles ["--roles ROLES", "-r", "Run SSH commands only on hosts matching these roles", - lambda { |value| + lambda do |value| Configuration.env.add_cmdline_filter(:role, value) - } + end ] end def hostfilter ["--hosts HOSTS", "-z", "Run SSH commands only on matching hosts", - lambda { |value| + lambda do |value| Configuration.env.add_cmdline_filter(:host, value) - } + end ] end def print_config_variables ["--print-config-variables", "-p", "Display the defined config variables before starting the deployment tasks.", - lambda { |_value| + lambda do |_value| Configuration.env.set(:print_config_variables, true) - } + end ] end end diff --git a/spec/integration/dsl_spec.rb b/spec/integration/dsl_spec.rb index 69a5f7a4..34e5b7b0 100644 --- a/spec/integration/dsl_spec.rb +++ b/spec/integration/dsl_spec.rb @@ -165,9 +165,9 @@ describe Capistrano::DSL do describe "when defining role with reserved name" do it "fails with ArgumentError" do - expect { + expect do dsl.role :all, %w{example1.com} - }.to raise_error(ArgumentError, "all reserved name for role. Please choose another name") + end.to raise_error(ArgumentError, "all reserved name for role. Please choose another name") end end diff --git a/spec/lib/capistrano/configuration/filter_spec.rb b/spec/lib/capistrano/configuration/filter_spec.rb index 11e60adc..ad65e69e 100644 --- a/spec/lib/capistrano/configuration/filter_spec.rb +++ b/spec/lib/capistrano/configuration/filter_spec.rb @@ -3,19 +3,21 @@ require "spec_helper" module Capistrano class Configuration describe Filter do - let(:available) { - [Server.new("server1").add_roles([:web, :db]), - Server.new("server2").add_role(:web), - Server.new("server3").add_role(:redis), - Server.new("server4").add_role(:db), - Server.new("server5").add_role(:stageweb)] - } + let(:available) do + [ + Server.new("server1").add_roles([:web, :db]), + Server.new("server2").add_role(:web), + Server.new("server3").add_role(:redis), + Server.new("server4").add_role(:db), + Server.new("server5").add_role(:stageweb) + ] + end describe '#new' do it "won't create an invalid type of filter" do - expect { + expect do Filter.new(:zarg) - }.to raise_error RuntimeError + end.to raise_error RuntimeError end context "with type :host" do diff --git a/spec/lib/capistrano/configuration/host_filter_spec.rb b/spec/lib/capistrano/configuration/host_filter_spec.rb index a8375441..3558676b 100644 --- a/spec/lib/capistrano/configuration/host_filter_spec.rb +++ b/spec/lib/capistrano/configuration/host_filter_spec.rb @@ -5,13 +5,13 @@ module Capistrano describe HostFilter do subject(:host_filter) { HostFilter.new(values) } - let(:available) { + let(:available) do [Server.new("server1"), Server.new("server2"), Server.new("server3"), Server.new("server4"), Server.new("server5")] - } + end shared_examples "it filters hosts correctly" do |expected| it "filters correctly" do diff --git a/spec/lib/capistrano/configuration/role_filter_spec.rb b/spec/lib/capistrano/configuration/role_filter_spec.rb index 83a2abb5..dc6ece4c 100644 --- a/spec/lib/capistrano/configuration/role_filter_spec.rb +++ b/spec/lib/capistrano/configuration/role_filter_spec.rb @@ -5,13 +5,15 @@ module Capistrano describe RoleFilter do subject(:role_filter) { RoleFilter.new(values) } - let(:available) { - [Server.new("server1").add_roles([:web, :db]), - Server.new("server2").add_role(:web), - Server.new("server3").add_role(:redis), - Server.new("server4").add_role(:db), - Server.new("server5").add_role(:stageweb)] - } + let(:available) do + [ + Server.new("server1").add_roles([:web, :db]), + Server.new("server2").add_role(:web), + Server.new("server3").add_role(:redis), + Server.new("server4").add_role(:db), + Server.new("server5").add_role(:stageweb) + ] + end shared_examples "it filters roles correctly" do |expected_size, expected| it "filters correctly" do diff --git a/spec/lib/capistrano/configuration_spec.rb b/spec/lib/capistrano/configuration_spec.rb index e29485b0..f63911b6 100644 --- a/spec/lib/capistrano/configuration_spec.rb +++ b/spec/lib/capistrano/configuration_spec.rb @@ -263,7 +263,7 @@ module Capistrano config.set :format, :pretty config.set :log_level, :debug config.set :ssh_options, :user => "albert" - SSHKit::Backend::Netssh.configure do |ssh| ssh.ssh_options = { :password => "einstein" } end + SSHKit::Backend::Netssh.configure { |ssh| ssh.ssh_options = { :password => "einstein" } } config.configure_backend expect(config.backend.config.backend.config.ssh_options).to eq(:user => "albert", :password => "einstein") end diff --git a/spec/lib/capistrano/dsl/task_enhancements_spec.rb b/spec/lib/capistrano/dsl/task_enhancements_spec.rb index 38ba0e14..526cfc5d 100644 --- a/spec/lib/capistrano/dsl/task_enhancements_spec.rb +++ b/spec/lib/capistrano/dsl/task_enhancements_spec.rb @@ -80,7 +80,7 @@ module Capistrano end it "invokes using the correct namespace when defined within a namespace" do - Rake.application.in_namespace("namespace") { + Rake.application.in_namespace("namespace") do Rake::Task.define_task("task") do |t| order.push(t.name) end @@ -90,7 +90,7 @@ module Capistrano task_enhancements.after("task", "after_task", :order) do |t| order.push(t.name) end - } + end Rake::Task["namespace:task"].invoke diff --git a/spec/lib/capistrano/immutable_task_spec.rb b/spec/lib/capistrano/immutable_task_spec.rb index 1249655d..01f7a397 100644 --- a/spec/lib/capistrano/immutable_task_spec.rb +++ b/spec/lib/capistrano/immutable_task_spec.rb @@ -19,13 +19,13 @@ module Capistrano message =~ /^WARNING: load:defaults has already been invoked/ end - expect { + expect do namespace :load do task :defaults do # Never reached since load_defaults is frozen and can't be enhanced end end - }.to raise_error(/frozen/i) + end.to raise_error(/frozen/i) end end end diff --git a/spec/lib/capistrano/scm_spec.rb b/spec/lib/capistrano/scm_spec.rb index 936ff132..abe9e602 100644 --- a/spec/lib/capistrano/scm_spec.rb +++ b/spec/lib/capistrano/scm_spec.rb @@ -5,9 +5,9 @@ require "capistrano/scm" module RaiseNotImplementedMacro def raise_not_implemented_on(method) it "should raise NotImplemented on #{method}" do - expect { + expect do subject.send(method) - }.to raise_error(NotImplementedError) + end.to raise_error(NotImplementedError) end end end