rspec_fixtures 0.6.4 → 0.6.5

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: e275cbc4415001359fe5cba161e50ac4e9624521d41540d098ca653eeb3fda4a
4
- data.tar.gz: de7b6b0ee599760ea4bf17c79056d7b5bc3497521600709e163e3afa9bb036b0
3
+ metadata.gz: e36d048ba906c61b8256d0465aca19b4416710f842da133bffcbd5fda86f1850
4
+ data.tar.gz: 72336fe2be6d5a2a907cc31d3b1fad511d78632e359eff1f1e85ba843f36834c
5
5
  SHA512:
6
- metadata.gz: 6a265b08892e6a2568c2f628bc290d09378013cc1428acef54d09581912c270efe2892a39880f34e26acc856692e9c46e52c7d408b7288d4caba2de0a9a9b696
7
- data.tar.gz: 4205ad6ce9c5d9df45e4e8440f620134bc9420d3cc52ac014efecd1069914575a6cd5e0f0ac6224937bd5939e9fbed1f05d0a6a74d24b3647f05becbfa21853f
6
+ metadata.gz: 99aa998d87733a931b7b5351ac336c699351d3d4a2696ad010c5bd40cad5ce7154c0fa93de16773366831e869cf2e4bfca8403811a619af61d502abba2cbcb8a
7
+ data.tar.gz: fba81b54376d1a1ceb35fc5053943c1d99a1cd2085c11241fe5ea4af2715d593c4ec453981e150d23390f09c8b8fccd3abed195102468f491f13bfeae6538aaa
data/README.md CHANGED
@@ -188,5 +188,16 @@ delete the fixtures folder, and run the specs again with:
188
188
  $ AUTO_APPROVE=1 rspec
189
189
  ```
190
190
 
191
+ ### `strip_ansi_escape`
192
+
193
+ In case your output strings contain ANSI escape codes that you wish to avoid
194
+ storing in your fixtures, you can set the `strip_ansi_escape` to `true`.
195
+
196
+ ```ruby
197
+ RSpec.configure do |config|
198
+ config.strip_ansi_escape = true
199
+ end
200
+ ```
201
+
191
202
 
192
203
  [1]: https://en.wikipedia.org/wiki/Levenshtein_distance
@@ -14,6 +14,7 @@ module RSpecFixtures
14
14
  @actual ||= actual
15
15
  return false if @actual.empty?
16
16
 
17
+ @actual = sanitize @actual
17
18
  success = strings_match?
18
19
 
19
20
  if success or !interactive?
@@ -73,6 +74,12 @@ module RSpecFixtures
73
74
  true
74
75
  end
75
76
 
77
+ # Returns true if RSpec is configured to sanitize (remove ANSI escape
78
+ # codes) from the actual strings before proceeeding to comparing them.
79
+ def sanitize?
80
+ RSpec.configuration.strip_ansi_escape
81
+ end
82
+
76
83
  # Returns true if RSpec is configured to allow interactivity.
77
84
  # By default, interactivity is enabled unless the environment
78
85
  # variable `CI` is set.
@@ -91,7 +98,7 @@ module RSpecFixtures
91
98
  "#{fixtures_dir}/#{fixture_name}"
92
99
  end
93
100
 
94
- protected
101
+ protected
95
102
 
96
103
  # Asks for user approval. Used by child classes.
97
104
  def approve_fixture
@@ -125,6 +132,11 @@ module RSpecFixtures
125
132
  end
126
133
  end
127
134
 
135
+ # Returns the input string stripped of ANSI escape codes if the
136
+ # strip_ansi_escape configuration setting was set to true
137
+ def sanitize(string)
138
+ sanitize? ? Strings::ANSI.sanitize(string) : string
139
+ end
128
140
  end
129
141
 
130
142
  end
@@ -5,5 +5,6 @@ if defined? RSpec
5
5
  config.add_setting :fixtures_path, default: File.expand_path('spec/fixtures')
6
6
  config.add_setting :interactive_fixtures, default: !ENV['CI']
7
7
  config.add_setting :auto_approve, default: ENV['AUTO_APPROVE']
8
+ config.add_setting :strip_ansi_escape, default: false
8
9
  end
9
10
  end
@@ -1,3 +1,5 @@
1
+ require 'strings-ansi'
2
+
1
3
  module RSpecFixtures
2
4
  # Capture stdout and stderr
3
5
  #
@@ -13,6 +15,7 @@ module RSpecFixtures
13
15
  block.call
14
16
 
15
17
  captured_stream.string
18
+
16
19
  ensure
17
20
  $stdout = original_stream
18
21
  end
@@ -28,6 +31,7 @@ module RSpecFixtures
28
31
  block.call
29
32
 
30
33
  captured_stream.string
34
+
31
35
  ensure
32
36
  $stderr = original_stream
33
37
  end
@@ -1,3 +1,3 @@
1
1
  module RSpecFixtures
2
- VERSION = "0.6.4"
2
+ VERSION = "0.6.5"
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.4
4
+ version: 0.6.5
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-10 00:00:00.000000000 Z
11
+ date: 2019-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.19'
69
+ - !ruby/object:Gem::Dependency
70
+ name: strings-ansi
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.1'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.1'
69
83
  description: Automatic interactive fixtures for rspec
70
84
  email: db@dannyben.com
71
85
  executables: []