spec/support/driver_examples.rb in capybara-json-0.1.2 vs spec/support/driver_examples.rb in capybara-json-0.2.0

- old
+ new

@@ -45,27 +45,33 @@ @driver.get('/env', {}, { 'X-Custom-Header' => 'custom header'}) @driver.body['headers']['X_CUSTOM_HEADER'].should == 'custom header' end end +shared_examples_for "driver with redirect support" do + it "should update current_url" do + @driver.get "/redirect" + URI.parse(@driver.current_url).path.should == "/landed" + 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" end - + 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 end - + it 'should post body' do json = { :some => :args } - + @driver.__send__(method, '/env', json) @driver.body['rack.input'].should == MultiJson.encode(json) end end end