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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e36d048ba906c61b8256d0465aca19b4416710f842da133bffcbd5fda86f1850
4
- data.tar.gz: 72336fe2be6d5a2a907cc31d3b1fad511d78632e359eff1f1e85ba843f36834c
3
+ metadata.gz: c5dcbd201cfc8ce961170eab0d1293f45442f0175ad029fb89272669438b347b
4
+ data.tar.gz: d9f1bc75b1e82777eaa0b14c3e06d10bbe292a593210d0802d5302f53e5d8674
5
5
  SHA512:
6
- metadata.gz: 99aa998d87733a931b7b5351ac336c699351d3d4a2696ad010c5bd40cad5ce7154c0fa93de16773366831e869cf2e4bfca8403811a619af61d502abba2cbcb8a
7
- data.tar.gz: fba81b54376d1a1ceb35fc5053943c1d99a1cd2085c11241fe5ea4af2715d593c4ec453981e150d23390f09c8b8fccd3abed195102468f491f13bfeae6538aaa
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. The supplied regular expression
116
- must include exactly one capture group, which will be then replaced by '...'.
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: (.*)file/)
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
- # Provides a chained matcher to do something like:
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
- def except(regex)
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
- begin
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
- # Provides a chained matcher to adjust the actual string before
46
- # checking for matches:
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 foreard the actual output to the
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".
@@ -1,3 +1,3 @@
1
1
  module RSpecFixtures
2
- VERSION = "0.6.5"
2
+ VERSION = "0.7.0"
3
3
  end
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.6.5
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: 2019-10-18 00:00:00.000000000 Z
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.4
119
+ rubygems_version: 3.0.3
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Interactive RSpec Fixtures