spec/support/driver_examples.rb in capybara-json-0.2.0 vs spec/support/driver_examples.rb in capybara-json-0.2.1
- old
+ new
@@ -52,10 +52,18 @@
@driver.get "/redirect"
URI.parse(@driver.current_url).path.should == "/landed"
end
end
+shared_examples_for "driver not to follow redirect" do
+ it "should not follow redirect" do
+ @driver.get "/redirect"
+ @driver.status_code.should == 302
+ URI.parse(@driver.current_url).path.should == "/redirect"
+ 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"
@@ -63,17 +71,17 @@
it 'should set content length' do
json = { :some => :args }
@driver.__send__(method, '/env', json)
- @driver.body['content_length'].to_i.should == MultiJson.encode(json).length
+ @driver.body['content_length'].to_i.should == MultiJson.dump(json).length
end
it 'should post body' do
json = { :some => :args }
@driver.__send__(method, '/env', json)
- @driver.body['rack.input'].should == MultiJson.encode(json)
+ @driver.body['rack.input'].should == MultiJson.dump(json)
end
end
end
shared_examples_for 'driver for client error' do