diff --git a/lib/capybara/session.rb b/lib/capybara/session.rb index 97994def..8608e247 100644 --- a/lib/capybara/session.rb +++ b/lib/capybara/session.rb @@ -29,7 +29,7 @@ module Capybara end def response_headers - driver.response.headers + driver.response_headers end def visit(path) @@ -99,7 +99,7 @@ module Capybara end def body - driver.response.body + driver.body end def has_content?(content) diff --git a/spec/session/celerity_session_spec.rb b/spec/session/culerity_session_spec.rb similarity index 89% rename from spec/session/celerity_session_spec.rb rename to spec/session/culerity_session_spec.rb index 11e3adfe..958308b9 100644 --- a/spec/session/celerity_session_spec.rb +++ b/spec/session/culerity_session_spec.rb @@ -8,7 +8,7 @@ describe Capybara::Session do describe '#driver' do it "should be a rack test driver" do - @session.driver.should be_an_instance_of(Capybara::Driver::Celerity) + @session.driver.should be_an_instance_of(Capybara::Driver::Culerity) end end @@ -20,5 +20,6 @@ describe Capybara::Session do it_should_behave_like "session" it_should_behave_like "session with javascript support" + it_should_behave_like "session with headers support" end end diff --git a/spec/session/rack_test_session_spec.rb b/spec/session/rack_test_session_spec.rb index 9df04d52..43395278 100644 --- a/spec/session/rack_test_session_spec.rb +++ b/spec/session/rack_test_session_spec.rb @@ -20,5 +20,6 @@ describe Capybara::Session do it_should_behave_like "session" it_should_behave_like "session without javascript support" + it_should_behave_like "session with headers support" end end diff --git a/spec/session/selenium_session_spec.rb b/spec/session/selenium_session_spec.rb index 3903de16..53362a3d 100644 --- a/spec/session/selenium_session_spec.rb +++ b/spec/session/selenium_session_spec.rb @@ -20,5 +20,6 @@ describe Capybara::Session do it_should_behave_like "session" it_should_behave_like "session with javascript support" + it_should_behave_like "session without headers support" end end diff --git a/spec/session_with_headers_support_spec.rb b/spec/session_with_headers_support_spec.rb new file mode 100644 index 00000000..aae40b4c --- /dev/null +++ b/spec/session_with_headers_support_spec.rb @@ -0,0 +1,13 @@ +require File.expand_path('spec_helper', File.dirname(__FILE__)) + + +shared_examples_for "session with headers support" do + + describe '#response_headers' do + it "should return response headers" do + @session.visit('/with_simple_html') + @session.response_headers['Content-Type'].should == 'text/html' + end + end + +end diff --git a/spec/session_without_headers_support_spec.rb b/spec/session_without_headers_support_spec.rb new file mode 100644 index 00000000..13ea6bdc --- /dev/null +++ b/spec/session_without_headers_support_spec.rb @@ -0,0 +1,15 @@ +require File.expand_path('spec_helper', File.dirname(__FILE__)) + +require 'nokogiri' + +shared_examples_for "session without headers support" do + describe "#evaluate_script" do + before{ @session.visit('/with_simple_html') } + it "should raise an error" do + running { + @session.response_headers + }.should raise_error(Capybara::NotSupportedByDriverError) + end + end +end + \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 31bb20d2..bddcc19b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,4 +12,7 @@ Dir[File.dirname(__FILE__)+'/dsl/*'].each { |group| } require 'session_with_javascript_support_spec' require 'session_without_javascript_support_spec' +require 'session_with_headers_support_spec' +require 'session_without_headers_support_spec' + alias :running :lambda