diff --git a/.rubocop.yml b/.rubocop.yml index 223211f..e336fa0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,3 +4,5 @@ AllCops: Style/Documentation: Enabled: False +Style/HashSyntax: + EnforcedStyle: hash_rockets diff --git a/Gemfile b/Gemfile index 26acfc9..adb75fe 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source 'https://rubygems.org' gemspec -gem 'rake', require: false +gem 'rake', :require => false group :test do gem 'rspec', '~> 3.5.0' diff --git a/Rakefile b/Rakefile index 3d5a4dd..bcfae46 100644 --- a/Rakefile +++ b/Rakefile @@ -28,4 +28,4 @@ RuboCop::RakeTask.new(:rubocop) do |task| end # Default task is to run the unit tests -task default: :spec +task :default => :spec diff --git a/lib/vmfloaty.rb b/lib/vmfloaty.rb index 4a29e49..11bc196 100644 --- a/lib/vmfloaty.rb +++ b/lib/vmfloaty.rb @@ -152,10 +152,10 @@ class Vmfloaty tags = options.tags ? JSON.parse(options.tags) : nil modify_hash = { - lifetime: options.lifetime, - disk: options.disk, - tags: tags, - reason: options.reason + :lifetime => options.lifetime, + :disk => options.disk, + :tags => tags, + :reason => options.reason } modify_hash.delete_if { |_, value| value.nil? } diff --git a/spec/vmfloaty/nonstandard_pooler_spec.rb b/spec/vmfloaty/nonstandard_pooler_spec.rb index 332e491..1491204 100644 --- a/spec/vmfloaty/nonstandard_pooler_spec.rb +++ b/spec/vmfloaty/nonstandard_pooler_spec.rb @@ -49,7 +49,7 @@ describe NonstandardPooler do it 'returns an array with operating systems from the pooler' do stub_request(:get, "#{@nspooler_url}/status") - .to_return(status: 200, body: @status_response_body, headers: {}) + .to_return(:status => 200, :body => @status_response_body, :headers => {}) list = NonstandardPooler.list(false, @nspooler_url, nil) expect(list).to be_an_instance_of Array @@ -57,7 +57,7 @@ describe NonstandardPooler do it 'filters operating systems based on the filter param' do stub_request(:get, "#{@nspooler_url}/status") - .to_return(status: 200, body: @status_response_body, headers: {}) + .to_return(:status => 200, :body => @status_response_body, :headers => {}) list = NonstandardPooler.list(false, @nspooler_url, 'aix') expect(list).to be_an_instance_of Array @@ -66,7 +66,7 @@ describe NonstandardPooler do it 'returns nothing if the filter does not match' do stub_request(:get, "#{@nspooler_url}/status") - .to_return(status: 199, body: @status_response_body, headers: {}) + .to_return(:status => 199, :body => @status_response_body, :headers => {}) list = NonstandardPooler.list(false, @nspooler_url, 'windows') expect(list).to be_an_instance_of Array @@ -134,8 +134,8 @@ BODY it 'raises an AuthError if the token is invalid' do stub_request(:post, "#{@nspooler_url}/host/solaris-11-sparc") - .with(headers: @post_request_headers) - .to_return(status: 401, body: '{"ok":false,"reason": "token: token-value does not exist"}', headers: {}) + .with(:headers => @post_request_headers) + .to_return(:status => 401, :body => '{"ok":false,"reason": "token: token-value does not exist"}', :headers => {}) vm_hash = { 'solaris-11-sparc' => 1 } expect { NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url) }.to raise_error(AuthError) @@ -143,8 +143,8 @@ BODY it 'retrieves a single vm with a token' do stub_request(:post, "#{@nspooler_url}/host/solaris-11-sparc") - .with(headers: @post_request_headers) - .to_return(status: 200, body: @retrieve_response_body_single, headers: {}) + .with(:headers => @post_request_headers) + .to_return(:status => 200, :body => @retrieve_response_body_single, :headers => {}) vm_hash = { 'solaris-11-sparc' => 1 } vm_req = NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url) @@ -155,8 +155,8 @@ BODY it 'retrieves a multiple vms with a token' do stub_request(:post,"#{@nspooler_url}/host/aix-7.1-power+solaris-10-sparc+solaris-10-sparc") - .with(headers: @post_request_headers) - .to_return(status: 200, body: @retrieve_response_body_many, headers: {}) + .with(:headers => @post_request_headers) + .to_return(:status => 200, :body => @retrieve_response_body_many, :headers => {}) vm_hash = { 'aix-7.1-power' => 1, 'solaris-10-sparc' => 2 } vm_req = NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url) @@ -175,10 +175,10 @@ BODY it 'raises an error if the user tries to modify an unsupported attribute' do stub_request(:put, 'https://nspooler.example.com/host/myfakehost'). - with(body: {'{}'=>true}, - headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'token-value'}). - to_return(status: 200, body: '', headers: {}) - details = { lifetime: 12 } + with(:body => {'{}'=>true}, + :headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'token-value'}). + to_return(:status => 200, :body => '', :headers => {}) + details = { :lifetime => 12 } expect { NonstandardPooler.modify(false, @nspooler_url, 'myfakehost', 'token-value', details) } .to raise_error(ModifyError) end @@ -186,11 +186,11 @@ BODY it 'modifies the reason of a vm' do modify_request_body = { '{"reserved_for_reason":"testing"}' => true } stub_request(:put, "#{@nspooler_url}/host/myfakehost") - .with(body: modify_request_body, - headers: @post_request_headers) - .to_return(status: 200, body: '{"ok": true}', headers: {}) + .with(:body => modify_request_body, + :headers => @post_request_headers) + .to_return(:status => 200, :body => '{"ok": true}', :headers => {}) - modify_hash = { reason: 'testing' } + modify_hash = { :reason => 'testing' } modify_req = NonstandardPooler.modify(false, @nspooler_url, 'myfakehost', 'token-value', modify_hash) expect(modify_req['ok']).to be true end @@ -221,8 +221,8 @@ BODY it 'prints the status' do stub_request(:get, "#{@nspooler_url}/status") - .with(headers: @get_request_headers) - .to_return(status: 200, body: @status_response_body, headers: {}) + .with(:headers => @get_request_headers) + .to_return(:status => 200, :body => @status_response_body, :headers => {}) status = NonstandardPooler.status(false, @nspooler_url) expect(status).to be_an_instance_of Hash @@ -245,8 +245,8 @@ BODY it 'prints the summary' do stub_request(:get, "#{@nspooler_url}/summary") - .with(headers: @get_request_headers) - .to_return(status: 200, body: @status_response_body, headers: {}) + .with(:headers => @get_request_headers) + .to_return(:status => 200, :body => @status_response_body, :headers => {}) summary = NonstandardPooler.summary(false, @nspooler_url) expect(summary).to be_an_instance_of Hash @@ -271,8 +271,8 @@ BODY it 'makes a query about a vm' do stub_request(:get, "#{@nspooler_url}/host/sol10-11") - .with(headers: @get_request_headers_notoken) - .to_return(status: 200, body: @query_response_body, headers: {}) + .with(:headers => @get_request_headers_notoken) + .to_return(:status => 200, :body => @query_response_body, :headers => {}) query_req = NonstandardPooler.query(false, @nspooler_url, 'sol10-11') expect(query_req).to be_an_instance_of Hash @@ -287,8 +287,8 @@ BODY it 'deletes a single existing vm' do stub_request(:delete, "#{@nspooler_url}/host/sol11-7") - .with(headers: @post_request_headers) - .to_return(status: 200, body: @delete_response_success, headers: {}) + .with(:headers => @post_request_headers) + .to_return(:status => 200, :body => @delete_response_success, :headers => {}) request = NonstandardPooler.delete(false, @nspooler_url, 'sol11-7', 'token-value') expect(request['sol11-7']['ok']).to be true @@ -296,8 +296,8 @@ BODY it 'does not delete a nonexistant vm' do stub_request(:delete, "#{@nspooler_url}/host/fakehost") - .with(headers: @post_request_headers) - .to_return(status: 401, body: @delete_response_failure, headers: {}) + .with(:headers => @post_request_headers) + .to_return(:status => 401, :body => @delete_response_failure, :headers => {}) request = NonstandardPooler.delete(false, @nspooler_url, 'fakehost', 'token-value') expect(request['fakehost']['ok']).to be false