Top Level Namespace
Defined Under Namespace
Modules: ArtirixDataModels
Instance Method Summary collapse
-
#fake_mode_for(model_name) ⇒ Object
:nocov:.
-
#given_gateway_config(connection_url = nil) ⇒ Object
:nocov:.
- #mock_gateway_delete_not_found_response(**params) ⇒ Object
-
#mock_gateway_delete_response(**params) ⇒ Object
DELETE.
- #mock_gateway_get_not_found_response(**params) ⇒ Object
-
#mock_gateway_get_response(**params) ⇒ Object
GET.
- #mock_gateway_not_found_response(method:, path:, body: nil, json_body: true, timeout: nil, authorization_bearer: nil, authorization_token_hash: nil, gateway: nil, headers: nil) ⇒ Object
- #mock_gateway_post_not_found_response(**params) ⇒ Object
-
#mock_gateway_post_response(**params) ⇒ Object
POST.
- #mock_gateway_put_not_found_response(**params) ⇒ Object
-
#mock_gateway_put_response(**params) ⇒ Object
PUT.
- #mock_gateway_response(response:, method:, path:, body: nil, json_body: true, timeout: nil, authorization_bearer: nil, authorization_token_hash: nil, gateway: nil, headers: nil) ⇒ Object
Instance Method Details
#fake_mode_for(model_name) ⇒ Object
:nocov:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/artirix_data_models/spec_support/fake_mode.rb', line 2 def fake_mode_for(model_name) before(:each) do config = ArtirixDataModels.configuration # fix in case of SimpleConfig (mocking SimpleConfig with rspec explodes if not) if defined?(SimpleConfig) && config.kind_of?(SimpleConfig::Config) SimpleConfig::Config.class_eval { public :singleton_class } end dfm = config.try(:data_fake_mode) || double allow(dfm).to receive(model_name).and_return(true) allow(config).to receive(:data_fake_mode).and_return(dfm) allow(config).to receive(:debug_model_mode_enabled).and_return(true) end end |
#given_gateway_config(connection_url = nil) ⇒ Object
:nocov:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/artirix_data_models/spec_support/gateway_mock.rb', line 2 def given_gateway_config(connection_url = nil) connection_url ||= 'http://example.com/other' before(:each) do config = ArtirixDataModels.configuration # fix in case of SimpleConfig (mocking SimpleConfig with rspec explodes if not) if defined?(SimpleConfig) && config.kind_of?(SimpleConfig::Config) SimpleConfig::Config.class_eval { public :singleton_class } end dg = config.try(:data_gateway) || double allow(dg).to receive(:url).and_return(connection_url) allow(config).to receive(:data_gateway).and_return(dg) end end |
#mock_gateway_delete_not_found_response(**params) ⇒ Object
114 115 116 |
# File 'lib/artirix_data_models/spec_support/gateway_mock.rb', line 114 def mock_gateway_delete_not_found_response(**params) mock_gateway_not_found_response method: :delete, **params end |
#mock_gateway_delete_response(**params) ⇒ Object
DELETE
110 111 112 |
# File 'lib/artirix_data_models/spec_support/gateway_mock.rb', line 110 def mock_gateway_delete_response(**params) mock_gateway_response method: :delete, **params end |
#mock_gateway_get_not_found_response(**params) ⇒ Object
87 88 89 |
# File 'lib/artirix_data_models/spec_support/gateway_mock.rb', line 87 def mock_gateway_get_not_found_response(**params) mock_gateway_not_found_response method: :get, **params end |
#mock_gateway_get_response(**params) ⇒ Object
GET
83 84 85 |
# File 'lib/artirix_data_models/spec_support/gateway_mock.rb', line 83 def mock_gateway_get_response(**params) mock_gateway_response method: :get, **params end |
#mock_gateway_not_found_response(method:, path:, body: nil, json_body: true, timeout: nil, authorization_bearer: nil, authorization_token_hash: nil, gateway: nil, headers: nil) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/artirix_data_models/spec_support/gateway_mock.rb', line 51 def mock_gateway_not_found_response(method:, path:, body: nil, json_body: true, timeout: nil, authorization_bearer: nil, authorization_token_hash: nil, gateway: nil, headers: nil) gateway ||= ArtirixDataModels::DAORegistry.gateway params_hash = { path: path, body: body, json_body: json_body, timeout: timeout, authorization_bearer: , authorization_token_hash: , headers: headers } allow(gateway).to receive(:perform).with(method, params_hash).and_raise ArtirixDataModels::DataGateway::NotFound # check with body already parsed unless body.nil? body = body.kind_of?(String) ? body : body.to_json allow(gateway).to receive(:perform).with(method, params_hash.merge(body: body)).and_raise ArtirixDataModels::DataGateway::NotFound end end |
#mock_gateway_post_not_found_response(**params) ⇒ Object
96 97 98 |
# File 'lib/artirix_data_models/spec_support/gateway_mock.rb', line 96 def mock_gateway_post_not_found_response(**params) mock_gateway_not_found_response method: :post, **params end |
#mock_gateway_post_response(**params) ⇒ Object
POST
92 93 94 |
# File 'lib/artirix_data_models/spec_support/gateway_mock.rb', line 92 def mock_gateway_post_response(**params) mock_gateway_response method: :post, **params end |
#mock_gateway_put_not_found_response(**params) ⇒ Object
105 106 107 |
# File 'lib/artirix_data_models/spec_support/gateway_mock.rb', line 105 def mock_gateway_put_not_found_response(**params) mock_gateway_not_found_response method: :put, **params end |
#mock_gateway_put_response(**params) ⇒ Object
PUT
101 102 103 |
# File 'lib/artirix_data_models/spec_support/gateway_mock.rb', line 101 def mock_gateway_put_response(**params) mock_gateway_response method: :put, **params end |
#mock_gateway_response(response:, method:, path:, body: nil, json_body: true, timeout: nil, authorization_bearer: nil, authorization_token_hash: nil, gateway: nil, headers: nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/artirix_data_models/spec_support/gateway_mock.rb', line 20 def mock_gateway_response(response:, method:, path:, body: nil, json_body: true, timeout: nil, authorization_bearer: nil, authorization_token_hash: nil, gateway: nil, headers: nil) gateway ||= ArtirixDataModels::DAORegistry.gateway params_hash = { path: path, body: body, json_body: json_body, timeout: timeout, authorization_bearer: , authorization_token_hash: , headers: headers } allow(gateway).to receive(:perform).with(method, params_hash).and_return response # check with body already parsed unless body.nil? body = body.kind_of?(String) ? body : body.to_json allow(gateway).to receive(:perform).with(method, params_hash.merge(body: body)).and_return response end end |