Sha256: 42bc9c897abae5a10733379081cdf6d2e1f00cce94e6cb7e889d717e1bc1e3eb

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

[ :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

  describe Capybara::Json do
    include described_class
    
    before(:all) do
      Capybara.app = JsonTestApp
      Capybara.current_driver = driver
    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!' }
      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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capybara-json-0.1.1 spec/capybara/json_spec.rb
capybara-json-0.1.0 spec/capybara/json_spec.rb
capybara-json-0.0.3 spec/capybara/json_spec.rb