media_types 0.2.3 → 0.2.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfc032dcb8a8e98536dac1ca449bd8138c3594c2
4
- data.tar.gz: 489d7e95f4819ac96379221d30b5202fbdacaa37
3
+ metadata.gz: 289075ecf2d6af18c0c90f5e16a1dbd99e2192aa
4
+ data.tar.gz: c3834ae46284989bbdd47c007af6e6ad4d59fc3f
5
5
  SHA512:
6
- metadata.gz: 24c6f02bdb57bfd3e86a434b13ad6d42f3701bb496234a2c411a23cc503a124a34adaca30ee2e01420b9e8078e3a63ab1b3a0db482998d5230079d0c971ae559
7
- data.tar.gz: 694cdc7622903947e80acc5056ce31d187b76e11566be259d1f3e515dcbb5309d305ecc77c25dc56dd548585e1c86dffd5d2fe8be52c26834acc5346ea1b5855
6
+ metadata.gz: ea836cc120dfd87c39d96f59119fe27fe1b101a24b331edd919d4662d717b621ce94fa77c7aaec7a8b4b2f8a415f6e46bf3febea232eee1a11eb6f4d06b757be
7
+ data.tar.gz: adb3dafa03155c97f88391d68c28d583b121696ba6730a16b8f08d6744b893686d91263c3079349a715f0a92e9213f1fe7e0f44105a3bc326bb8f7b39be932eb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.2.4
2
+
3
+ - Change messages for `assert_media_types_registered` to be more informative and consistent.
4
+
1
5
  # 0.2.3
2
6
 
3
7
  - Fix an issue with `Hash#compact` which was introduce in 2.4+. Now works with Ruby 2.3.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- media_types (0.2.3)
4
+ media_types (0.2.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -105,6 +105,8 @@ module MediaTypes
105
105
  mock = Minitest::Mock.new
106
106
  uncalled = expected_types_hash.dup
107
107
 
108
+ failed = []
109
+
108
110
  uncalled.length.times do
109
111
  mock.expect(:call, nil) do |registerable|
110
112
  type = registerable.to_s
@@ -112,20 +114,24 @@ module MediaTypes
112
114
  synonyms = registerable.synonyms
113
115
 
114
116
  options = uncalled.delete(type)
115
- options && options == [symbol, synonyms] || raise(
116
- MockExpectationError,
117
- format(
118
- 'Called with [type: %<type>s, symbol: %<symbol>s, synonyms: %<synonyms>s]' + "\n"\
119
- 'Resolved options: [%<resolved>s]' + "\n"\
120
- 'Uncalled options: [%<uncalled>s]',
121
- type: type,
122
- symbol: symbol,
123
- synonyms: synonyms,
124
- resolved: options,
125
- uncalled: uncalled
117
+ return true if options && options == [symbol, synonyms] && pass
118
+
119
+ failed <<
120
+ MockExpectationError.new(
121
+ format(
122
+ 'Call failed to match expectations:' + "\n"\
123
+ '+++ actual [type: %<type>s, symbol: %<symbol>s, synonyms: %<synonyms>s]' + "\n"\
124
+ '--- expected [type: %<type>s, symbol: %<resolved_symbol>s, synonyms: %<resolved_synonyms>s]',
125
+ type: type,
126
+ symbol: symbol,
127
+ synonyms: synonyms,
128
+ resolved_symbol: options&.first,
129
+ resolved_synonyms: options&.last
130
+ )
126
131
  )
127
- )
128
132
  end
133
+
134
+ false
129
135
  end
130
136
 
131
137
  MediaTypes.stub(:register, mock) do
@@ -136,7 +142,24 @@ module MediaTypes
136
142
  end
137
143
  end
138
144
 
139
- assert_mock mock
145
+ messages = failed.map(&:message)
146
+ uncalled.each do |type, options|
147
+ messages << format(
148
+ 'Call did not occur:' + "\n"\
149
+ '--- expected: [type: %<type>s, symbol: %<resolved_symbol>s, synonyms: %<resolved_synonyms>s]',
150
+ type: type,
151
+ resolved_symbol: options&.first,
152
+ resolved_synonyms: options&.last
153
+ )
154
+ end
155
+
156
+ if messages.length.positive?
157
+ flunk messages.join(",\n")
158
+ else
159
+ pass
160
+ end
161
+
162
+ assert mock
140
163
  end
141
164
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
142
165
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MediaTypes
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: media_types
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derk-Jan Karrenbeld