Sha256: 337a9cd303d8c7f3567df79f9373fd2fed3a264c1dfc69d05b2b2ddc5c31727e

Contents?: true

Size: 786 Bytes

Versions: 1

Compression:

Stored size: 786 Bytes

Contents

require 'capybara'
require 'capybara/dsl'

module Capybara
  module Json
    def self.included(base)
      base.__send__(:include, Capybara::DSL) unless base < Capybara or base < Capybara::DSL 
      base.extend(self)
    end

    %w[ get delete ].each do |method|
      module_eval %{
        def #{method}(path, params = {}, env = {})
          page.driver.#{method}(path, params, env)
        end
      }
    end

    %w[ post put ].each do |method|
      module_eval %{
        def #{method}(path, json, env = {})
          page.driver.#{method}(path, json, env)
        end
      }
    end
  end

  module RackTestJson
    autoload :Driver, 'capybara/rack_test_json/driver'
  end
end

Capybara.register_driver :rack_test_json do |app|
  Capybara::RackTestJson::Driver.new(app)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capybara-json-0.0.1 lib/capybara/json.rb