rspec_approvals 0.8.0 → 0.9.2

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: e5b4e09ac5169c8240d4edf4c4af422845f6508064c93d2277ecafb477c3280f
4
- data.tar.gz: f95d71fc3c4986f9e22675acb082f7c0dce415a3d92b940b98ddd494e256c154
3
+ metadata.gz: 0fb4bded8ab248d2bd2826a66f0bbac01188b92614bea48bfb0203f80f118934
4
+ data.tar.gz: cfaf0bea149ef3926d99f136f291b837756af97dda04d807ce47d55f57dc72a9
5
5
  SHA512:
6
- metadata.gz: 62a96b36858efaa4d83363ce260c0e873bd6cd3dd42ed09c5e9ef5463193a813a16e7cda50d3cdd0f48a61b015679ccb8804c6fabe5c68808f9c8d3f7753b523
7
- data.tar.gz: a207d63a7719161c9bb333030b22dec35b04ea391ba17e6a8c2bde5f780c1ebe7264590023eeb6651f7d547e21f99e2ab5c6d2eb2f3d76455fad8cf7a8c3e54e
6
+ metadata.gz: 041c95b54d4a62f16f0de9fb0502eb482723caca78698e7d9c0d41e5ce42031acbb59ced32bf18524962044ef3baa2daf6db0e07d5802350d13d550bd3cf3d50
7
+ data.tar.gz: e77f8886c6a274455423a2ee584342a78d89a53536d75419d5965d4013d8f5166c96faadd4aec4e1980d4a0dc80c8a9cb0e1fc33d04048f62170841f911a8d26
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/rspec_approvals.svg)](https://badge.fury.io/rb/rspec_approvals)
4
4
  [![Build Status](https://github.com/DannyBen/rspec_approvals/workflows/Test/badge.svg)](https://github.com/DannyBen/rspec_approvals/actions?query=workflow%3ATest)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/a06ed5e30412062c454c/maintainability)](https://codeclimate.com/github/DannyBen/rspec_approvals/maintainability)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/b6ca26de93d9236c706a/maintainability)](https://codeclimate.com/github/DannyBen/rspec_approvals/maintainability)
6
6
 
7
7
  ---
8
8
 
@@ -237,6 +237,17 @@ ENV['COLUMNS'] = '80'
237
237
  ENV['LINES'] = '24'
238
238
  ```
239
239
 
240
+ ### Recommended rspec flags
241
+
242
+ For best results, it is recommended you configure rspec to use the
243
+ documentation format. Place the code below in a file named `.rspec`
244
+ in your project's directory:
245
+
246
+ ```
247
+ --color
248
+ --format documentation
249
+ ```
250
+
240
251
  ## Contributing / Support
241
252
 
242
253
  If you experience any issue, have a question or a suggestion, or if you wish
@@ -1,6 +1,5 @@
1
1
  require 'io/console'
2
2
  require 'colsole'
3
- require 'tty-prompt'
4
3
  require 'diffy'
5
4
 
6
5
  module RSpecApprovals
@@ -20,7 +19,7 @@ module RSpecApprovals
20
19
  prompt_user
21
20
  end
22
21
 
23
- private
22
+ private
24
23
 
25
24
  def prompt_user
26
25
  response = auto_approve? ? :approve : get_response
@@ -45,23 +44,19 @@ module RSpecApprovals
45
44
  end
46
45
 
47
46
  def get_response
48
- prompt.select "Please Choose:", menu_options, symbols: { marker: '>' }
49
- rescue TTY::Reader::InputInterrupt
50
- # :nocov:
51
- return :reject
52
- # :nocov:
47
+ Prompt.select "Please Choose:", 'r', menu_options
53
48
  end
54
49
 
55
50
  def menu_options
56
51
  base = {
57
- 'Reject (and fail test)' => :reject,
58
- 'Approve (and save)' => :approve,
52
+ 'a' => ['Approve (and save)', :approve],
53
+ 'r' => ['Reject (and fail test)', :reject]
59
54
  }
60
55
 
61
56
  extra = {
62
- 'Show actual output' => :actual,
63
- 'Show expected output' => :expected,
64
- 'Show diff' => :diff,
57
+ '1' => ['Show actual output', :actual],
58
+ '2' => ['Show expected output', :expected],
59
+ '3' => ['Show diff', :diff]
65
60
  }
66
61
 
67
62
  expected.empty? ? base : base.merge(extra)
@@ -87,13 +82,10 @@ module RSpecApprovals
87
82
  end
88
83
 
89
84
  def show(what)
85
+ say ""
90
86
  say separator
91
87
  say what
92
88
  say separator
93
89
  end
94
-
95
- def prompt
96
- @prompt ||= TTY::Prompt.new
97
- end
98
90
  end
99
91
  end
@@ -0,0 +1,28 @@
1
+ # This is a fix for a pesky issue with tty-screen, which is a sub-dependency
2
+ # of tty-* gems.
3
+ # Without this fix, gems that include rspec_approval and tty-* gems might
4
+ # cause an error in some cases.
5
+ #
6
+ # ref: https://github.com/piotrmurach/tty-screen/issues/11
7
+ require 'stringio'
8
+
9
+ unless StringIO.method_defined? :ioctl
10
+ class StringIO
11
+ def ioctl(*)
12
+ # :nocov:
13
+ 80
14
+ # :nocov:
15
+ end
16
+ end
17
+ end
18
+
19
+ unless StringIO.method_defined? :wait_readable
20
+ class StringIO
21
+ def wait_readable(*)
22
+ # :nocov:
23
+ true
24
+ # :nocov:
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,25 @@
1
+ require 'io/console'
2
+ require 'colsole'
3
+
4
+ module RSpecApprovals
5
+ class Prompt
6
+ class << self
7
+ include Colsole
8
+
9
+ def select(prompt, default, options)
10
+ options.each do |key, config|
11
+ color = key == default ? 'txtred' : 'txtgrn'
12
+ say "!#{color}!#{key}!txtrst!) #{config.first}"
13
+ end
14
+
15
+ say "\n!txtblu!#{prompt}!txtrst! "
16
+ response = STDIN.getch.downcase
17
+
18
+ response = default unless options.has_key? response
19
+
20
+ resay "!txtpur!#{options[response].first}"
21
+ options[response].last
22
+ end
23
+ end
24
+ end
25
+ end
@@ -6,35 +6,36 @@ module RSpecApprovals
6
6
  # These methods are borrowed from rspec's built in matchers
7
7
  # https://github.com/rspec/rspec-expectations/blob/add9b271ecb1d65f7da5bc8a9dd8c64d81d92303/lib/rspec/matchers/built_in/output.rb
8
8
  module Stream
9
- module Stdout
10
- def self.capture(block)
9
+ module Capture
10
+ def self.capture(stream, block)
11
11
  RSpecApprovals.stdout.truncate 0
12
12
  RSpecApprovals.stdout.rewind
13
+ RSpecApprovals.stderr.truncate 0
14
+ RSpecApprovals.stderr.rewind
13
15
 
14
- original_stream = $stdout
16
+ stdout_original_stream = $stdout
17
+ stderr_original_stream = $stderr
15
18
  $stdout = RSpecApprovals.stdout
19
+ $stderr = RSpecApprovals.stderr
16
20
  block.call
17
- RSpecApprovals.stdout.string.dup
21
+ RSpecApprovals.send(stream).string.dup
18
22
 
19
23
  ensure
20
- $stdout = original_stream
24
+ $stdout = stdout_original_stream
25
+ $stderr = stderr_original_stream
21
26
 
22
27
  end
23
28
  end
24
29
 
25
- module Stderr
30
+ module Stdout
26
31
  def self.capture(block)
27
- RSpecApprovals.stderr.truncate 0
28
- RSpecApprovals.stderr.rewind
29
-
30
- original_stream = $stderr
31
- $stderr = RSpecApprovals.stderr
32
- block.call
33
- RSpecApprovals.stderr.string.dup
34
-
35
- ensure
36
- $stderr = original_stream
32
+ Capture.capture :stdout, block
33
+ end
34
+ end
37
35
 
36
+ module Stderr
37
+ def self.capture(block)
38
+ Capture.capture :stderr, block
38
39
  end
39
40
  end
40
41
  end
@@ -1,3 +1,3 @@
1
1
  module RSpecApprovals
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.2"
3
3
  end
@@ -1,6 +1,8 @@
1
1
  require 'rspec_approvals/extensions/file'
2
+ require 'rspec_approvals/extensions/stringio'
2
3
 
3
4
  require 'rspec_approvals/module_functions'
5
+ require 'rspec_approvals/prompt'
4
6
  require 'rspec_approvals/stream'
5
7
  require 'rspec_approvals/approval_handler'
6
8
  require 'rspec_approvals/matchers/base'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_approvals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.2
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: 2020-05-19 00:00:00.000000000 Z
11
+ date: 2021-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.3'
55
- - !ruby/object:Gem::Dependency
56
- name: tty-prompt
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.19'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0.19'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: strings-ansi
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -90,11 +76,13 @@ files:
90
76
  - lib/rspec_approvals.rb
91
77
  - lib/rspec_approvals/approval_handler.rb
92
78
  - lib/rspec_approvals/extensions/file.rb
79
+ - lib/rspec_approvals/extensions/stringio.rb
93
80
  - lib/rspec_approvals/matchers/base.rb
94
81
  - lib/rspec_approvals/matchers/match_approval.rb
95
82
  - lib/rspec_approvals/matchers/output_approval.rb
96
83
  - lib/rspec_approvals/matchers/raise_approval.rb
97
84
  - lib/rspec_approvals/module_functions.rb
85
+ - lib/rspec_approvals/prompt.rb
98
86
  - lib/rspec_approvals/rspec_config.rb
99
87
  - lib/rspec_approvals/stream.rb
100
88
  - lib/rspec_approvals/version.rb
@@ -117,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
105
  - !ruby/object:Gem::Version
118
106
  version: '0'
119
107
  requirements: []
120
- rubygems_version: 3.1.2
108
+ rubygems_version: 3.2.25
121
109
  signing_key:
122
110
  specification_version: 4
123
111
  summary: Interactive RSpec Approvals