rspec-expectations 2.14.3 → 2.14.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/Changelog.md +9 -0
- data/features/diffing.feature +1 -1
- data/lib/rspec/expectations/differ.rb +25 -11
- data/lib/rspec/expectations/version.rb +1 -1
- data/lib/rspec/matchers.rb +0 -3
- data/lib/rspec/matchers/built_in/match.rb +5 -0
- data/spec/rspec/expectations/differ_spec.rb +18 -3
- data/spec/rspec/matchers/match_spec.rb +13 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ZTEyOTg0ZTBjMDczNGJlZTc1ZGI3YThjODY4MWViMjMzYzI2ZTk1OWQ4NjVi
|
10
|
-
NjgyMmZlZjNiODRjOTU2ODdkYTM0YzIzMjQwMjAxZTI4YzY5Y2MzYWJlZmVl
|
11
|
-
MDgwZjdjZjQ5Nzc0MDY4MzVlMTQwMTczMGE4Y2NhNzJlZDAzMjE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZGZjNzZkNjQwMDU4NWI5ZDRmYzM0NjM4M2MwMTMzNmJhODgyOWE0NGU4NzQ0
|
14
|
-
MWI2Yjc2YzUxYjNmMGZmMGQ4MzQ4ODFiYjU2NDViOGJmNGVmNjFlNGU4M2Iz
|
15
|
-
Njc3N2U0ZDUwNGJiMjVhZmRmZDViOTRmNjVhMjU1MDRjYjk3NTY=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2fe9c0e9206aaf6e58ecb9d8ef9e906668443bad
|
4
|
+
data.tar.gz: b87df2d0361493a79a7f6b481b55e13babff42e8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e72fd27b6f8595cccd408ce04cae06c4ec222f424015c0e50a942ab03ee40b716a3d159c4b88d73715769ab45156056d9a51c0f223335c8ddc1ac9cc1fde01bf
|
7
|
+
data.tar.gz: cf203e11140a60a320babfa6be93bd5943b1645a6ccd4b5dc01edaefd5fbe0ed7e770ba05f2deb9f2b096c76213db103cf8ea8042ef8f6e9052ac24d6e45ca04
|
data/Changelog.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
### 2.14.4 / 2013-11-06
|
2
|
+
[full changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.3...v2.14.4)
|
3
|
+
|
4
|
+
Bug fixes
|
5
|
+
|
6
|
+
* Make the `match` matcher produce a diff output. (Jon Rowe, Ben Moss)
|
7
|
+
* Choose encoding for diff's more intelligently, and when all else fails fall
|
8
|
+
back to default internal encoding with replacing characters. (Jon Rowe)
|
9
|
+
|
1
10
|
### 2.14.3 / 2013-09-22
|
2
11
|
[full changelog](http://github.com/rspec/rspec-expectations/compare/v2.14.2...v2.14.3)
|
3
12
|
|
data/features/diffing.feature
CHANGED
@@ -5,11 +5,13 @@ require 'pp'
|
|
5
5
|
module RSpec
|
6
6
|
module Expectations
|
7
7
|
class Differ
|
8
|
+
|
8
9
|
# This is snagged from diff/lcs/ldiff.rb (which is a commandline tool)
|
9
10
|
def diff_as_string(input_data_new, input_data_old)
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
encoding = pick_encoding input_data_new, input_data_old
|
12
|
+
output = matching_encoding("", encoding)
|
13
|
+
data_old = input_data_old.split(matching_encoding("\n", encoding)).map! { |e| e.chomp }
|
14
|
+
data_new = input_data_new.split(matching_encoding("\n", encoding)).map! { |e| e.chomp }
|
13
15
|
diffs = Diff::LCS.diff(data_old, data_new)
|
14
16
|
return output if diffs.empty?
|
15
17
|
oldhunk = hunk = nil
|
@@ -33,16 +35,16 @@ module RSpec
|
|
33
35
|
hunk.unshift(oldhunk)
|
34
36
|
end
|
35
37
|
else
|
36
|
-
output << matching_encoding(oldhunk.diff(format).to_s,
|
38
|
+
output << matching_encoding(oldhunk.diff(format).to_s, encoding)
|
37
39
|
end
|
38
40
|
ensure
|
39
41
|
oldhunk = hunk
|
40
|
-
output << matching_encoding("\n",
|
42
|
+
output << matching_encoding("\n", encoding)
|
41
43
|
end
|
42
44
|
end
|
43
45
|
#Handle the last remaining hunk
|
44
|
-
output << matching_encoding(oldhunk.diff(format).to_s,
|
45
|
-
output << matching_encoding("\n",
|
46
|
+
output << matching_encoding(oldhunk.diff(format).to_s, encoding)
|
47
|
+
output << matching_encoding("\n", encoding)
|
46
48
|
color_diff output
|
47
49
|
rescue Encoding::CompatibilityError
|
48
50
|
if input_data_new.encoding != input_data_old.encoding
|
@@ -115,7 +117,8 @@ module RSpec
|
|
115
117
|
#
|
116
118
|
# note, PP is used to ensure the ordering of the internal values of key/value e.g.
|
117
119
|
# <# a: b: c:> not <# c: a: b:>
|
118
|
-
|
120
|
+
encoding = pick_encoding pp_key, pp_value
|
121
|
+
matching_encoding("#{pp_key} => #{pp_value}", encoding)
|
119
122
|
end.join(",\n")
|
120
123
|
when String
|
121
124
|
object =~ /\n/ ? object : object.inspect
|
@@ -124,12 +127,23 @@ module RSpec
|
|
124
127
|
end
|
125
128
|
end
|
126
129
|
|
130
|
+
private
|
131
|
+
|
127
132
|
if String.method_defined?(:encoding)
|
128
|
-
def
|
129
|
-
|
133
|
+
def pick_encoding(source_a, source_b)
|
134
|
+
Encoding.compatible?(source_a, source_b) || Encoding.default_external
|
135
|
+
end
|
136
|
+
|
137
|
+
def matching_encoding(string, encoding)
|
138
|
+
string.encode encoding
|
139
|
+
rescue Encoding::UndefinedConversionError
|
140
|
+
string.encode(encoding, :undef => :replace)
|
130
141
|
end
|
131
142
|
else
|
132
|
-
def
|
143
|
+
def pick_encoding(source_a, source_b)
|
144
|
+
end
|
145
|
+
|
146
|
+
def matching_encoding(string, encoding)
|
133
147
|
string
|
134
148
|
end
|
135
149
|
end
|
data/lib/rspec/matchers.rb
CHANGED
@@ -521,9 +521,6 @@ module RSpec
|
|
521
521
|
# expect { do_something_risky }.to raise_error(PoorRiskDecisionError, /oo ri/)
|
522
522
|
#
|
523
523
|
# expect { do_something_risky }.not_to raise_error
|
524
|
-
# expect { do_something_risky }.not_to raise_error(PoorRiskDecisionError)
|
525
|
-
# expect { do_something_risky }.not_to raise_error(PoorRiskDecisionError, "that was too risky")
|
526
|
-
# expect { do_something_risky }.not_to raise_error(PoorRiskDecisionError, /oo ri/)
|
527
524
|
def raise_error(error=Exception, message=nil, &block)
|
528
525
|
BuiltIn::RaiseError.new(error, message, &block)
|
529
526
|
end
|
@@ -54,7 +54,12 @@ EOD
|
|
54
54
|
@actual="Tu avec carte {count} item has".encode('UTF-16LE')
|
55
55
|
expect(subject).to eql 'Could not produce a diff because of the encoding of the string (UTF-16LE)'
|
56
56
|
end
|
57
|
-
it '
|
57
|
+
it 'handles differently encoded strings that are compatible' do
|
58
|
+
@expected = "강인철".encode('UTF-8')
|
59
|
+
@actual = "abc".encode('us-ascii')
|
60
|
+
expect(subject).to eql "\n@@ -1,2 +1,2 @@\n-abc\n+강인철\n"
|
61
|
+
end
|
62
|
+
it 'outputs a message when encountering differently encoded strings' do
|
58
63
|
@expected="Tu avec carté {count} itém has".encode('UTF-16LE')
|
59
64
|
@actual="Tu avec carte {count} item has"
|
60
65
|
expect(subject).to eql 'Could not produce a diff because the encoding of the actual string (UTF-8) differs from the encoding of the expected string (UTF-16LE)'
|
@@ -137,7 +142,7 @@ EOD
|
|
137
142
|
expect(diff).to eq expected_diff
|
138
143
|
end
|
139
144
|
|
140
|
-
it 'outputs unified diff
|
145
|
+
it 'outputs unified diff message of two hashes with differing encoding' do
|
141
146
|
expected_diff = %Q{
|
142
147
|
@@ -1,2 +1,2 @@
|
143
148
|
-"a" => "a"
|
@@ -148,6 +153,17 @@ EOD
|
|
148
153
|
expect(diff).to eq expected_diff
|
149
154
|
end
|
150
155
|
|
156
|
+
it 'outputs unified diff message of two hashes with encoding different to key encoding' do
|
157
|
+
expected_diff = %Q{
|
158
|
+
@@ -1,2 +1,2 @@
|
159
|
+
-:a => "a"
|
160
|
+
#{ (RUBY_VERSION.to_f > 1.8) ? %Q{+\"한글\" => \"한글2\"} : '+"\355\225\234\352\270\200" => "\355\225\234\352\270\2002"' }
|
161
|
+
}
|
162
|
+
|
163
|
+
diff = differ.diff_as_object({ "한글" => "한글2"}, { :a => "a"})
|
164
|
+
expect(diff).to eq expected_diff
|
165
|
+
end
|
166
|
+
|
151
167
|
it "outputs unified diff message of two hashes with object keys" do
|
152
168
|
expected_diff = %Q{
|
153
169
|
@@ -1,2 +1,2 @@
|
@@ -211,4 +227,3 @@ EOD
|
|
211
227
|
end
|
212
228
|
end
|
213
229
|
end
|
214
|
-
|
@@ -30,6 +30,19 @@ describe "expect(...).to match(expected)" do
|
|
30
30
|
matcher.matches?("string")
|
31
31
|
expect(matcher.failure_message_for_should).to eq "expected \"string\" to match /rings/"
|
32
32
|
end
|
33
|
+
|
34
|
+
it "provides a diff on failure" do
|
35
|
+
allow(RSpec::Matchers.configuration).to receive(:color?).and_return(false)
|
36
|
+
|
37
|
+
failure_message_that_includes_diff = %r%
|
38
|
+
\s*Diff:
|
39
|
+
\s*@@ -1,2 \+1,2 @@
|
40
|
+
\s*-/bar/
|
41
|
+
\s*\+"foo"%
|
42
|
+
|
43
|
+
expect { expect("foo").to match(/bar/) }.to fail_with(failure_message_that_includes_diff)
|
44
|
+
end
|
45
|
+
|
33
46
|
end
|
34
47
|
|
35
48
|
describe "expect(...).not_to match(expected)" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-expectations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.14.
|
4
|
+
version: 2.14.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Baker
|
@@ -9,13 +9,13 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: diff-lcs
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - '>='
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 1.1.3
|
21
21
|
- - <
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
|
-
- -
|
28
|
+
- - '>='
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: 1.1.3
|
31
31
|
- - <
|
@@ -222,20 +222,20 @@ require_paths:
|
|
222
222
|
- lib
|
223
223
|
required_ruby_version: !ruby/object:Gem::Requirement
|
224
224
|
requirements:
|
225
|
-
- -
|
225
|
+
- - '>='
|
226
226
|
- !ruby/object:Gem::Version
|
227
227
|
version: '0'
|
228
228
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
229
229
|
requirements:
|
230
|
-
- -
|
230
|
+
- - '>='
|
231
231
|
- !ruby/object:Gem::Version
|
232
232
|
version: '0'
|
233
233
|
requirements: []
|
234
234
|
rubyforge_project: rspec
|
235
|
-
rubygems_version: 2.0.
|
235
|
+
rubygems_version: 2.0.3
|
236
236
|
signing_key:
|
237
237
|
specification_version: 4
|
238
|
-
summary: rspec-expectations-2.14.
|
238
|
+
summary: rspec-expectations-2.14.4
|
239
239
|
test_files:
|
240
240
|
- features/README.md
|
241
241
|
- features/Upgrade.md
|