erroneous-api 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,12 +7,16 @@ module ErroneousAPI
7
7
  @base_url = base_url
8
8
  end
9
9
 
10
- def mock!(backend)
11
- self.connection.backend = backend
10
+ class << self
11
+ attr_accessor :mock_backend
12
+ end
13
+
14
+ def self.mock!(backend)
15
+ @mock_backend = backend
12
16
  end
13
17
 
14
18
  def connection
15
- @connection ||= EY::ApiHMAC::BaseConnection.new
19
+ @connection ||= setup_connection
16
20
  end
17
21
 
18
22
  def parse_deploy_fail(text)
@@ -29,5 +33,16 @@ module ErroneousAPI
29
33
  @details = json_response['details']
30
34
  end
31
35
  end
36
+
37
+ private
38
+
39
+ def setup_connection
40
+ connection = EY::ApiHMAC::BaseConnection.new
41
+ if Client.mock_backend
42
+ connection.backend = Client.mock_backend
43
+ end
44
+ connection
45
+ end
46
+
32
47
  end
33
48
  end
@@ -10,10 +10,17 @@ module ErroneousAPI
10
10
  attr_accessor :mapper
11
11
  end
12
12
 
13
+ def self.mock!
14
+ require 'erroneous-api/fake'
15
+ require 'erroneous-api/client'
16
+ self.mapper = ErroneousAPI::Fake
17
+ ErroneousAPI::Client.mock!(self)
18
+ end
19
+
13
20
  post '/parse_deploy_fail' do
14
21
  deploy_log = JSON.parse(request.body.read)["deploy_log"]
15
22
  content_type :json
16
- result = Server.mapper.parse_deploy_fail(deploy_log)
23
+ result = ErroneousAPI::Server.mapper.parse_deploy_fail(deploy_log)
17
24
  {
18
25
  :lines => (result[:lines] or raise "Expected parse_deploy_fail to return which :lines (empty array allowed)").to_a,
19
26
  :details => (result[:details] or raise "Expected parse_deploy_fail to return the :details (empty string allowed)"),
@@ -1,3 +1,3 @@
1
1
  module ErroneousAPI
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erroneous-api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jacob Burkhart