spec/grape/validations/default_spec.rb in grape-0.7.0 vs spec/grape/validations/default_spec.rb in grape-0.8.0
- old
+ new
@@ -72,52 +72,52 @@
ValidationsSpec::DefaultValidatorSpec::API
end
it 'set default value for optional param' do
get("/")
- last_response.status.should == 200
- last_response.body.should == { id: nil, type: 'default-type' }.to_json
+ expect(last_response.status).to eq(200)
+ expect(last_response.body).to eq({ id: nil, type: 'default-type' }.to_json)
end
it 'set default values for optional params' do
get("/user")
- last_response.status.should == 200
- last_response.body.should == { type1: 'default-type1', type2: 'default-type2' }.to_json
+ expect(last_response.status).to eq(200)
+ expect(last_response.body).to eq({ type1: 'default-type1', type2: 'default-type2' }.to_json)
end
it 'set default values for missing params in the request' do
get("/user?type2=value2")
- last_response.status.should == 200
- last_response.body.should == { type1: 'default-type1', type2: 'value2' }.to_json
+ expect(last_response.status).to eq(200)
+ expect(last_response.body).to eq({ type1: 'default-type1', type2: 'value2' }.to_json)
end
it 'set default values for optional params and allow to use required fields in the same time' do
get("/message?id=1")
- last_response.status.should == 200
- last_response.body.should == { id: '1', type1: 'default-type1', type2: 'default-type2' }.to_json
+ expect(last_response.status).to eq(200)
+ expect(last_response.body).to eq({ id: '1', type1: 'default-type1', type2: 'default-type2' }.to_json)
end
it 'sets lambda based defaults at the time of call' do
get("/numbers")
- last_response.status.should == 200
+ expect(last_response.status).to eq(200)
before = JSON.parse(last_response.body)
get("/numbers")
- last_response.status.should == 200
+ expect(last_response.status).to eq(200)
after = JSON.parse(last_response.body)
- before['non_random_number'].should == after['non_random_number']
- before['random_number'].should_not == after['random_number']
+ expect(before['non_random_number']).to eq(after['non_random_number'])
+ expect(before['random_number']).not_to eq(after['random_number'])
end
it 'set default values for optional grouped params' do
get('/group')
- last_response.status.should == 200
- last_response.body.should == { foo_bar: 'foo-bar' }.to_json
+ expect(last_response.status).to eq(200)
+ expect(last_response.body).to eq({ foo_bar: 'foo-bar' }.to_json)
end
it 'sets default values for grouped arrays' do
get('/array?array[][name]=name&array[][name]=name2&array[][with_default]=bar2')
- last_response.status.should == 200
- last_response.body.should == { array: [{ name: "name", with_default: "default" }, { name: "name2", with_default: "bar2" }] }.to_json
+ expect(last_response.status).to eq(200)
+ expect(last_response.body).to eq({ array: [{ name: "name", with_default: "default" }, { name: "name2", with_default: "bar2" }] }.to_json)
end
end