Skip to content

Commit

Permalink
rubocop: fixed "Use the new Ruby 1.9 hash syntax"
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Nov 26, 2014
1 parent a765df7 commit 942697a
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 92 deletions.
6 changes: 0 additions & 6 deletions .rubocop.yml
Expand Up @@ -90,12 +90,6 @@ Style/Documentation:
Style/DotPosition:
Enabled: false

# Offense count: 91
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/HashSyntax:
Enabled: false

# Offense count: 2
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
@@ -1,13 +1,13 @@
source "https://rubygems.org"

# TODO FIXME: use a correct branch here...
gem "suse-connect", :github => "SUSE/connect", :branch => "v0.2.14"
gem "suse-connect", github: "SUSE/connect", branch: "v0.2.14"

group :test do
gem "rake"
gem "yard"
gem "yast-rake", ">= 0.1.9"
gem "rspec", "~> 2.14.0"
gem "simplecov", :require => false
gem "coveralls", :require => false if ENV["TRAVIS"]
gem "simplecov", require: false
gem "coveralls", require: false if ENV["TRAVIS"]
end
54 changes: 27 additions & 27 deletions src/clients/inst_scc.rb
Expand Up @@ -579,47 +579,47 @@ def start_workflow
sequence = {
"ws_start" => workflow_start,
"check" => {
:auto => :auto,
:abort => :abort,
:cancel => :abort,
:register => "register",
:extensions => "select_addons",
:update => "update",
:next => :next
auto: :auto,
abort: :abort,
cancel: :abort,
register: "register",
extensions: "select_addons",
update: "update",
next: :next
},
"update" => {
:abort => :abort,
:cancel => :abort,
:next => "select_addons",
:register => "register"
abort: :abort,
cancel: :abort,
next: "select_addons",
register: "register"
},
"register" => {
:abort => :abort,
:cancel => :abort,
:skip => :next,
:next => "select_addons"
abort: :abort,
cancel: :abort,
skip: :next,
next: "select_addons"
},
"select_addons" => {
:abort => :abort,
:skip => "update_autoyast_config",
:cancel => "check",
:next => "addon_eula"
abort: :abort,
skip: "update_autoyast_config",
cancel: "check",
next: "addon_eula"
},
"addon_eula" => {
:abort => :abort,
:next => "register_addons"
abort: :abort,
next: "register_addons"
},
"register_addons" => {
:abort => :abort,
:next => "update_autoyast_config"
abort: :abort,
next: "update_autoyast_config"
},
"update_autoyast_config" => {
:abort => :abort,
:next => "pkg_manager"
abort: :abort,
next: "pkg_manager"
},
"pkg_manager" => {
:abort => :abort,
:next => :next
abort: :abort,
next: :next
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/registration/helpers.rb
Expand Up @@ -135,8 +135,8 @@ def self.copy_certificate_to_target
# write the current configuration to the configuration file
def self.write_config
config_params = {
:url => UrlHelpers.registration_url,
:insecure => insecure_registration
url: UrlHelpers.registration_url,
insecure: insecure_registration
}

log.info "writing registration config: #{config_params}"
Expand Down
28 changes: 14 additions & 14 deletions src/lib/registration/registration.rb
Expand Up @@ -42,8 +42,8 @@ def initialize(url = nil)

def register(email, reg_code, distro_target)
settings = connect_params(
:token => reg_code,
:email => email
token: reg_code,
email: email
)

login, password = SUSE::Connect::YaST.announce_system(settings, distro_target)
Expand Down Expand Up @@ -99,10 +99,10 @@ def get_addon_list
log.info "Reading available addons for product: #{base_product["name"]}"

remote_product = SUSE::Connect::Remote::Product.new(
:arch => base_product["arch"],
:identifier => base_product["name"],
:version => base_product["version"],
:release_type => base_product["release_type"]
arch: base_product["arch"],
identifier: base_product["name"],
version: base_product["version"],
release_type: base_product["release_type"]
)

params = connect_params
Expand Down Expand Up @@ -147,10 +147,10 @@ def set_registered(remote_product)
def service_for_product(product, &_block)
remote_product = product.is_a?(Hash) ?
SUSE::Connect::Remote::Product.new(
:arch => product["arch"],
:identifier => product["name"],
:version => product["version"],
:release_type => product["release_type"]
arch: product["arch"],
identifier: product["name"],
version: product["version"],
release_type: product["release_type"]
) : product

log.info "Using product: #{remote_product}"
Expand Down Expand Up @@ -202,11 +202,11 @@ def store_ssl_error(context)

def connect_params(params = {})
default_params = {
:language => ::Registration::Helpers.http_language,
:debug => ENV["SCCDEBUG"],
:verbose => ENV["Y2DEBUG"] == "1",
language: ::Registration::Helpers.http_language,
debug: ENV["SCCDEBUG"],
verbose: ENV["Y2DEBUG"] == "1",
# pass a verify_callback to get details about failed SSL verification
:verify_callback => verify_callback
verify_callback: verify_callback
}

if @url
Expand Down
26 changes: 13 additions & 13 deletions src/lib/registration/ui/autoyast_config_workflow.rb
Expand Up @@ -46,27 +46,27 @@ def run
sequence = {
"ws_start" => "general",
"general" => {
:abort => :abort,
:next => :next,
:addons => "addons"
abort: :abort,
next: :next,
addons: "addons"
},
"addons" => {
:abort => :abort,
:next => "general",
:download => "remote_addons"
abort: :abort,
next: "general",
download: "remote_addons"
},
"remote_addons" => {
:addons => "addons",
:abort => :abort,
:next => "addons_eula"
addons: "addons",
abort: :abort,
next: "addons_eula"
},
"addons_eula" => {
:abort => :abort,
:next => "addons_regcodes"
abort: :abort,
next: "addons_regcodes"
},
"addons_regcodes" => {
:abort => :abort,
:next => "addons"
abort: :abort,
next: "addons"
}
}

Expand Down
6 changes: 3 additions & 3 deletions test/addon_selection_dialog_test.rb
Expand Up @@ -18,13 +18,13 @@
describe ".run" do
it "returns response from addon selection according to pressed button" do
expect(Yast::UI).to receive(:UserInput).and_return(:abort)
registration = double(:activated_products => [], :get_addon_list => [])
registration = double(activated_products: [], get_addon_list: [])
expect(subject.run(registration)).to eq :abort
end

it "returns `:skip` if no addon is selected and user click next" do
expect(Yast::UI).to receive(:UserInput).and_return(:next)
registration = double(:activated_products => [], :get_addon_list => [])
registration = double(activated_products: [], get_addon_list: [])
expect(subject.run(registration)).to eq :skip
end

Expand All @@ -35,7 +35,7 @@
expect(Yast::UI).to receive(:QueryWidget).
with(Yast::Term.new(:id, test_addon.identifier), :Value).
and_return(true)
registration = double(:activated_products => [], :get_addon_list => [test_addon])
registration = double(activated_products: [], get_addon_list: [test_addon])
expect(subject.run(registration)).to eq :next
end
end
Expand Down
24 changes: 12 additions & 12 deletions test/addon_spec.rb
Expand Up @@ -18,8 +18,8 @@
prod1 = addon_generator
prod2 = addon_generator
registration = double(
:activated_products => [],
:get_addon_list => [prod1, prod2]
activated_products: [],
get_addon_list: [prod1, prod2]
)

expect(Registration::Addon.find_all(registration).size).to be 2
Expand All @@ -28,8 +28,8 @@
it "find even dependend products" do
prod1 = addon_with_child_generator
registration = double(
:activated_products => [],
:get_addon_list => [prod1]
activated_products: [],
get_addon_list: [prod1]
)

expect(Registration::Addon.find_all(registration).size).to be 2
Expand All @@ -38,8 +38,8 @@
it "sets properly dependencies between addons" do
prod1 = addon_with_child_generator
registration = double(
:activated_products => [],
:get_addon_list => [prod1]
activated_products: [],
get_addon_list: [prod1]
)

addons = Registration::Addon.find_all(registration)
Expand All @@ -51,8 +51,8 @@
prod1 = addon_generator("name" => "prod1")
prod2 = addon_generator("name" => "prod2")
registration = double(
:activated_products => [prod1],
:get_addon_list => [prod1, prod2]
activated_products: [prod1],
get_addon_list: [prod1, prod2]
)

addons = Registration::Addon.find_all(registration)
Expand All @@ -66,8 +66,8 @@

it "sets the registration status for dependent addons" do
registration = double(
:activated_products => YAML.load_file(fixtures_file("activated_products.yml")),
:get_addon_list => YAML.load_file(fixtures_file("pure_addons.yml"))
activated_products: YAML.load_file(fixtures_file("activated_products.yml")),
get_addon_list: YAML.load_file(fixtures_file("pure_addons.yml"))
)

addons = Registration::Addon.find_all(registration)
Expand Down Expand Up @@ -171,8 +171,8 @@
describe "#selectable?" do
let(:addons) do
Registration::Addon.find_all(double(
:get_addon_list => [addon_with_child_generator],
:activated_products => []
get_addon_list: [addon_with_child_generator],
activated_products: []
))
end

Expand Down
2 changes: 1 addition & 1 deletion test/discover_registration_services_test.rb
Expand Up @@ -29,7 +29,7 @@
# stub the SLP service discovery
slp_service = double
slp_attributes = double
allow(slp_attributes).to receive(:to_h).and_return({:description => "Description"})
allow(slp_attributes).to receive(:to_h).and_return({description: "Description"})
allow(slp_service).to receive(:attributes).and_return(slp_attributes)
allow(slp_service).to receive(:slp_url).and_return("service:registration.suse:smt:#{slp_url}")
allow(Yast::SlpService).to receive(:all).and_return([slp_service])
Expand Down
6 changes: 3 additions & 3 deletions test/helpers_spec.rb
Expand Up @@ -15,7 +15,7 @@

it "creates a label with description and url" do
description = "Description"
expect(slp_attributes).to receive(:to_h).and_return({:description => description})
expect(slp_attributes).to receive(:to_h).and_return({description: description})
expect(Registration::Helpers.service_description(slp_service)).to eq("#{description} (#{slp_url})")
end

Expand Down Expand Up @@ -162,8 +162,8 @@
expect(Registration::Helpers).to receive(:insecure_registration) \
.and_return(false)
expect(SUSE::Connect::YaST).to receive(:write_config).with(
:url => url,
:insecure => false
url: url,
insecure: false
)

Registration::Helpers.write_config
Expand Down
6 changes: 3 additions & 3 deletions test/registration_spec.rb
Expand Up @@ -21,7 +21,7 @@
expect(Registration::SwMgmt).to receive(:zypp_config_writable!)
expect_any_instance_of(SUSE::Connect::Credentials).to receive(:write)
expect(SUSE::Connect::YaST).to(receive(:announce_system)
.with(hash_including(:token => reg_code), target_distro)
.with(hash_including(token: reg_code), target_distro)
.and_return([username, password])
)

Expand Down Expand Up @@ -87,7 +87,7 @@

describe "#activated_products" do
it "returns list of activated products" do
status = double(:activated_products => [])
status = double(activated_products: [])
expect(SUSE::Connect::YaST).to receive(:status).and_return(status)

expect(Registration::Registration.new.activated_products).to eq([])
Expand Down Expand Up @@ -129,7 +129,7 @@
let(:error_code) { 19 }
let(:error_string) { "self signed certificate in certificate chain" }
# SSL error context
let(:context) { double(:error => error_code, :error_string => error_string) }
let(:context) { double(error: error_code, error_string: error_string) }

it "stores the SSL error details" do
certificate = File.read(fixtures_file("test.pem"))
Expand Down
4 changes: 2 additions & 2 deletions test/smt_status_spec.rb
Expand Up @@ -11,15 +11,15 @@

it "returns true when /center/regsvc?command=listproducts returns OK" do
expect(Registration::Downloader).to receive(:download).
with(expected_url, :insecure => false).
with(expected_url, insecure: false).
and_return(true)

expect(subject.ncc_api_present?).to be_true
end

it "returns false otherwise" do
expect(Registration::Downloader).to receive(:download).
with(expected_url, :insecure => false).
with(expected_url, insecure: false).
and_raise(Registration::DownloadError)

expect(subject.ncc_api_present?).to be_false
Expand Down
6 changes: 3 additions & 3 deletions test/url_helpers_spec.rb
Expand Up @@ -190,8 +190,8 @@

describe ".slp_discovery" do
it "returns SLP services excluding SUSE Manager services" do
service1 = double(:slp_url => "service:registration.suse:smt:https://example.com/connect")
service2 = double(:slp_url => "service:registration.suse:manager:https://example.com/connect")
service1 = double(slp_url: "service:registration.suse:smt:https://example.com/connect")
service2 = double(slp_url: "service:registration.suse:manager:https://example.com/connect")
expect(Yast::SlpService).to receive(:all).and_return([service1, service2])

result = Registration::UrlHelpers.slp_discovery
Expand All @@ -203,7 +203,7 @@

describe ".slp_discovery_feedback" do
it "runs SLP discovery with progress message" do
services = [ double(:slp_url => "service:registration.suse:smt:https://example.com/connect") ]
services = [ double(slp_url: "service:registration.suse:smt:https://example.com/connect") ]
expect(Yast::SlpService).to receive(:all).and_return(services)

# stub Popup.Feedback call but yield the passed block
Expand Down

0 comments on commit 942697a

Please sign in to comment.