Class: Spec::Client::Http::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/spec/client/http/transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Transaction

Returns a new instance of Transaction.



9
10
11
12
# File 'lib/spec/client/http/transaction.rb', line 9

def initialize(request)
  @request = request
  @response = nil
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



7
8
9
# File 'lib/spec/client/http/transaction.rb', line 7

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response.



7
8
9
# File 'lib/spec/client/http/transaction.rb', line 7

def response
  @response
end

Instance Method Details

#executeObject



14
15
16
17
# File 'lib/spec/client/http/transaction.rb', line 14

def execute
  @response = request.execute
  self
end

#redirect?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/spec/client/http/transaction.rb', line 23

def redirect?
  (300..399).include? @response.code
end

#success?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/spec/client/http/transaction.rb', line 19

def success?
  (200..299).include? @response.code
end