spec/capybara/json_spec.rb in capybara-json-0.0.2 vs spec/capybara/json_spec.rb in capybara-json-0.0.3

- old
+ new

@@ -1,43 +1,45 @@ require 'spec_helper' -describe "to require 'capybara/json'" do - it 'should register driver' do - Capybara.drivers.should have_key(:rack_test_json) - end -end - -describe Capybara::Json do - include described_class - - before(:all) do - Capybara.app = JsonTestApp - Capybara.current_driver = :rack_test_json - end - - after(:all) do - Capybara.app = nil - Capybara.current_driver = Capybara.default_driver - end - - %w[ get delete ].each do |method| - it "register #{method}" do - __send__(method, '/') - body.should == { 'Hello world!' => 'Hello world!' } +[ :rack_test_json, :httpclient_json ].each do |driver| + describe "to require 'capybara/json'" do + it "should register driver #{driver}" do + Capybara.drivers.should have_key(driver) end end - %w[ post put ].each do |method| - it "register #{method}" do - __send__(method, '/', {}) - body.should == { 'Hello world!' => 'Hello world!' } + describe Capybara::Json do + include described_class + + before(:all) do + Capybara.app = JsonTestApp + Capybara.current_driver = driver end - - it "#{method} send json" do - json = { "some" => "args" } - __send__(method, '/env', json) - - body['content_type'].should =~ %r"application/json" - body['rack.input'].should == MultiJson.encode(json) + + after(:all) do + Capybara.app = nil + Capybara.current_driver = Capybara.default_driver + end + + %w[ get delete ].each do |method| + it "register #{method}" do + __send__(method, '/') + body.should == { 'Hello world!' => 'Hello world!' } + end + end + + %w[ post put ].each do |method| + it "register #{method}" do + __send__(method, '/', {}) + body.should == { 'Hello world!' => 'Hello world!' } + end + + it "#{method} send json" do + json = { "some" => "args" } + __send__(method, '/env', json) + + body['content_type'].should =~ %r"application/json" + body['rack.input'].should == MultiJson.encode(json) + end end end end