Sha256: cc3f53d75890222c10ae22cd91263e472bbf1e90d6da84d41123b9a3f1128a41

Contents?: true

Size: 989 Bytes

Versions: 2

Compression:

Stored size: 989 Bytes

Contents

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!' }
    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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capybara-json-0.0.2 spec/capybara/json_spec.rb
capybara-json-0.0.1 spec/capybara/json_spec.rb