ruby_event_store-rspec 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2aaf7916e409889b919cfb186ac2c7a0864658719a569138add1294941b66a6c
4
- data.tar.gz: 1d03da7f66c3c055f07eaf066ebb1c780c39fc222e37fa92e31ff23918a13272
3
+ metadata.gz: 8eb0afc118a3be2829fec2383858efaf7c8a1766a41db876e39969261b5dc017
4
+ data.tar.gz: a6c84fcff753ba1753eccda8029cff733885f4cd383bcd04a4976a591cf3c2d1
5
5
  SHA512:
6
- metadata.gz: 3b79ad1a3165e1355e3570a59242011570c39c47332a10947937d58b9f54881b65a9872b956736b5861840dbac5ff1ba21e3ea07e7c9238c62e2b1ac96504136
7
- data.tar.gz: c4419133a70833970e69672a0b105c5076357753e073e88b6eadfe361a64516ddc8fda6a97d76bbc0020772a43e891391d0e873081a9d804273921ec052a6cfd
6
+ metadata.gz: 6f7db18e2cef98b5af008f636bc04fbdbb89763eb5eec488fa9fdc439d95793329c34e8ce17d2b1f0bd5423a767772e2c1dfae34867e3ff8b87c5c7d9de1a44f
7
+ data.tar.gz: 28be5f30b48d48b8d643f75afde951a706a96fbac8b3d3472f8e890e42c2e2ba2b02e78f6fd5836982021d4b601f02eb98da09a09d13497830f898a0d6d35e07
data/README.md CHANGED
@@ -3,4 +3,3 @@
3
3
  RSpec matchers for RubyEventStore.
4
4
 
5
5
  Find out more at [https://railseventstore.org](https://railseventstore.org/)
6
-
@@ -27,7 +27,7 @@ module RubyEventStore
27
27
  def times
28
28
  self
29
29
  end
30
- alias :time :times
30
+ alias time times
31
31
 
32
32
  def once
33
33
  expected.once
@@ -29,9 +29,9 @@ module RubyEventStore
29
29
  class FailureMessage
30
30
  class ExpectedLine
31
31
  def initialize(expected_klass, expected_metadata, expected_data)
32
- @expected_klass = expected_klass
32
+ @expected_klass = expected_klass
33
33
  @expected_metadata = expected_metadata
34
- @expected_data = expected_data
34
+ @expected_data = expected_data
35
35
  end
36
36
 
37
37
  def to_s
@@ -55,11 +55,11 @@ module RubyEventStore
55
55
 
56
56
  class ActualLine
57
57
  def initialize(actual_klass, actual_metadata, actual_data, expected_metadata, expected_data)
58
- @actual_klass = actual_klass
59
- @actual_metadata = actual_metadata
60
- @actual_data = actual_data
58
+ @actual_klass = actual_klass
59
+ @actual_metadata = actual_metadata
60
+ @actual_data = actual_data
61
61
  @expected_metadata = expected_metadata
62
- @expected_data = expected_data
62
+ @expected_data = expected_data
63
63
  end
64
64
 
65
65
  def to_s
@@ -83,10 +83,10 @@ module RubyEventStore
83
83
 
84
84
  class Diff
85
85
  def initialize(actual, expected, label, differ:)
86
- @actual = actual
86
+ @actual = actual
87
87
  @expected = expected
88
- @label = label
89
- @differ = differ
88
+ @label = label
89
+ @differ = differ
90
90
  end
91
91
 
92
92
  def to_s
@@ -94,14 +94,22 @@ module RubyEventStore
94
94
  end
95
95
  end
96
96
 
97
- def initialize(expected_klass, actual_klass, expected_data, actual_data, expected_metadata, actual_metadata, differ:)
98
- @expected_klass = expected_klass
99
- @actual_klass = actual_klass
100
- @expected_data = expected_data
101
- @actual_data = actual_data
97
+ def initialize(
98
+ expected_klass,
99
+ actual_klass,
100
+ expected_data,
101
+ actual_data,
102
+ expected_metadata,
103
+ actual_metadata,
104
+ differ:
105
+ )
106
+ @expected_klass = expected_klass
107
+ @actual_klass = actual_klass
108
+ @expected_data = expected_data
109
+ @actual_data = actual_data
102
110
  @expected_metadata = expected_metadata
103
- @actual_metadata = actual_metadata
104
- @differ = differ
111
+ @actual_metadata = actual_metadata
112
+ @differ = differ
105
113
  end
106
114
 
107
115
  def to_s
@@ -117,8 +125,8 @@ module RubyEventStore
117
125
  include ::RSpec::Matchers::Composable
118
126
 
119
127
  def initialize(expected, differ:, formatter:)
120
- @expected = expected
121
- @differ = differ
128
+ @expected = expected
129
+ @differ = differ
122
130
  @formatter = formatter
123
131
  end
124
132
 
@@ -138,16 +146,24 @@ module RubyEventStore
138
146
  end
139
147
 
140
148
  def failure_message
141
- actual_data = actual.data if actual.respond_to?(:data)
149
+ actual_data = actual.data if actual.respond_to?(:data)
142
150
  actual_metadata = actual.metadata if actual.respond_to?(:metadata)
143
- FailureMessage.new(expected, actual.class, expected_data, actual_data, expected_metadata, actual_metadata, differ: differ).to_s
151
+ FailureMessage.new(
152
+ expected,
153
+ actual.class,
154
+ expected_data,
155
+ actual_data,
156
+ expected_metadata,
157
+ actual_metadata,
158
+ differ: differ
159
+ ).to_s
144
160
  end
145
161
 
146
162
  def failure_message_when_negated
147
- %Q{
163
+ "
148
164
  expected: not a kind of #{expected}
149
165
  got: #{actual.class}
150
- }
166
+ "
151
167
  end
152
168
 
153
169
  def strict
@@ -191,4 +207,3 @@ expected: not a kind of #{expected}
191
207
  end
192
208
  end
193
209
  end
194
-
@@ -21,6 +21,7 @@ module RubyEventStore
21
21
  end
22
22
 
23
23
  private
24
+
24
25
  attr_reader :differ
25
26
  end
26
27
 
@@ -64,13 +65,11 @@ module RubyEventStore
64
65
  end
65
66
 
66
67
  def failure_message(expected, events)
67
- "expected #{expected.events} to be applied, diff:" +
68
- differ.diff(expected.events.to_s + "\n", events)
68
+ "expected #{expected.events} to be applied, diff:" + differ.diff(expected.events.to_s + "\n", events)
69
69
  end
70
70
 
71
71
  def failure_message_when_negated(expected, events)
72
- "expected #{expected.events} not to be applied, diff:" +
73
- differ.diff(expected.events.inspect + "\n", events)
72
+ "expected #{expected.events} not to be applied, diff:" + differ.diff(expected.events.inspect + "\n", events)
74
73
  end
75
74
 
76
75
  attr_reader :differ
@@ -4,9 +4,9 @@ module RubyEventStore
4
4
  module RSpec
5
5
  class HaveApplied
6
6
  def initialize(*expected, phraser:, failure_message_formatter:)
7
- @expected = ExpectedCollection.new(expected)
7
+ @expected = ExpectedCollection.new(expected)
8
8
  @failure_message_formatter = failure_message_formatter
9
- @phraser = phraser
9
+ @phraser = phraser
10
10
  @fetch_events = FetchUnpublishedEvents.new
11
11
  end
12
12
 
@@ -24,7 +24,7 @@ module RubyEventStore
24
24
  def times
25
25
  self
26
26
  end
27
- alias :time :times
27
+ alias time times
28
28
 
29
29
  def once
30
30
  expected.once
@@ -4,8 +4,8 @@ module RubyEventStore
4
4
  module RSpec
5
5
  class HavePublished
6
6
  def initialize(*expected, phraser:, failure_message_formatter:)
7
- @expected = ExpectedCollection.new(expected)
8
- @phraser = phraser
7
+ @expected = ExpectedCollection.new(expected)
8
+ @phraser = phraser
9
9
  @failure_message_formatter = failure_message_formatter
10
10
  @fetch_events = FetchEvents.new
11
11
  end
@@ -38,7 +38,7 @@ module RubyEventStore
38
38
  def times
39
39
  self
40
40
  end
41
- alias :time :times
41
+ alias time times
42
42
 
43
43
  def from(event_id)
44
44
  fetch_events.from(event_id)
@@ -12,9 +12,7 @@ module RubyEventStore
12
12
 
13
13
  def matches?(handler)
14
14
  @handler = handler
15
- @subscribed_to = expected.select do |event|
16
- event_store.subscribers_for(event).include?(handler)
17
- end
15
+ @subscribed_to = expected.select { |event| event_store.subscribers_for(event).include?(handler) }
18
16
 
19
17
  matcher.matches?(subscribed_to)
20
18
  end
@@ -25,13 +23,11 @@ module RubyEventStore
25
23
  end
26
24
 
27
25
  def failure_message
28
- "expected #{handler} to be subscribed to events, diff:" +
29
- differ.diff(expected.to_s + "\n", subscribed_to)
26
+ "expected #{handler} to be subscribed to events, diff:" + differ.diff(expected.to_s + "\n", subscribed_to)
30
27
  end
31
28
 
32
29
  def failure_message_when_negated
33
- "expected #{handler} not to be subscribed to events, diff:" +
34
- differ.diff(expected.to_s + "\n", subscribed_to)
30
+ "expected #{handler} not to be subscribed to events, diff:" + differ.diff(expected.to_s + "\n", subscribed_to)
35
31
  end
36
32
 
37
33
  def description
@@ -40,9 +36,7 @@ module RubyEventStore
40
36
 
41
37
  private
42
38
 
43
- attr_reader :expected, :handler, :subscribed_to,
44
- :differ, :phraser, :matcher, :event_store
39
+ attr_reader :expected, :handler, :subscribed_to, :differ, :phraser, :matcher, :event_store
45
40
  end
46
41
  end
47
42
  end
48
-
@@ -8,11 +8,7 @@ module RubyEventStore
8
8
  def call(object)
9
9
  items = Array(object).compact.map { |o| format(o) }
10
10
  return "" if items.empty?
11
- if items.one?
12
- items.join
13
- else
14
- "#{items[all_but_last].join(", ")} and #{items.fetch(-1)}"
15
- end
11
+ items.one? ? items.join : "#{items[all_but_last].join(", ")} and #{items.fetch(-1)}"
16
12
  end
17
13
 
18
14
  private
@@ -22,11 +18,7 @@ module RubyEventStore
22
18
  end
23
19
 
24
20
  def format(object)
25
- if object.respond_to?(:description)
26
- ::RSpec::Support::ObjectFormatter.format(object)
27
- else
28
- "be a #{object}"
29
- end
21
+ object.respond_to?(:description) ? ::RSpec::Support::ObjectFormatter.format(object) : "be a #{object}"
30
22
  end
31
23
  end
32
24
  end
@@ -34,16 +26,24 @@ module RubyEventStore
34
26
  def be_an_event(expected)
35
27
  BeEvent.new(expected, differ: differ, formatter: formatter)
36
28
  end
37
- alias :be_event :be_an_event
38
- alias :an_event :be_an_event
39
- alias :event :be_an_event
29
+ alias be_event be_an_event
30
+ alias an_event be_an_event
31
+ alias event be_an_event
40
32
 
41
33
  def have_published(*expected)
42
- HavePublished.new(*expected, phraser: phraser, failure_message_formatter: RSpec.default_formatter.have_published(differ))
34
+ HavePublished.new(
35
+ *expected,
36
+ phraser: phraser,
37
+ failure_message_formatter: RSpec.default_formatter.have_published(differ)
38
+ )
43
39
  end
44
40
 
45
41
  def have_applied(*expected)
46
- HaveApplied.new(*expected, phraser: phraser, failure_message_formatter: RSpec.default_formatter.have_applied(differ))
42
+ HaveApplied.new(
43
+ *expected,
44
+ phraser: phraser,
45
+ failure_message_formatter: RSpec.default_formatter.have_applied(differ)
46
+ )
47
47
  end
48
48
 
49
49
  def have_subscribed_to_events(*expected)
@@ -37,7 +37,7 @@ module RubyEventStore
37
37
  def times
38
38
  self
39
39
  end
40
- alias :time :times
40
+ alias time times
41
41
 
42
42
  def strict
43
43
  expected.strict
@@ -52,7 +52,7 @@ module RubyEventStore
52
52
  end
53
53
  end
54
54
 
55
- return (expectations + reality)
55
+ return expectations + reality
56
56
  end
57
57
  end
58
58
 
@@ -76,6 +76,7 @@ module RubyEventStore
76
76
  end
77
77
 
78
78
  private
79
+
79
80
  attr_reader :differ, :lingo
80
81
 
81
82
  def failure_message_no_events
@@ -92,13 +93,14 @@ module RubyEventStore
92
93
 
93
94
  but was #{lingo.published} #{correct_event_count} times
94
95
  EOS
95
-
96
96
  if !events_with_correct_type.empty?
97
97
  [
98
98
  <<~EOS.strip,
99
99
  There are events of correct type but with incorrect payload:
100
100
  EOS
101
- events_with_correct_type.each_with_index.map {|event_with_correct_type, index| event_diff(expected_event, event_with_correct_type, index) },
101
+ events_with_correct_type.each_with_index.map do |event_with_correct_type, index|
102
+ event_diff(expected_event, event_with_correct_type, index)
103
+ end,
102
104
  nil
103
105
  ]
104
106
  end
@@ -110,7 +112,7 @@ module RubyEventStore
110
112
  , but it was not #{lingo.published}
111
113
 
112
114
  There are events of correct type but with incorrect payload:
113
- #{events_with_correct_type.each_with_index.map {|event_with_correct_type, index| event_diff(expected_event, event_with_correct_type, index) }.join("\n")}
115
+ #{events_with_correct_type.each_with_index.map { |event_with_correct_type, index| event_diff(expected_event, event_with_correct_type, index) }.join("\n")}
114
116
  EOS
115
117
  end
116
118
 
@@ -118,12 +120,12 @@ module RubyEventStore
118
120
  [
119
121
  "#{index + 1}) #{event_with_correct_type.inspect}",
120
122
  indent(data_diff(expected_event, event_with_correct_type), 4),
121
- indent(metadata_diff(expected_event, event_with_correct_type), 4),
123
+ indent(metadata_diff(expected_event, event_with_correct_type), 4)
122
124
  ].reject(&:empty?)
123
125
  end
124
126
 
125
127
  def indent(str, count)
126
- str.to_s.split("\n").map {|l| l.sub(//, " " * count) }
128
+ str.to_s.split("\n").map { |l| l.sub(//, " " * count) }
127
129
  end
128
130
 
129
131
  def failure_message_incorrect_type
@@ -184,7 +186,7 @@ module RubyEventStore
184
186
  def expected_events_list(expected)
185
187
  <<~EOS.strip
186
188
  [
187
- #{expected.map(&:description).map {|d| indent(d, 2) }.join("\n")}
189
+ #{expected.map(&:description).map { |d| indent(d, 2) }.join("\n")}
188
190
  ]
189
191
  EOS
190
192
  end
@@ -192,7 +194,7 @@ module RubyEventStore
192
194
  def actual_events_list(actual)
193
195
  <<~EOS.strip
194
196
  but the following was #{lingo.published}: [
195
- #{actual.map(&:inspect).map {|d| indent(d, 2) }.join("\n")}
197
+ #{actual.map(&:inspect).map { |d| indent(d, 2) }.join("\n")}
196
198
  ]
197
199
  EOS
198
200
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RubyEventStore
4
4
  module RSpec
5
- VERSION = "2.3.0"
5
+ VERSION = "2.4.0"
6
6
  end
7
7
  end
@@ -35,6 +35,4 @@ module RubyEventStore
35
35
  end
36
36
  end
37
37
 
38
- ::RSpec.configure do |config|
39
- config.include ::RubyEventStore::RSpec::Matchers
40
- end
38
+ ::RSpec.configure { |config| config.include ::RubyEventStore::RSpec::Matchers }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_event_store-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkency
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-09 00:00:00.000000000 Z
11
+ date: 2022-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -55,6 +55,7 @@ metadata:
55
55
  changelog_uri: https://github.com/RailsEventStore/rails_event_store/releases
56
56
  source_code_uri: https://github.com/RailsEventStore/rails_event_store
57
57
  bug_tracker_uri: https://github.com/RailsEventStore/rails_event_store/issues
58
+ rubygems_mfa_required: 'true'
58
59
  post_install_message:
59
60
  rdoc_options: []
60
61
  require_paths:
@@ -63,14 +64,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
64
  requirements:
64
65
  - - ">="
65
66
  - !ruby/object:Gem::Version
66
- version: '2.6'
67
+ version: '2.7'
67
68
  required_rubygems_version: !ruby/object:Gem::Requirement
68
69
  requirements:
69
70
  - - ">="
70
71
  - !ruby/object:Gem::Version
71
72
  version: '0'
72
73
  requirements: []
73
- rubygems_version: 3.1.4
74
+ rubygems_version: 3.3.7
74
75
  signing_key:
75
76
  specification_version: 4
76
77
  summary: RSpec matchers for RubyEventStore