Skip to content

Commit

Permalink
resolve (some) spec deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
igrigorik committed May 29, 2016
1 parent 2951e8b commit 6c06cd3
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 77 deletions.
6 changes: 3 additions & 3 deletions spec/integration/early_abort_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

post_request(request_data, err) do |c|
c.response.should == "{\"error\":\"Can't handle requests with X-Crash: true.\"}"
File.exist?("/tmp/goliath-test-error.log").should be_false
File.exist?("/tmp/goliath-test-error.log").should be false
end
end
end
Expand All @@ -36,8 +36,8 @@

post_request(request_data, err) do |c|
c.response.should =~ /Payload size can't exceed 10 bytes/
File.exist?("/tmp/goliath-test-error.log").should be_false
File.exist?("/tmp/goliath-test-error.log").should be false
end
end
end
end
end
2 changes: 1 addition & 1 deletion spec/integration/test_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DummyServer < Goliath::API
with_api(DummyServer, :log_file => "test.log") do |api|
get_request({},err)
end
File.exist?("test.log").should be_true
File.exist?("test.log").should be_truthy
File.unlink("test.log")
end

Expand Down
10 changes: 5 additions & 5 deletions spec/unit/env_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@
context '#respond_to?' do
it 'returns true for items in the hash' do
@env['test'] = 'true'
@env.respond_to?(:test).should be_true
@env.respond_to?(:test).should be true
end

it 'returns false for items not in hash' do
@env.respond_to?(:test).should be_false
@env.respond_to?(:test).should be false
end

it 'returns true for items in the config hash' do
@env['config'] = {'test' => true}
@env.respond_to?(:test).should be_true
@env.respond_to?(:test).should be true
end

it 'returns false for items not in the config hash' do
@env['config'] = {}
@env.respond_to?(:test).should be_false
@env.respond_to?(:test).should be false
end

it 'delegates if not found' do
@env.respond_to?(:[]).should be_true
@env.respond_to?(:[]).should be true
end
end
end
4 changes: 2 additions & 2 deletions spec/unit/headers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

it 'returns true if a key has been set' do
@h['my_header'] = 'my_value'
@h.has_key?('my_header').should be_true
@h.has_key?('my_header').should be true
end

it 'returns false if the key has not been set' do
@h.has_key?('my_header').should be_false
@h.has_key?('my_header').should be false
end

it 'ignores nil values' do
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/rack/formatters/json_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
end

it 'checks content type for application/json' do
@js.json_response?({'Content-Type' => 'application/json'}).should be_true
@js.json_response?({'Content-Type' => 'application/json'}).should be_truthy
end

it 'returns false for non-applicaton/json types' do
@js.json_response?({'Content-Type' => 'application/xml'}).should be_false
@js.json_response?({'Content-Type' => 'application/xml'}).should be_falsey
end

it 'calls the app with the provided environment' do
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/rack/formatters/xml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
end

it 'checks content type for application/xml' do
@xml.xml_response?({'Content-Type' => 'application/xml'}).should be_true
@xml.xml_response?({'Content-Type' => 'application/xml'}).should be_truthy
end

it 'returns false for non-applicaton/xml types' do
@xml.xml_response?({'Content-Type' => 'application/json'}).should be_false
@xml.xml_response?({'Content-Type' => 'application/json'}).should be_falsey
end

it 'calls the app with the provided environment' do
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/rack/formatters/yaml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
end

it 'checks content type for text/yaml' do
@ym.yaml_response?({'Content-Type' => 'text/yaml'}).should be_true
@ym.yaml_response?({'Content-Type' => 'text/yaml'}).should be_truthy
end

it 'returns false for non-applicaton/yaml types' do
@ym.yaml_response?({'Content-Type' => 'application/xml'}).should be_false
@ym.yaml_response?({'Content-Type' => 'application/xml'}).should be_falsey
end

it 'calls the app with the provided environment' do
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/rack/params_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
@env['QUERY_STRING'] = 'foo[]=bar&foo[]=baz&foo[]=foos'

ret = @params.retrieve_params(@env)
ret['foo'].is_a?(Array).should be_true
ret['foo'].is_a?(Array).should be true
ret['foo'].length.should == 3
ret['foo'].should == %w(bar baz foos)
end
Expand Down Expand Up @@ -98,7 +98,7 @@

it 'handles empty query and post body' do
ret = @params.retrieve_params(@env)
ret.is_a?(Hash).should be_true
ret.is_a?(Hash).should be true
ret.should be_empty
end

Expand All @@ -116,7 +116,7 @@

it 'sets the params into the environment' do
@app.should_receive(:call).with do |app_env|
app_env.has_key?('params').should be_true
app_env.has_key?('params').should be true
app_env['params']['a'].should == 'b'
end

Expand Down
30 changes: 15 additions & 15 deletions spec/unit/rack/validation/param_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

it "uses a default value if optional is not supplied" do
cv = Goliath::Rack::Validation::Param.new(@app, :key => 'key')
cv.optional.should be_false
cv.optional.should be false
end

it "should have default and message be optional" do
Expand Down Expand Up @@ -127,52 +127,52 @@

context 'key_valid?' do
it 'raises exception if the key is not provided' do
@rp.key_valid?(@env['params']).should be_false
@rp.key_valid?(@env['params']).should be false
end

it 'raises exception if the key is blank' do
@env['params']['mk'] = ''
@rp.key_valid?(@env['params']).should be_false
@rp.key_valid?(@env['params']).should be false
end

it 'raises exception if the key is nil' do
@env['params']['mk'] = nil
@rp.key_valid?(@env['params']).should be_false
@rp.key_valid?(@env['params']).should be false
end

it 'handles an empty array' do
@env['params']['mk'] = []
@rp.key_valid?(@env['params']).should be_false
@rp.key_valid?(@env['params']).should be false
end

it 'handles an array of nils' do
@env['params']['mk'] = [nil, nil, nil]
@rp.key_valid?(@env['params']).should be_false
@rp.key_valid?(@env['params']).should be false
end

it 'handles an array of blanks' do
@env['params']['mk'] = ['', '', '']
@rp.key_valid?(@env['params']).should be_false
@rp.key_valid?(@env['params']).should be false
end

it "doesn't raise if the key provided" do
@env['params']['mk'] = 'my value'
@rp.key_valid?(@env['params']).should be_true
@rp.key_valid?(@env['params']).should be true
end

it "doesn't raise if the array contains valid data" do
@env['params']['mk'] = [1, 2, 3, 4]
@rp.key_valid?(@env['params']).should be_true
@rp.key_valid?(@env['params']).should be true
end

it "doesn't raise if the key provided is multiline and has blanks" do
@env['params']['mk'] = "my\n \nvalue"
@rp.key_valid?(@env['params']).should be_true
@rp.key_valid?(@env['params']).should be true
end

it "doesn't raise if the key provided is an array and contains multiline with blanks" do
@env['params']['mk'] = ["my\n \nvalue", "my\n \nother\n \nvalue"]
@rp.key_valid?(@env['params']).should be_true
@rp.key_valid?(@env['params']).should be true
end
end
end
Expand All @@ -194,7 +194,7 @@
}
}

@rp.key_valid?(@env['params']).should be_false
@rp.key_valid?(@env['params']).should be false
end

it "return true if key is present" do
Expand All @@ -205,7 +205,7 @@
}
}

@rp.key_valid?(@env['params']).should be_true
@rp.key_valid?(@env['params']).should be true
end
end

Expand All @@ -225,7 +225,7 @@
}
}

@rp.key_valid?(@env['params']).should be_false
@rp.key_valid?(@env['params']).should be false
end

it "return true if key is present" do
Expand All @@ -236,7 +236,7 @@
}
}

@rp.key_valid?(@env['params']).should be_true
@rp.key_valid?(@env['params']).should be true
end
end

Expand Down
50 changes: 25 additions & 25 deletions spec/unit/rack/validation/required_param_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,56 +54,56 @@

describe 'key_valid?' do
it 'raises exception if the key is not provided' do
@rp.key_valid?(@env['params']).should be_false
@rp.key_valid?(@env['params']).should be false
end

it 'raises exception if the key is blank' do
@env['params']['mk'] = ''
@rp.key_valid?(@env['params']).should be_false
@rp.key_valid?(@env['params']).should be false
end

it 'raises exception if the key is nil' do
@env['params']['mk'] = nil
@rp.key_valid?(@env['params']).should be_false
@rp.key_valid?(@env['params']).should be false
end

it 'handles an empty array' do
@env['params']['mk'] = []
@rp.key_valid?(@env['params']).should be_false
@rp.key_valid?(@env['params']).should be false
end

it 'handles an array of nils' do
@env['params']['mk'] = [nil, nil, nil]
@rp.key_valid?(@env['params']).should be_false
@rp.key_valid?(@env['params']).should be false
end

it 'handles an array of blanks' do
@env['params']['mk'] = ['', '', '']
@rp.key_valid?(@env['params']).should be_false
@rp.key_valid?(@env['params']).should be false
end

it "doesn't raise if the key provided" do
@env['params']['mk'] = 'my value'
@rp.key_valid?(@env['params']).should be_true
@rp.key_valid?(@env['params']).should be true
end

it "doesn't raise if the array contains valid data" do
@env['params']['mk'] = [1, 2, 3, 4]
@rp.key_valid?(@env['params']).should be_true
@rp.key_valid?(@env['params']).should be true
end

it "doesn't raise if the key provided is multiline and has blanks" do
@env['params']['mk'] = "my\n \nvalue"
@rp.key_valid?(@env['params']).should be_true
@rp.key_valid?(@env['params']).should be true
end

it "doesn't raise if the key provided is an array and contains multiline with blanks" do
@env['params']['mk'] = ["my\n \nvalue", "my\n \nother\n \nvalue"]
@rp.key_valid?(@env['params']).should be_true
end
@rp.key_valid?(@env['params']).should be true
end
end
end

describe 'Nested keys tests' do
before do
@app = double('app').as_null_object
Expand All @@ -122,22 +122,22 @@
'pass' => "password"}
}
}
@rp.key_valid?(@env['params']).should be_false

@rp.key_valid?(@env['params']).should be false
end

it "return true if key is present" do
@env['params'] = {'data' => {
'credentials' => {
'login' => "user",
'pass' => "password"}
}
}
@rp.key_valid?(@env['params']).should be_true

@rp.key_valid?(@env['params']).should be true
end
end

describe 'Nested keys tests (with string)' do
before do
@app = double('app').as_null_object
Expand All @@ -156,21 +156,21 @@
'pass' => "password"}
}
}
@rp.key_valid?(@env['params']).should be_false

@rp.key_valid?(@env['params']).should be false
end

it "return true if key is present" do
@env['params'] = {'data' => {
'credentials' => {
'login' => "user",
'pass' => "password"}
}
}
@rp.key_valid?(@env['params']).should be_true

@rp.key_valid?(@env['params']).should be true
end
end


end
Loading

0 comments on commit 6c06cd3

Please sign in to comment.