Class: Net::HTTP

Inherits:
Protocol
  • Object
show all
Defined in:
lib/foundation_api/test_helper.rb,
lib/foundation_api/test_helper.rb

Overview

Mock around Net::HTTP so we don’t need a real connection. We just verify whether the correct data is posted and return know test data

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.raw_post_bodyObject



34
35
36
# File 'lib/foundation_api/test_helper.rb', line 34

def self.raw_post_body
  @raw_post_body
end

.raw_post_body=(body) ⇒ Object



30
31
32
# File 'lib/foundation_api/test_helper.rb', line 30

def self.raw_post_body=(body)
  @raw_post_body = body
end

.raw_post_pathObject



42
43
44
# File 'lib/foundation_api/test_helper.rb', line 42

def self.raw_post_path
  @raw_post_path
end

.raw_post_path=(path) ⇒ Object



38
39
40
# File 'lib/foundation_api/test_helper.rb', line 38

def self.raw_post_path=(path)
  @raw_post_path = path
end

.raw_response_dataObject



22
23
24
# File 'lib/foundation_api/test_helper.rb', line 22

def self.raw_response_data
  @raw_response_data
end

.raw_response_data=(data) ⇒ Object



26
27
28
# File 'lib/foundation_api/test_helper.rb', line 26

def self.raw_response_data=(data)
  @raw_response_data = data
end

Instance Method Details

#connectObject



9
10
# File 'lib/foundation_api/test_helper.rb', line 9

def connect
end

#post(path, body, headers = {}) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/foundation_api/test_helper.rb', line 46

def post(path, body, headers = {})
  res = Net::HTTPSuccess.new('1.2', '200', 'OK')
  self.class.raw_post_path = path
  self.class.raw_post_body = body
  res.body = self.class.raw_response_data
  res
end