shokkenki-consumer 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/shokkenki/consumer/dsl/order.rb +4 -10
- data/lib/shokkenki/consumer/model/interaction.rb +7 -5
- data/lib/shokkenki/consumer/model/patronage.rb +3 -3
- data/lib/shokkenki/consumer/model/request.rb +26 -0
- data/lib/shokkenki/consumer/rspec/rspec_configuration.rb +5 -0
- data/lib/shokkenki/consumer/version.rb +1 -1
- metadata +7 -6
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'shokkenki/term/core_ext'
|
2
1
|
require_relative '../model/interaction'
|
3
2
|
require_relative '../model/fixture'
|
3
|
+
require_relative '../model/request'
|
4
4
|
require_relative 'http_methods'
|
5
5
|
require_relative 'term_dsl'
|
6
6
|
|
@@ -22,13 +22,7 @@ module Shokkenki
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def receive details
|
25
|
-
|
26
|
-
raise "The request method must be a symbol." unless @request_details = details[:method].is_a?(Symbol)
|
27
|
-
|
28
|
-
raise "No request path has been specified." unless details.has_key?(:path)
|
29
|
-
raise "The request path must be a string." unless details[:path].is_a?(String)
|
30
|
-
|
31
|
-
@request_details = details
|
25
|
+
@request_details = Shokkenki::Consumer::Model::Request.new details
|
32
26
|
self
|
33
27
|
end
|
34
28
|
|
@@ -53,8 +47,8 @@ module Shokkenki
|
|
53
47
|
def to_interaction
|
54
48
|
Shokkenki::Consumer::Model::Interaction.new(
|
55
49
|
:label => @interaction_label,
|
56
|
-
:request => @request_details
|
57
|
-
:response => @response_details
|
50
|
+
:request => @request_details,
|
51
|
+
:response => @response_details,
|
58
52
|
:fixtures => @fixtures
|
59
53
|
)
|
60
54
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'shokkenki/term/core_ext'
|
2
|
+
|
1
3
|
module Shokkenki
|
2
4
|
module Consumer
|
3
5
|
module Model
|
@@ -6,9 +8,9 @@ module Shokkenki
|
|
6
8
|
attr_reader :label, :request, :response, :time, :fixtures
|
7
9
|
|
8
10
|
def initialize attributes
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@response = attributes[:response]
|
11
|
+
@request = attributes[:request].to_shokkenki_term
|
12
|
+
@label = attributes[:label] || attributes[:request].label
|
13
|
+
@response = attributes[:response].to_shokkenki_term
|
12
14
|
@fixtures = attributes[:fixtures]
|
13
15
|
@time = Time.now
|
14
16
|
end
|
@@ -17,9 +19,9 @@ module Shokkenki
|
|
17
19
|
hash = {
|
18
20
|
:request => @request.to_hash,
|
19
21
|
:response => @response.to_hash,
|
20
|
-
:time => @time.utc.iso8601
|
22
|
+
:time => @time.utc.iso8601,
|
23
|
+
:label => @label
|
21
24
|
}
|
22
|
-
hash.merge!(:label => @label) if @label
|
23
25
|
hash.merge!(:fixtures => @fixtures.map{ |f| f.to_hash }) if @fixtures
|
24
26
|
hash
|
25
27
|
end
|
@@ -10,11 +10,11 @@ module Shokkenki
|
|
10
10
|
def initialize attributes
|
11
11
|
@provider = attributes[:provider]
|
12
12
|
@consumer = attributes[:consumer]
|
13
|
-
@interactions =
|
13
|
+
@interactions = {}
|
14
14
|
end
|
15
15
|
|
16
16
|
def add_interaction interaction
|
17
|
-
@interactions
|
17
|
+
@interactions[interaction.label] = interaction
|
18
18
|
@provider.stub_interaction interaction
|
19
19
|
end
|
20
20
|
|
@@ -22,7 +22,7 @@ module Shokkenki
|
|
22
22
|
Ticket.new(
|
23
23
|
:consumer => @consumer,
|
24
24
|
:provider => @provider,
|
25
|
-
:interactions => @interactions
|
25
|
+
:interactions => @interactions.values
|
26
26
|
)
|
27
27
|
end
|
28
28
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Shokkenki
|
2
|
+
module Consumer
|
3
|
+
module Model
|
4
|
+
class Request < Hash
|
5
|
+
|
6
|
+
def initialize attributes
|
7
|
+
raise "No request method has been specified." unless attributes.has_key?(:method)
|
8
|
+
raise "The request method must be a symbol." unless attributes[:method].is_a?(Symbol)
|
9
|
+
|
10
|
+
raise "No request path has been specified." unless attributes.has_key?(:path)
|
11
|
+
raise "The request path must be a string." unless attributes[:path].is_a?(String)
|
12
|
+
merge! attributes
|
13
|
+
end
|
14
|
+
|
15
|
+
def label
|
16
|
+
query = " ? #{self[:query].to_json}" if self[:query]
|
17
|
+
headers = " headers: #{self[:headers].to_json}" if self[:headers]
|
18
|
+
"#{self[:method]} #{self[:path]}#{query}#{headers}"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
@@ -4,6 +4,11 @@ require 'rspec'
|
|
4
4
|
|
5
5
|
RSpec.configure do |config|
|
6
6
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
7
|
+
|
8
|
+
if config.respond_to?(:backtrace_inclusion_patterns)
|
9
|
+
config.backtrace_inclusion_patterns << /shokkenki\-consumer/
|
10
|
+
end
|
11
|
+
|
7
12
|
config.include(
|
8
13
|
Shokkenki::Consumer::RSpec::ExampleGroupBinding,
|
9
14
|
:shokkenki_consumer => lambda{ |x| true }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shokkenki-consumer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-02
|
12
|
+
date: 2014-03-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - ! '>='
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: 1.
|
101
|
+
version: 1.1.0
|
102
102
|
type: :runtime
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -106,7 +106,7 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 1.
|
109
|
+
version: 1.1.0
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
name: rack
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,6 +220,7 @@ files:
|
|
220
220
|
- lib/shokkenki/consumer/model/interaction.rb
|
221
221
|
- lib/shokkenki/consumer/model/patronage.rb
|
222
222
|
- lib/shokkenki/consumer/model/provider.rb
|
223
|
+
- lib/shokkenki/consumer/model/request.rb
|
223
224
|
- lib/shokkenki/consumer/model/role.rb
|
224
225
|
- lib/shokkenki/consumer/model/simplification.rb
|
225
226
|
- lib/shokkenki/consumer/model/ticket.rb
|
@@ -265,11 +266,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
265
266
|
version: '0'
|
266
267
|
segments:
|
267
268
|
- 0
|
268
|
-
hash:
|
269
|
+
hash: 268067568248106092
|
269
270
|
requirements: []
|
270
271
|
rubyforge_project:
|
271
272
|
rubygems_version: 1.8.23
|
272
273
|
signing_key:
|
273
274
|
specification_version: 3
|
274
|
-
summary: shokkenki-consumer-1.0
|
275
|
+
summary: shokkenki-consumer-1.1.0
|
275
276
|
test_files: []
|