pry-test 0.6.5 → 0.6.6

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
- SHA1:
3
- metadata.gz: 902de8c8742428c4e1b68d84eef9c70a8c1e9f8f
4
- data.tar.gz: 44d6facd4f0c3dcba6ce14a8e9d753dd44bd4160
2
+ SHA256:
3
+ metadata.gz: 49293b2860beb82dfddce98173d8b6d4c88a4496742521459d96af1b8f0ebefa
4
+ data.tar.gz: 5ed5052aad02cb367a5344918e2f37d8540e5e6ec61397ff1d1b90c67a5aa9ec
5
5
  SHA512:
6
- metadata.gz: c6f23ef3de82912a30da92d2e68902fa0ddba56285e6cbc96be01282e7ac2574d9cc9d6b24cf2eb4bdfb3ab9cbc92b5092323c69340a6f60020f3afc7148c56a
7
- data.tar.gz: 3fab1d585d844c930f1254368d4a908e9b816fb77a60e4960dab2e856029dcce18801bd7b5be222f914c442c5b7e648c6ae6e3bb447b03b74baa192e77527a8a
6
+ metadata.gz: 4e136ed442f5914bbf00b44a5c9c093e7d6f0dae93693f6e8fd3cd89cd37546f84bec244eae1cd938039d44a4ee9968548d6fbccaf751f00bb19d0576607e4bb
7
+ data.tar.gz: e7eac236789f34cfa2dcf056283262d5dfd3df9ff81ee184b90fb66a68d1c703d7eccd07e3bc68d040f0dd1129bd4b154c31143d934b8f239344016847f32f90
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec magic_frozen_string_literal
4
+ bundle exec standardrb --fix
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  path = File.expand_path("../pry-test/**/*.rb", __FILE__)
2
- Dir[path].each { |file| require file }
4
+ Dir[path].sort.each { |file| require file }
@@ -1,5 +1,6 @@
1
- module PryTest
1
+ # frozen_string_literal: true
2
2
 
3
+ module PryTest
3
4
  class << self
4
5
  def formatters
5
6
  @formatters ||= []
@@ -56,19 +57,18 @@ module PryTest
56
57
  def after_suite(test_classes)
57
58
  end
58
59
 
59
- def render(template_name, template_context=nil)
60
+ def render(template_name, template_context = nil)
60
61
  puts text_to_render(template_name, template_context)
61
62
  end
62
63
 
63
- def render_inline(template_name, template_context=nil)
64
+ def render_inline(template_name, template_context = nil)
64
65
  print text_to_render(template_name, template_context)
65
66
  end
66
67
 
67
68
  private
68
69
 
69
- def text_to_render(template_name, template_context=nil)
70
+ def text_to_render(template_name, template_context = nil)
70
71
  Template.new(template_context || self).render_to_string(template_name)
71
72
  end
72
-
73
73
  end
74
74
  end
@@ -1,16 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PryTest
2
4
  module Color
3
5
  extend self
4
6
 
5
7
  colors = {
6
- :red => 31,
7
- :green => 32,
8
- :yellow => 33,
9
- :blue => 34,
10
- :magenta => 35,
11
- :cyan => 36,
12
- :white => 37,
13
- :gray => 90
8
+ red: 31,
9
+ green: 32,
10
+ yellow: 33,
11
+ blue: 34,
12
+ magenta: 35,
13
+ cyan: 36,
14
+ white: 37,
15
+ gray: 90
14
16
  }
15
17
 
16
18
  def default(text)
@@ -19,7 +21,7 @@ module PryTest
19
21
 
20
22
  colors.each do |name, code|
21
23
  define_method name do |text|
22
- "\e[#{code}m#{text}\e[0m"
24
+ "\e[#{code}m#{text}\e[0m"
23
25
  end
24
26
  end
25
27
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "base_formatter"
2
4
 
3
5
  module PryTest
@@ -35,6 +37,5 @@ module PryTest
35
37
  render "default/test_fail", test
36
38
  end
37
39
  end
38
-
39
40
  end
40
41
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "base_formatter"
2
4
 
3
5
  module PryTest
@@ -20,6 +22,5 @@ module PryTest
20
22
  def after_suite(test_classes)
21
23
  render "default/suite"
22
24
  end
23
-
24
25
  end
25
26
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "erb"
2
4
  require_relative "color"
3
5
 
@@ -16,15 +18,15 @@ module PryTest
16
18
 
17
19
  def render_to_string(name)
18
20
  instance_eval do
19
- ERB.new(self.class.view(name), nil, "%<>-").result(binding)
21
+ ERB.new(self.class.view(name), trim_mode: "-").result(binding)
20
22
  end
21
23
  end
22
24
 
23
25
  def partial(name, *collection)
24
26
  return render_to_string(name) if collection.empty?
25
- collection.map do |item|
27
+ collection.map { |item|
26
28
  Template.new(item).render_to_string(name)
27
- end.join("\n")
29
+ }.join("\n")
28
30
  end
29
31
 
30
32
  def duration_color(duration)
@@ -40,12 +42,11 @@ module PryTest
40
42
  finish = assert[:lines].length - 1 if finish >= assert[:lines].length
41
43
  (start..finish).map do |i|
42
44
  {
43
- :line_num => (i + 1),
44
- :line => assert[:lines][i],
45
- :color => (i == index ? :red : :gray)
45
+ line_num: (i + 1),
46
+ line: assert[:lines][i],
47
+ color: (i == index ? :red : :gray)
46
48
  }
47
49
  end
48
50
  end
49
-
50
51
  end
51
52
  end
@@ -1,6 +1,6 @@
1
- require "os"
2
- require "thread"
1
+ # frozen_string_literal: true
3
2
 
3
+ require "os"
4
4
  module PryTest
5
5
  class Runner
6
6
  class << self
@@ -13,9 +13,9 @@ module PryTest
13
13
  end
14
14
  end
15
15
 
16
- attr_reader :formatter, :options, :duration, :passed, :failed
16
+ attr_reader :formatter, :options, :duration
17
17
 
18
- def initialize(formatter, options={})
18
+ def initialize(formatter, options = {})
19
19
  @formatter = formatter
20
20
  @options = options
21
21
  end
@@ -32,11 +32,11 @@ module PryTest
32
32
  end
33
33
 
34
34
  def tests
35
- @tests ||= test_classes.map{ |klass| klass.tests }.flatten
35
+ @tests ||= test_classes.map { |klass| klass.tests }.flatten
36
36
  end
37
37
 
38
38
  def failed_tests
39
- tests.select{ |test| test.invoked? && !test.passed? }
39
+ tests.select { |test| test.invoked? && !test.passed? }
40
40
  end
41
41
 
42
42
  def failed
@@ -44,7 +44,7 @@ module PryTest
44
44
  end
45
45
 
46
46
  def passed_tests
47
- tests.select{ |test| test.invoked? && test.passed? }
47
+ tests.select { |test| test.invoked? && test.passed? }
48
48
  end
49
49
 
50
50
  def passed
@@ -84,17 +84,16 @@ module PryTest
84
84
 
85
85
  def run_threads(queue)
86
86
  puts "PryTest is running #{thread_count} threads."
87
- threads = thread_count.times.map do
87
+ threads = thread_count.times.map {
88
88
  Thread.new do
89
- while !queue.empty?
89
+ until queue.empty?
90
90
  Thread.current.terminate if PryTest::Runner.terminate?
91
91
  test = queue.pop
92
92
  test.invoke(formatter, options)
93
93
  end
94
94
  end
95
- end
95
+ }
96
96
  threads.each { |t| t.join }
97
97
  end
98
-
99
98
  end
100
99
  end
@@ -1,5 +1,6 @@
1
- module PryTest
1
+ # frozen_string_literal: true
2
2
 
3
+ module PryTest
3
4
  # Superclass for all test classes.
4
5
  # @example Create a subclass with a test.
5
6
  # class SimpleTest < PryTest::Test
@@ -9,7 +10,6 @@ module PryTest
9
10
  # end
10
11
  class Test
11
12
  class << self
12
-
13
13
  # All subclasses of this class.
14
14
  # @return [Array<PryTest::Test>]
15
15
  def subclasses
@@ -30,14 +30,14 @@ module PryTest
30
30
  # Defines a setup method that will run before each individual test.
31
31
  # @param [Symbol] what Deprecated but maintained for backwards compatibility.
32
32
  # @yield A block of code that will serve as the setup method.
33
- def before(what=nil, &block)
33
+ def before(what = nil, &block)
34
34
  @before = block
35
35
  end
36
36
 
37
37
  # Defines a teardown method that will run after each individual test.
38
38
  # @param [Symbol] what Deprecated but maintained for backwards compatibility.
39
39
  # @yield A block of code that will serve as the teardown method.
40
- def after(what=nil, &block)
40
+ def after(what = nil, &block)
41
41
  @after = block
42
42
  end
43
43
 
@@ -59,7 +59,6 @@ module PryTest
59
59
  wrapper.create_method(:after, &@after) if @after
60
60
  tests << wrapper
61
61
  end
62
-
63
62
  end
64
63
  end
65
64
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "monitor"
2
4
 
3
5
  module PryTest
4
-
5
6
  # A wrapper class for individual tests.
6
7
  # Exists for the purpose of isolating the test method so it can run in its own thread.
7
8
  class TestWrapper
@@ -29,13 +30,16 @@ module PryTest
29
30
  end
30
31
 
31
32
  # callback stubs
32
- def before; end
33
- def after; end
33
+ def before
34
+ end
35
+
36
+ def after
37
+ end
34
38
 
35
39
  # Runs the test code.
36
40
  # @formatter [PryTest::Formatter] The formatter to use.
37
41
  # @options [Hash]
38
- def invoke(formatter, options={})
42
+ def invoke(formatter, options = {})
39
43
  @formatter = formatter
40
44
  @options = options
41
45
  @formatter.before_test(self)
@@ -59,10 +63,10 @@ module PryTest
59
63
  # end
60
64
  # end
61
65
  def assert(value)
62
- info = assert_info(value, caller_locations.first)
63
- asserts << info.merge(:value => value)
66
+ info = assert_info(value, caller_locations(1..1).first)
67
+ asserts << info.merge(value: value)
64
68
 
65
- if !value
69
+ unless value
66
70
  Pry.start unless @options[:disable_pry]
67
71
 
68
72
  # TODO: I don't really like the coupling to the runner here
@@ -96,7 +100,7 @@ module PryTest
96
100
  def passed?
97
101
  return false unless invoked?
98
102
  return true if asserts.empty?
99
- asserts.map{ |a| !!a[:value] }.uniq == [true]
103
+ asserts.map { |a| !!a[:value] }.uniq == [true]
100
104
  end
101
105
 
102
106
  # Returns a list of all failed asserts.
@@ -127,8 +131,8 @@ module PryTest
127
131
  # @return [Hash]
128
132
  def assert_info(value, location)
129
133
  info = {
130
- :file_path => location.absolute_path,
131
- :line_num => location.lineno
134
+ file_path: location.absolute_path,
135
+ line_num: location.lineno
132
136
  }
133
137
 
134
138
  info.merge! line_info(location) unless value
@@ -149,10 +153,9 @@ module PryTest
149
153
  def line_info(location)
150
154
  lines = File.open(location.absolute_path).readlines
151
155
  {
152
- :lines => lines,
153
- :line => lines[location.lineno]
156
+ lines: lines,
157
+ line: lines[location.lineno]
154
158
  }
155
159
  end
156
-
157
160
  end
158
161
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PryTest
2
- VERSION = "0.6.5"
4
+ VERSION = "0.6.6"
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  unless ENV["PRY_TEST_DEMO"]
2
4
  require_relative "test_helper"
3
5
 
@@ -51,7 +53,6 @@ unless ENV["PRY_TEST_DEMO"]
51
53
  assert PryTest::Color.gray("foo") == "\e[90mfoo\e[0m"
52
54
  assert ColorTest::CRAYON.gray("foo") == "\e[90mfoo\e[0m"
53
55
  end
54
-
55
56
  end
56
57
 
57
58
  end
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if ENV["PRY_TEST_DEMO"]
2
4
  require_relative "../test_helper"
3
5
 
4
6
  class Fail < PryTest::Test
5
-
6
7
  before do
7
8
  @var = "fubar"
8
9
  end
@@ -13,6 +14,5 @@ if ENV["PRY_TEST_DEMO"]
13
14
  # For example, type @var.
14
15
  assert false
15
16
  end
16
-
17
17
  end
18
18
  end
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if ENV["PRY_TEST_DEMO"]
2
4
  require_relative "../test_helper"
3
5
 
4
6
  class TestIOLatency < PryTest::Test
5
-
6
7
  test "sleep 1 sec" do
7
8
  sleep 1
8
9
  assert true
@@ -17,6 +18,5 @@ if ENV["PRY_TEST_DEMO"]
17
18
  sleep 1
18
19
  assert true
19
20
  end
20
-
21
21
  end
22
22
  end
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  unless ENV["PRY_TEST_DEMO"]
2
4
  require_relative "test_helper"
3
5
 
4
6
  class TestRunner < PryTest::Test
5
-
6
7
  before do
7
8
  @runner = PryTest::Runner.new(PryTest::DefaultFormatter.new)
8
9
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "../lib/pry-test"
@@ -1,53 +1,53 @@
1
+ # frozen_string_literal: true
2
+
1
3
  unless ENV["PRY_TEST_DEMO"]
2
4
  require_relative "test_helper"
3
5
 
4
6
  class TestTest < PryTest::Test
5
-
6
7
  before do
7
8
  @test_test = TestTest.clone
8
9
  @test_test.instance_eval { @subclasses = [] }
9
10
  @test_test.instance_eval { @tests = [] }
10
- @Example = Class.new(@test_test) do
11
+ @example = Class.new(@test_test) {
11
12
  before {}
12
13
  after {}
13
14
  test("truth") { assert true }
14
- end
15
- @before_callback = @Example.before
16
- @after_callback = @Example.after
15
+ }
16
+ @before_callback = @example.before
17
+ @after_callback = @example.after
17
18
  end
18
19
 
19
20
  test "adds subclass" do
20
21
  assert @test_test.subclasses.length == 1
21
- assert @test_test.subclasses[0] == @Example
22
+ assert @test_test.subclasses[0] == @example
22
23
  end
23
24
 
24
25
  test "stores subclasses" do
25
26
  assert @test_test.subclasses.is_a?(Array)
26
27
  assert @test_test.subclasses.length == 1
27
- assert @test_test.subclasses.first == @Example
28
+ assert @test_test.subclasses.first == @example
28
29
  end
29
30
 
30
31
  test "stores tests" do
31
- assert @Example.tests.is_a?(Array)
32
- assert @Example.tests.length == 1
33
- assert @Example.tests.first.is_a?(PryTest::TestWrapper)
32
+ assert @example.tests.is_a?(Array)
33
+ assert @example.tests.length == 1
34
+ assert @example.tests.first.is_a?(PryTest::TestWrapper)
34
35
  end
35
36
 
36
37
  test ".before" do
37
- assert @Example.instance_eval { @before } == @before_callback
38
+ assert @example.instance_eval { @before } == @before_callback
38
39
  end
39
40
 
40
41
  test ".after" do
41
- assert @Example.instance_eval { @after } == @after_callback
42
+ assert @example.instance_eval { @after } == @after_callback
42
43
  end
43
44
 
44
45
  test "tests" do
45
46
  t = lambda {}
46
- @Example.send :test, :add_a_test, &t
47
- assert @Example.tests.length == 2
48
- assert @Example.tests.last.is_a?(PryTest::TestWrapper)
49
- assert @Example.tests.last.desc == :add_a_test
47
+ @example.send :test, :add_a_test, &t
48
+ assert @example.tests.length == 2
49
+ assert @example.tests.last.is_a?(PryTest::TestWrapper)
50
+ assert @example.tests.last.desc == :add_a_test
50
51
  end
51
-
52
52
  end
53
53
  end
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  unless ENV["PRY_TEST_DEMO"]
2
4
  require_relative "test_helper"
3
5
 
4
6
  class TestWrapperTest < PryTest::Test
5
-
6
7
  test ".new" do
7
8
  desc = "test_#{rand(999**10)}"
8
9
  meth = lambda { ".new" }
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-17 00:00:00.000000000 Z
11
+ date: 2020-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: pry
14
+ name: os
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: pry-stack_explorer
28
+ name: pry
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: os
70
+ name: pry-stack_explorer
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -80,6 +80,34 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: magic_frozen_string_literal
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: rake
85
113
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +137,7 @@ dependencies:
109
137
  - !ruby/object:Gem::Version
110
138
  version: '0'
111
139
  - !ruby/object:Gem::Dependency
112
- name: coveralls
140
+ name: standard
113
141
  requirement: !ruby/object:Gem::Requirement
114
142
  requirements:
115
143
  - - ">="
@@ -132,6 +160,7 @@ extensions: []
132
160
  extra_rdoc_files: []
133
161
  files:
134
162
  - bin/pry-test
163
+ - bin/standardize
135
164
  - lib/pry-test.rb
136
165
  - lib/pry-test/formatters/base_formatter.rb
137
166
  - lib/pry-test/formatters/color.rb
@@ -159,7 +188,7 @@ homepage: https://github.com/hopsoft/pry-test
159
188
  licenses:
160
189
  - MIT
161
190
  metadata: {}
162
- post_install_message:
191
+ post_install_message:
163
192
  rdoc_options: []
164
193
  require_paths:
165
194
  - lib
@@ -174,17 +203,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
203
  - !ruby/object:Gem::Version
175
204
  version: '0'
176
205
  requirements: []
177
- rubyforge_project:
178
- rubygems_version: 2.6.12
179
- signing_key:
206
+ rubygems_version: 3.0.3
207
+ signing_key:
180
208
  specification_version: 4
181
209
  summary: A small test framework that supports debugging test failures and errors when
182
210
  they happen.
183
211
  test_files:
212
+ - test/runner_test.rb
213
+ - test/test_wrapper_test.rb
184
214
  - test/color_test.rb
215
+ - test/test_test.rb
216
+ - test/test_helper.rb
185
217
  - test/demos/fail_test.rb
186
218
  - test/demos/io_latency_test.rb
187
- - test/runner_test.rb
188
- - test/test_helper.rb
189
- - test/test_test.rb
190
- - test/test_wrapper_test.rb