Skip to content

Commit

Permalink
Use Integer instead of Fixnum
Browse files Browse the repository at this point in the history
  • Loading branch information
namusyaka committed Dec 27, 2016
1 parent 6ae8db7 commit 3b41eeb
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2878,7 +2878,7 @@ end
The behaviour is then:

```bash
GET /123 # 'Fixnum'
GET /123 # 'Integer'
GET /foo # 400 error - 'blah is invalid'
```

Expand Down
4 changes: 2 additions & 2 deletions lib/grape/dsl/inside_route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def status(status = nil)
when Symbol
raise ArgumentError, "Status code :#{status} is invalid." unless Rack::Utils::SYMBOL_TO_STATUS_CODE.keys.include?(status)
@status = Rack::Utils.status_code(status)
when Fixnum
when Integer
@status = status
when nil
return @status if @status
Expand All @@ -135,7 +135,7 @@ def status(status = nil)
200
end
else
raise ArgumentError, 'Status code must be Fixnum or Symbol.'
raise ArgumentError, 'Status code must be Integer or Symbol.'
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/grape/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ class DummyFormatClass
end

get '/', id: '32'
expect(last_response.body).to eql 'first 32:Fixnum second'
expect(last_response.body).to eql 'first 32:Integer second'
end

it 'adds a after filter' do
Expand Down Expand Up @@ -2506,7 +2506,7 @@ def static
end
end
describe 'status' do
it 'can be set to arbitrary Fixnum value' do
it 'can be set to arbitrary Integer value' do
subject.get '/foo' do
status 210
end
Expand Down
6 changes: 3 additions & 3 deletions spec/grape/dsl/inside_route_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ def initialize
.to raise_error(ArgumentError, 'Status code :foo_bar is invalid.')
end

it 'accepts unknown Fixnum status codes' do
it 'accepts unknown Integer status codes' do
expect { subject.status 210 }.to_not raise_error
end

it 'raises error if status is not a fixnum or symbol' do
it 'raises error if status is not a integer or symbol' do
expect { subject.status Object.new }
.to raise_error(ArgumentError, 'Status code must be Fixnum or Symbol.')
.to raise_error(ArgumentError, 'Status code must be Integer or Symbol.')
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/grape/dsl/request_response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def self.imbue(key, value)
end

it 'abort if :with option value is not Symbol, String or Proc' do
expect { subject.rescue_from :all, with: 1234 }.to raise_error(ArgumentError, 'with: Fixnum, expected Symbol, String or Proc')
expect { subject.rescue_from :all, with: 1234 }.to raise_error(ArgumentError, 'with: Integer, expected Symbol, String or Proc')
end

it 'abort if both :with option and block are passed' do
Expand Down
16 changes: 8 additions & 8 deletions spec/grape/validations/validators/allow_blank_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class API < Grape::API
get '/allow_float_blank'

params do
requires :val, type: Fixnum, allow_blank: true
requires :val, type: Integer, allow_blank: true
end
get '/allow_fixnum_blank'
get '/allow_integer_blank'

params do
requires :val, type: Symbol, allow_blank: true
Expand Down Expand Up @@ -173,9 +173,9 @@ class API < Grape::API
get '/allow_float_blank'

params do
requires :val, type: Fixnum, allow_blank: true
requires :val, type: Integer, allow_blank: true
end
get '/allow_fixnum_blank'
get '/allow_integer_blank'

params do
requires :val, type: Symbol, allow_blank: true
Expand Down Expand Up @@ -345,8 +345,8 @@ def app
expect(last_response.status).to eq(200)
end

it 'accepts empty when fixnum allow_blank' do
get '/custom_message/allow_fixnum_blank', val: ''
it 'accepts empty when integer allow_blank' do
get '/custom_message/allow_integer_blank', val: ''
expect(last_response.status).to eq(200)
end
end
Expand Down Expand Up @@ -483,8 +483,8 @@ def app
expect(last_response.status).to eq(200)
end

it 'accepts empty when fixnum allow_blank' do
get '/allow_fixnum_blank', val: ''
it 'accepts empty when integer allow_blank' do
get '/allow_integer_blank', val: ''
expect(last_response.status).to eq(200)
end
end
Expand Down
14 changes: 7 additions & 7 deletions spec/grape/validations/validators/coerce_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class User

get '/int', int: '45'
expect(last_response.status).to eq(200)
expect(last_response.body).to eq('Fixnum')
expect(last_response.body).to eq('Integer')
end

context 'Array' do
Expand All @@ -189,7 +189,7 @@ class User

get '/array', arry: %w(1 2 3)
expect(last_response.status).to eq(200)
expect(last_response.body).to eq('Fixnum')
expect(last_response.body).to eq('Integer')
end

it 'Array of Bools' do
Expand Down Expand Up @@ -238,7 +238,7 @@ class User

get '/set', set: Set.new([1, 2, 3, 4]).to_a
expect(last_response.status).to eq(200)
expect(last_response.body).to eq('Fixnum')
expect(last_response.body).to eq('Integer')
end

it 'Set of Bools' do
Expand Down Expand Up @@ -326,7 +326,7 @@ class User

get '/int', integers: { int: '45' }
expect(last_response.status).to eq(200)
expect(last_response.body).to eq('Fixnum')
expect(last_response.body).to eq('Integer')
end
end

Expand Down Expand Up @@ -525,11 +525,11 @@ class User

get '/', splines: '{"x":"1","y":"woof"}'
expect(last_response.status).to eq(200)
expect(last_response.body).to eq('Fixnum.String')
expect(last_response.body).to eq('Integer.String')

get '/', splines: '[{"x":1,"y":2},{"x":1,"y":"quack"}]'
expect(last_response.status).to eq(200)
expect(last_response.body).to eq('Fixnum.Fixnum')
expect(last_response.body).to eq('Integer.Integer')

get '/', splines: '{"x":"4","y":"woof"}'
expect(last_response.status).to eq(400)
Expand Down Expand Up @@ -576,7 +576,7 @@ class User

get '/', a: '5'
expect(last_response.status).to eq(200)
expect(last_response.body).to eq('Fixnum')
expect(last_response.body).to eq('Integer')

get '/', a: 'anything else'
expect(last_response.status).to eq(200)
Expand Down

0 comments on commit 3b41eeb

Please sign in to comment.