Skip to content

Commit

Permalink
upgrade rack-test to 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dnesteryuk committed Oct 1, 2019
1 parent 45b1288 commit 6b03904
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ group :test do
gem 'maruku'
gem 'mime-types'
gem 'rack-jsonp', require: 'rack/jsonp'
gem 'rack-test', '~> 0.6.3'
gem 'rack-test', '~> 1.1.0'
gem 'rspec', '~> 3.0'
gem 'ruby-grape-danger', '~> 0.1.0', require: false
end
2 changes: 1 addition & 1 deletion gemfiles/multi_json.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ group :test do
gem 'maruku'
gem 'mime-types'
gem 'rack-jsonp', require: 'rack/jsonp'
gem 'rack-test', '~> 0.6.3'
gem 'rack-test', '~> 1.1.0'
gem 'rspec', '~> 3.0'
gem 'ruby-grape-danger', '~> 0.1.0', require: false
end
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/multi_xml.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ group :test do
gem 'maruku'
gem 'mime-types'
gem 'rack-jsonp', require: 'rack/jsonp'
gem 'rack-test', '~> 0.6.3'
gem 'rack-test', '~> 1.1.0'
gem 'rspec', '~> 3.0'
gem 'ruby-grape-danger', '~> 0.1.0', require: false
end
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rack_edge.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ group :test do
gem 'maruku'
gem 'mime-types'
gem 'rack-jsonp', require: 'rack/jsonp'
gem 'rack-test', '~> 0.6.3'
gem 'rack-test', '~> 1.1.0'
gem 'rspec', '~> 3.0'
gem 'ruby-grape-danger', '~> 0.1.0', require: false
end
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_3.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ group :test do
gem 'maruku'
gem 'mime-types'
gem 'rack-jsonp', require: 'rack/jsonp'
gem 'rack-test', '~> 0.6.3'
gem 'rack-test', '~> 1.1.0'
gem 'rspec', '~> 3.0'
gem 'ruby-grape-danger', '~> 0.1.0', require: false
end
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_4.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ group :test do
gem 'maruku'
gem 'mime-types'
gem 'rack-jsonp', require: 'rack/jsonp'
gem 'rack-test', '~> 0.6.3'
gem 'rack-test', '~> 1.1.0'
gem 'rspec', '~> 3.0'
gem 'ruby-grape-danger', '~> 0.1.0', require: false
end
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ group :test do
gem 'maruku'
gem 'mime-types'
gem 'rack-jsonp', require: 'rack/jsonp'
gem 'rack-test', '~> 0.6.3'
gem 'rack-test', '~> 1.1.0'
gem 'rspec', '~> 3.0'
gem 'ruby-grape-danger', '~> 0.1.0', require: false
end
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_edge.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ group :test do
gem 'maruku'
gem 'mime-types'
gem 'rack-jsonp', require: 'rack/jsonp'
gem 'rack-test', '~> 0.6.3'
gem 'rack-test', '~> 1.1.0'
gem 'rspec', '~> 3.0'
gem 'ruby-grape-danger', '~> 0.1.0', require: false
end
Expand Down
4 changes: 2 additions & 2 deletions spec/grape/validations/validators/coerce_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ def self.parsed?(value)
expect(last_response.status).to eq(200)
expect(last_response.body).to eq('arrays work')

get '/', splines: [{ x: 2, ints: [] }, { x: 3, ints: [4], obj: { y: 'quack' } }]
get '/', splines: [{ x: 2, ints: [5] }, { x: 3, ints: [4], obj: { y: 'quack' } }]
expect(last_response.status).to eq(200)
expect(last_response.body).to eq('arrays work')

Expand All @@ -592,7 +592,7 @@ def self.parsed?(value)
expect(last_response.status).to eq(400)
expect(last_response.body).to eq('splines[x] does not have a valid value')

get '/', splines: [{ x: 1, ints: [] }, { x: 4, ints: [] }]
get '/', splines: [{ x: 1, ints: [5] }, { x: 4, ints: [6] }]
expect(last_response.status).to eq(400)
expect(last_response.body).to eq('splines[x] does not have a valid value')
end
Expand Down
14 changes: 12 additions & 2 deletions spec/grape/validations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -540,15 +540,25 @@ def validate_param!(attr_name, params)
]

expect(last_response.status).to eq(400)
expect(last_response.body).to eq('children[0][parents] is missing, children[1][parents] is missing')
expect(last_response.body).to eq(
'children[0][parents][0][name] is missing, ' \
'children[1][parents][0][name] is missing'
)
end

it 'safely handles empty arrays and blank parameters' do
# NOTE: with body parameters in json or XML or similar this
# should actually return 200, since an empty array is valid.
get '/within_array', children: []
expect(last_response.status).to eq(400)
expect(last_response.body).to eq('children is missing')
expect(last_response.body).to eq(
'children[0][name] is missing, ' \
'children[0][parents] is missing, ' \
'children[0][parents] is invalid, ' \
'children[0][parents][0][name] is missing, ' \
'children[0][parents][0][name] is empty'
)

get '/within_array', children: [name: 'Jay']
expect(last_response.status).to eq(400)
expect(last_response.body).to eq('children[0][parents] is missing')
Expand Down

0 comments on commit 6b03904

Please sign in to comment.