diff options
author | Thom May <thom@may.lt> | 2016-07-29 17:32:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-29 17:32:49 +0100 |
commit | e37ffed627248082b138bb87123dcb1e5be074b2 (patch) | |
tree | 8ae8aa3992b4037cbaf274b18577d79e69019906 /spec/server_spec.rb | |
parent | f4b93097a44daea4c6346ad855cb5b8d02cad328 (diff) | |
parent | e257f450c044616fefbd15e9a180387aaaa572a1 (diff) | |
download | chef-zero-e37ffed627248082b138bb87123dcb1e5be074b2.tar.gz |
Merge pull request #230 from chef/tm/style
ChefStyle
Diffstat (limited to 'spec/server_spec.rb')
-rw-r--r-- | spec/server_spec.rb | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/spec/server_spec.rb b/spec/server_spec.rb index 123a13e..64167e1 100644 --- a/spec/server_spec.rb +++ b/spec/server_spec.rb @@ -1,9 +1,9 @@ -require 'chef_zero/server' -require 'net/http' -require 'uri' +require "chef_zero/server" +require "net/http" +require "uri" describe ChefZero::Server do - context 'with a server bound to port 8889' do + context "with a server bound to port 8889" do before :each do @server = ChefZero::Server.new(:port => 8889) @server.start_background @@ -12,84 +12,84 @@ describe ChefZero::Server do @server.stop end - it 'a second server bound to port 8889 throws EADDRINUSE' do + it "a second server bound to port 8889 throws EADDRINUSE" do expect { ChefZero::Server.new(:port => 8889).start }.to raise_error Errno::EADDRINUSE end - it 'a server bound to range 8889-9999 binds to a port > 8889' do + it "a server bound to range 8889-9999 binds to a port > 8889" do server = ChefZero::Server.new(:port => 8889.upto(9999)) server.start_background expect(server.port).to be > 8889 expect(URI(server.url).port).to be > 8889 end - it 'a server bound to range 8889-8889 throws an exception' do + it "a server bound to range 8889-8889 throws an exception" do expect { ChefZero::Server.new(:port => 8889.upto(8889)).start_background }.to raise_error Errno::EADDRINUSE end - it 'has a very patient request timeout' do + it "has a very patient request timeout" do expect(@server.server.config[:RequestTimeout]).to eq 300 end - context 'accept headers' do + context "accept headers" do def get_nodes(accepts) uri = URI(@server.url) httpcall = Net::HTTP.new(uri.host, uri.port) - httpcall.get('/nodes', 'Accept' => accepts) + httpcall.get("/nodes", "Accept" => accepts) end def get_version uri = URI(@server.url) httpcall = Net::HTTP.new(uri.host, uri.port) - httpcall.get('/version', 'Accept' => 'text/plain, application/json') + httpcall.get("/version", "Accept" => "text/plain, application/json") end - it 'accepts requests with no accept header' do - request = Net::HTTP::Get.new('/nodes') - request.delete('Accept') + it "accepts requests with no accept header" do + request = Net::HTTP::Get.new("/nodes") + request.delete("Accept") uri = URI(@server.url) response = Net::HTTP.new(uri.host, uri.port).request(request) - expect(response.code).to eq '200' + expect(response.code).to eq "200" end - it 'accepts requests with accept: application/json' do - expect(get_nodes('application/json').code).to eq '200' + it "accepts requests with accept: application/json" do + expect(get_nodes("application/json").code).to eq "200" end - it 'accepts requests with accept: application/*' do - expect(get_nodes('application/*').code).to eq '200' + it "accepts requests with accept: application/*" do + expect(get_nodes("application/*").code).to eq "200" end - it 'accepts requests with accept: application/*' do - expect(get_nodes('*/*').code).to eq '200' + it "accepts requests with accept: application/*" do + expect(get_nodes("*/*").code).to eq "200" end - it 'denies requests with accept: application/blah' do - expect(get_nodes('application/blah').code).to eq '406' + it "denies requests with accept: application/blah" do + expect(get_nodes("application/blah").code).to eq "406" end - it 'denies requests with accept: blah/json' do - expect(get_nodes('blah/json').code).to eq '406' + it "denies requests with accept: blah/json" do + expect(get_nodes("blah/json").code).to eq "406" end - it 'denies requests with accept: blah/*' do - expect(get_nodes('blah/*').code).to eq '406' + it "denies requests with accept: blah/*" do + expect(get_nodes("blah/*").code).to eq "406" end - it 'denies requests with accept: blah/*' do - expect(get_nodes('blah/*').code).to eq '406' + it "denies requests with accept: blah/*" do + expect(get_nodes("blah/*").code).to eq "406" end - it 'denies requests with accept: <empty string>' do - expect(get_nodes('').code).to eq '406' + it "denies requests with accept: <empty string>" do + expect(get_nodes("").code).to eq "406" end - it 'accepts requests with accept: a/b;a=b;c=d, application/json;a=b, application/xml;a=b' do - expect(get_nodes('a/b;a=b;c=d, application/json;a=b, application/xml;a=b').code).to eq '200' + it "accepts requests with accept: a/b;a=b;c=d, application/json;a=b, application/xml;a=b" do + expect(get_nodes("a/b;a=b;c=d, application/json;a=b, application/xml;a=b").code).to eq "200" end - it 'accepts /version' do - expect(get_version.body.start_with?('chef-zero')).to be true + it "accepts /version" do + expect(get_version.body.start_with?("chef-zero")).to be true end end end |