Sha256: 6a6d386dd254994320552842a463c63fe86208308a98bba84cbac62e27934a84

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

# This is a shim/monkey-path for handling engine routes in Rails 3
# http://blog.pivotal.io/labs/labs/writing-rails-engine-rspec-controller-tests

module EngineControllerTestMonkeyPatch
  def get(action, parameters = nil, session = nil, flash = nil)
    process_action(action, "GET", parameters, session, flash)
  end

  # Executes a request simulating POST HTTP method and set/volley the response
  def post(action, parameters = nil, session = nil, flash = nil)
    process_action(action, "POST", parameters, session, flash)
  end

  # Executes a request simulating PUT HTTP method and set/volley the response
  def put(action, parameters = nil, session = nil, flash = nil)
    process_action(action, "PUT", parameters, session, flash)
  end

  # Executes a request simulating DELETE HTTP method and set/volley the response
  def delete(action, parameters = nil, session = nil, flash = nil)
    process_action(action, "DELETE", parameters, session, flash)
  end

  private

  def process_action(action, method = "GET", parameters = nil, session = nil, flash = nil)
    parameters ||= {}
    process(action, method, parameters.merge!(:use_route => :applicants), session, flash)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
applicants-0.11.0 spec/support/engine_controller_test_monkey_path.rb