spec/parameter_transformations_spec.rb in sinatra-param-1.2.2 vs spec/parameter_transformations_spec.rb in sinatra-param-1.3.0

- old
+ new

@@ -2,34 +2,41 @@ describe 'Parameter Transformations' do describe 'default' do it 'sets a default value when none is given' do get('/default') do |response| - response.status.should == 200 - JSON.parse(response.body)['sort'].should == 'title' + expect(response.status).to eql 200 + expect(JSON.parse(response.body)['sort']).to eql 'title' end end + it 'sets a default value from an empty hash' do + get('/default/hash') do |response| + expect(response.status).to eql 200 + expect(JSON.parse(response.body)['attributes']).to eql Hash.new + end + end + it 'sets a default value from a proc' do get('/default/proc') do |response| - response.status.should == 200 - JSON.parse(response.body)['year'].should == 2014 + expect(response.status).to eql 200 + expect(JSON.parse(response.body)['year']).to eql 2014 end end end describe 'transform' do it 'transforms the input using to_proc' do get('/transform', order: 'asc') do |response| - response.status.should == 200 - JSON.parse(response.body)['order'].should == 'ASC' + expect(response.status).to eql 200 + expect(JSON.parse(response.body)['order']).to eql 'ASC' end end it 'skips transformations when the value is nil' do get('/transform/required') do |response| - response.status.should == 400 - JSON.parse(response.body)['message'].should eq('Invalid Parameter: order') + expect(response.status).to eql 400 + expect(JSON.parse(response.body)['message']).to eq('Invalid Parameter: order') end end end end