spec/support/driver_examples.rb in capybara-json-0.1.0 vs spec/support/driver_examples.rb in capybara-json-0.1.1
- old
+ new
@@ -38,11 +38,18 @@
@driver.visit('/')
@driver.response_headers['Content-Type'].should =~ /^application\/json/
end
end
+shared_examples_for 'driver with custom header support' do
+ it "should send custom header" do
+ @driver.get('/env', {}, { 'X-Custom-Header' => 'custom header'})
+ @driver.body['headers']['X_CUSTOM_HEADER'].should == 'custom header'
+ end
+end
+
%w[ post put ].each do |method|
shared_examples_for "driver to #{method} json" do
it 'should set content type as json to request' do
@driver.__send__(method, '/env', {})
@driver.body['content_type'].should =~ %r"^application/json"
@@ -81,17 +88,25 @@
it 'should make the body available' do
@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)
+ 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
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)
end
end