spec/support/driver_examples.rb in capybara-json-0.2.2 vs spec/support/driver_examples.rb in capybara-json-0.2.3

- old
+ new

@@ -23,15 +23,32 @@ end describe '#body' do it "should return json reponses" do @driver.visit('/') + @driver.body.should be_a(Hash) @driver.body.should include('Hello world!') end # pending encoding end + context '#source' do + it "should return raw reponse" do + @driver.visit('/') + @driver.source.should be_a(String) + @driver.source.should include('Hello world!') + end + end + + describe '#json' do + it "should return json reponses" do + @driver.visit('/') + @driver.json.should be_a(Hash) + @driver.json.should include('Hello world!') + end + # pending encoding + end # TODO: find by jsonpath? end shared_examples_for 'driver with header support' do it "should make headers available through response_headers" do @@ -90,11 +107,11 @@ end end shared_examples_for 'driver for client error' do it 'should not raise exception' do - expect { @driver.get('/errors/400') }.should_not raise_exception + expect { @driver.get('/errors/400') }.not_to raise_exception end it 'should make the status code available' do @driver.get('/errors/400') @driver.status_code.should == 400 @@ -109,23 +126,23 @@ @driver.get('/errors/400') @driver.body['status_code'].should == 400 end it 'should raise error using bang!' do - expect { @driver.get!('/errors/400') }.should raise_exception(Capybara::Json::Error) + expect { @driver.get!('/errors/400') }.to raise_exception(Capybara::Json::Error) end end shared_examples_for 'driver for server error' do it 'should not raise exception' do - expect { @driver.get('/errors/500') }.should_not raise_exception + expect { @driver.get('/errors/500') }.not_to raise_exception end it 'should make the status_code available' do @driver.get('/errors/500') @driver.status_code.should == 500 end it 'should raise error using bang!' do - expect { @driver.get!('/errors/500') }.should raise_exception(Capybara::Json::Error) + expect { @driver.get!('/errors/500') }.to raise_exception(Capybara::Json::Error) end end