rspec_fixtures 0.6.5 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -3
- data/lib/rspec_fixtures/matchers/base.rb +8 -10
- data/lib/rspec_fixtures/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5dcbd201cfc8ce961170eab0d1293f45442f0175ad029fb89272669438b347b
|
4
|
+
data.tar.gz: d9f1bc75b1e82777eaa0b14c3e06d10bbe292a593210d0802d5302f53e5d8674
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eedf09c7c9eae0382f4be79c1cc24ea6a2edce727bce2993ca02803d08463edc8c361abe100048cbb88bf72ca65b46d7060225a62fd055ddaf7546b848d4555b
|
7
|
+
data.tar.gz: 34a7501c494aac09839a4025fe9a027a8347cc1f9ddd351bb81e72101731ca51c0f21ce73b5f2a1daf959b223f0a2ae2e981558bf1ca386c307e02288eebb924
|
data/README.md
CHANGED
@@ -112,13 +112,22 @@ expect { puts 'some string' }.to output_fixture('fixture_filename').diff(5)
|
|
112
112
|
### `except` - Exclude by regular expression
|
113
113
|
|
114
114
|
Adding `except(regex)` to either `match_fixture` or `output_fixture` will
|
115
|
-
modify the string under test before running.
|
116
|
-
|
115
|
+
modify the string under test before running. By default, the regular
|
116
|
+
expression will be replaced with `...`.
|
117
117
|
|
118
118
|
In the below example, we ignore the full path of the file.
|
119
119
|
|
120
120
|
```ruby
|
121
|
-
expect('path: /path/to/file').to match_fixture('fixture_filename').except(/path:
|
121
|
+
expect('path: /path/to/file').to match_fixture('fixture_filename').except(/path: .*file/)
|
122
|
+
```
|
123
|
+
|
124
|
+
You may provide a second argument, which will be used as an alternative
|
125
|
+
replace string:
|
126
|
+
|
127
|
+
In the below example, all time strings will be replaced with `HH:MM`:
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
expect('22:30').to match_fixture('fixture_filename').except(/\d2:\d2/, 'HH:MM')
|
122
131
|
```
|
123
132
|
|
124
133
|
### `before` - Alter the string before testing
|
@@ -24,7 +24,7 @@ module RSpecFixtures
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
#
|
27
|
+
# Enables the ability to do something like:
|
28
28
|
# `expect(string).to match_fixture(file).diff(10)
|
29
29
|
# The distance argument is the max allowed Levenshtein Distance.
|
30
30
|
def diff(distance)
|
@@ -32,18 +32,16 @@ module RSpecFixtures
|
|
32
32
|
self
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
# Enables the ability to do something like:
|
36
|
+
# `expect(string).to match_fixture(file).except(/\d+/)
|
37
|
+
def except(regex, replace = '...')
|
36
38
|
before ->(str) do
|
37
|
-
|
38
|
-
str[regex, 1] = '...'
|
39
|
-
rescue IndexError
|
40
|
-
end
|
41
|
-
str
|
39
|
+
str.gsub regex, replace
|
42
40
|
end
|
43
41
|
end
|
44
42
|
|
45
|
-
#
|
46
|
-
#
|
43
|
+
# Enables the ability to adjust the actual string before checking
|
44
|
+
# for matches:
|
47
45
|
# `expect(a).to match_fixture(f).before ->(actual) { actual.gsub /one/, 'two' }`
|
48
46
|
def before(proc)
|
49
47
|
@before ||= []
|
@@ -112,7 +110,7 @@ module RSpecFixtures
|
|
112
110
|
end
|
113
111
|
|
114
112
|
# Do the actual test.
|
115
|
-
# - If .before() was used, we
|
113
|
+
# - If .before() was used, we foreward the actual output to the
|
116
114
|
# proc for processing first.
|
117
115
|
# - If .diff() was used, then distance will be set and then
|
118
116
|
# we "levenshtein it".
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_fixtures
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
|
-
rubygems_version: 3.0.
|
119
|
+
rubygems_version: 3.0.3
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: Interactive RSpec Fixtures
|