Sha256: 7524ade42c423bb8c21ef98d378531ba0236b5faf3e7973622dbde3cc94d0266

Contents?: true

Size: 773 Bytes

Versions: 7

Compression:

Stored size: 773 Bytes

Contents

class Rack::MockSession
  attr_writer :last_response

  def last_response
    @last_response
  end
end

class Rack::Test::Session
  class << self
    def http_action_with_async_catch(method_name)
      alias_method "#{method_name}_without_async_catch", method_name
      class_eval((<<-RUBY), __FILE__, __LINE__)
      def #{method_name}_with_async_catch(*args, &block)
        catch(:async) {return #{method_name}_without_async_catch(*args, &block)}
        nil
      end
      RUBY
      alias_method method_name, "#{method_name}_with_async_catch"
    end
  end

  def_delegators :@rack_mock_session, :last_response=

  http_action_with_async_catch :get
  http_action_with_async_catch :put
  http_action_with_async_catch :post
  http_action_with_async_catch :delete
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
honkster-js-test-server-0.2.10 spec/spec_helpers/mock_session.rb
honkster-js-test-server-0.2.9 spec/spec_helpers/mock_session.rb
js-test-server-0.2.8 spec/spec_helpers/mock_session.rb
js-test-server-0.2.7 spec/spec_helpers/mock_session.rb
js-test-server-0.2.6 spec/spec_helpers/mock_session.rb
js-test-server-0.2.1 spec/spec_helpers/mock_session.rb
js-test-server-0.2.0 spec/spec_helpers/mock_session.rb