pry-test 0.5.5 → 0.6.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
  SHA1:
3
- metadata.gz: b74d2ed52a6c240c8fce9857115a28f19f12c192
4
- data.tar.gz: 73d23a617531c4452414e150b595262f3ac0a2de
3
+ metadata.gz: 020727b338a4685172a46d1316cf2da5fd1fdc38
4
+ data.tar.gz: 760b17b36e795fbc62468e044f91cd400c210a24
5
5
  SHA512:
6
- metadata.gz: f0e904e78144a5a9efa74cb91ae3fba9c699fd6865efee22e7e8731015e064add2762525a792a43be1c2f45af9dc8f36d62a9eca190ecdbc3deb0a33ef801d42
7
- data.tar.gz: ce72d5cd0e13d3b25674155a84c3136cc2bab9d9324610f4df563f99085e410bdb7e368f06f3508e919aa9082c4e610c0a1cf4f44e6d090b1d3efe709d93efd3
6
+ metadata.gz: 419fa946efa0f52d0d92ae1bcd6c39da0b071937f0219ceeadb6dd34ec5a43e99b087367872e9f4131e5c1405332caddb3b0b821f528aac2fd781b9db8af7760
7
+ data.tar.gz: ef66f74defd2b4f0ae5258b40111a5dd5eea28d3a196c7dbb7f83bf2227f60318cfb2f82c3c5841f09770d762e0798386e9ff0e6aa530efecab706a19824b4cc
data/bin/pry-test CHANGED
@@ -68,54 +68,31 @@ def runner(options)
68
68
  end
69
69
 
70
70
  # setup pry -------------------------------------------------------------------
71
- options[:disable_pry] ||= options[:async] || RUBY_ENGINE == "jruby" || RUBY_ENGINE == "rbx"
72
71
 
73
- if options[:disable_pry]
74
- if ENV["PRY_TEST_COVERAGE"]
75
- require "simplecov"
76
- require "coveralls"
77
- SimpleCov.command_name "pry-test"
78
- SimpleCov.formatter = Coveralls::SimpleCov::Formatter
79
- SimpleCov.start do
80
- add_filter "test/*.rb"
81
- add_filter "bin"
82
- end
72
+ if ENV["PRY_TEST_COVERAGE"]
73
+ require "simplecov"
74
+ require "coveralls"
75
+ SimpleCov.command_name "pry-test"
76
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
77
+ SimpleCov.start do
78
+ add_filter "test/*.rb"
79
+ add_filter "bin"
83
80
  end
81
+ end
84
82
 
85
- require_relative "../lib/pry-test"
86
- require_tests options
87
- include PryTest::Color
88
- puts magenta("Disabling pry when running with: [#{RUBY_ENGINE}] #{options.inspect}")
83
+ require_relative "../lib/pry-test"
84
+ require_tests options
85
+ include PryTest::Color
86
+
87
+ options[:disable_pry] = true if options[:async]
88
+ if options[:disable_pry]
89
+ puts "Disabline pry #{options.inspect}"
89
90
  exit runner(options).run
90
91
  else
91
- require_relative "../lib/pry-test"
92
- require_tests options
93
- include PryTest::Color
94
-
95
- begin
96
- require "pry"
97
- require "pry-stack_explorer"
98
- require "pry-rescue"
99
- rescue Exception => e
100
- puts red(e.message)
101
- puts e.backtrace.join("\n")
102
- puts red("This can be caused when pry-stack_explorer isn't specified in the Gemfile.")
103
- puts red("It might also indicate that pry-stack_explorer & pry are out of sync.")
104
- puts red("Try different cominations of GEM versions for pry & pry-stack_explorer.")
105
- exit 1
106
- end
107
-
108
- Pry.config.hooks.add_hook :before_session, :print_instructions do |_, _, _pry_|
109
- puts
110
- puts magenta(" Pry session started")
111
- puts magenta("".ljust(80, "-"))
112
- puts " #{magenta " Failures:"} Type #{green "up"} to see the line that failed"
113
- puts " #{magenta "Exceptions:"} Type #{green "whereami"} to get your bearings"
114
- puts
115
- puts " Type #{green "exit"} or #{green "<CTL-D>"} to continue"
116
- puts magenta("".ljust(80, "-"))
117
- puts
118
- end
119
-
92
+ require "pry"
93
+ require "pry-stack_explorer"
94
+ require "pry-byebug"
95
+ require "pry-rescue"
96
+ require "binding_of_caller"
120
97
  exit Pry.rescue { runner(options).run }
121
98
  end
@@ -9,6 +9,7 @@ module PryTest
9
9
  end
10
10
 
11
11
  def after_test(test)
12
+ return unless test.invoked?
12
13
  if test.passed?
13
14
  render "default/test_pass", test
14
15
  else
@@ -4,7 +4,13 @@ require "thread"
4
4
  module PryTest
5
5
  class Runner
6
6
  class << self
7
- attr_accessor :exit
7
+ def terminate
8
+ @terminate = true
9
+ end
10
+
11
+ def terminate?
12
+ !!@terminate
13
+ end
8
14
  end
9
15
 
10
16
  attr_reader :formatter, :options, :active_test, :duration, :passed, :failed
@@ -22,24 +28,26 @@ module PryTest
22
28
  start = Time.now
23
29
 
24
30
  test_classes.each do |test_class|
25
- formatter.before_class(test_class)
26
- test_class.tests.shuffle.each do |test|
27
- @active_test = test
28
- if @options[:async]
29
- @tests ||= Queue.new
30
- @tests << test
31
- else
32
- test.invoke(@formatter, @options)
31
+ if !PryTest::Runner.terminate?
32
+ formatter.before_class(test_class)
33
+ test_class.tests.shuffle.each do |test|
34
+ @active_test = test
35
+ if @options[:async]
36
+ @tests ||= Queue.new
37
+ @tests << test
38
+ else
39
+ test.invoke(@formatter, @options)
40
+ end
33
41
  end
42
+ formatter.after_class(test_class)
34
43
  end
35
- formatter.after_class(test_class)
36
44
  end
37
45
 
38
46
  run_threads if @options[:async]
39
47
 
40
48
  @duration = Time.now - start
41
- @passed = tests.select{ |test| test.passed? }.count
42
- @failed = tests.select{ |test| !test.passed? }.count
49
+ @passed = tests.select{ |test| test.invoked? && test.passed? }.count
50
+ @failed = tests.select{ |test| test.invoked? && !test.passed? }.count
43
51
  formatter.after_results(self)
44
52
  formatter.after_suite(test_classes)
45
53
  @failed
@@ -60,8 +68,8 @@ module PryTest
60
68
  puts "PryTest is running #{thread_count} threads."
61
69
  thread_count.times do
62
70
  threads << Thread.new do
63
- while @tests.empty? == false
64
- Thread.current.kill if PryTest::Runner.exit
71
+ while !@tests.empty?
72
+ Thread.current.kill if PryTest::Runner.terminate?
65
73
  @tests.pop.invoke(@formatter, @options)
66
74
  end
67
75
  end
@@ -63,10 +63,10 @@ module PryTest
63
63
  @asserts << assert_info(caller).merge(:value => value)
64
64
 
65
65
  if !value
66
- binding.pry(:quiet => true) unless @options[:disable_pry]
66
+ Pry.start binding.of_caller(0) unless @options[:disable_pry]
67
67
 
68
- # I don't really like the coupling to the runner here
69
- PryTest::Runner.exit = true if @options[:fail_fast]
68
+ # TODO: I don't really like the coupling to the runner here
69
+ PryTest::Runner.terminate if @options[:fail_fast]
70
70
  end
71
71
 
72
72
  value
@@ -78,9 +78,14 @@ module PryTest
78
78
  !@duration.nil?
79
79
  end
80
80
 
81
+ # Indicates if this test has been invoked.
82
+ # @return [Boolean]
83
+ def invoked?
84
+ !!@invoked
85
+ end
86
+
81
87
  # Indicates if this test passed.
82
88
  def passed?
83
- return true if !@invoked || @asserts.empty?
84
89
  return false if @asserts.empty?
85
90
  @asserts.map{ |a| !!a[:value] }.uniq == [true]
86
91
  end
@@ -1,3 +1,3 @@
1
1
  module PryTest
2
- VERSION = "0.5.5"
2
+ VERSION = "0.6.0"
3
3
  end
data/test/color_test.rb CHANGED
@@ -7,6 +7,11 @@ unless ENV["PRY_TEST_DEMO"]
7
7
  end
8
8
  CRAYON = Crayon.new
9
9
 
10
+ test "default" do
11
+ assert PryTest::Color.default("foo") == "foo"
12
+ assert ColorTest::CRAYON.default("foo") == "foo"
13
+ end
14
+
10
15
  test "red" do
11
16
  assert PryTest::Color.red("foo") == "\e[31mfoo\e[0m"
12
17
  assert ColorTest::CRAYON.red("foo") == "\e[31mfoo\e[0m"
@@ -9,7 +9,8 @@ unless ENV["PRY_TEST_DEMO"]
9
9
  t = PryTest::TestWrapper.new(TestWrapperTest, desc, &meth)
10
10
  assert t.desc == desc
11
11
  assert t.test == ".new"
12
- assert t.passed?
12
+ assert t.invoked? == false
13
+ assert t.passed? == false
13
14
  assert t.finished? == false
14
15
  assert t.duration.nil?
15
16
  assert t.asserts.empty?
metadata CHANGED
@@ -1,15 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-29 00:00:00.000000000 Z
11
+ date: 2015-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry-stack_explorer
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry-byebug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-rescue
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: binding_of_caller
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
13
83
  - !ruby/object:Gem::Dependency
14
84
  name: os
15
85
  requirement: !ruby/object:Gem::Requirement
@@ -72,12 +142,10 @@ email:
72
142
  - natehop@gmail.com
73
143
  executables:
74
144
  - pry-test
75
- extensions:
76
- - ext/mkrf_conf.rb
145
+ extensions: []
77
146
  extra_rdoc_files: []
78
147
  files:
79
148
  - bin/pry-test
80
- - ext/mkrf_conf.rb
81
149
  - lib/pry-test.rb
82
150
  - lib/pry-test/formatters/base_formatter.rb
83
151
  - lib/pry-test/formatters/color.rb
@@ -95,7 +163,6 @@ files:
95
163
  - lib/pry-test/test_wrapper.rb
96
164
  - lib/pry-test/version.rb
97
165
  - test/color_test.rb
98
- - test/demos/cpu_latency_test.rb
99
166
  - test/demos/fail_test.rb
100
167
  - test/demos/io_latency_test.rb
101
168
  - test/runner_test.rb
@@ -114,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
181
  requirements:
115
182
  - - ">="
116
183
  - !ruby/object:Gem::Version
117
- version: 1.9.2
184
+ version: '2.0'
118
185
  required_rubygems_version: !ruby/object:Gem::Requirement
119
186
  requirements:
120
187
  - - ">="
@@ -122,14 +189,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
189
  version: '0'
123
190
  requirements: []
124
191
  rubyforge_project:
125
- rubygems_version: 2.2.2
192
+ rubygems_version: 2.4.5
126
193
  signing_key:
127
194
  specification_version: 4
128
195
  summary: A small test framework that supports debugging test failures and errors when
129
196
  they happen.
130
197
  test_files:
131
198
  - test/color_test.rb
132
- - test/demos/cpu_latency_test.rb
133
199
  - test/demos/fail_test.rb
134
200
  - test/demos/io_latency_test.rb
135
201
  - test/runner_test.rb
data/ext/mkrf_conf.rb DELETED
@@ -1,34 +0,0 @@
1
- # based on instructions here:
2
- # http://en.wikibooks.org/wiki/Ruby_Programming/RubyGems#How_to_install_different_versions_of_gems_depending_on_which_version_of_ruby_the_installee_is_using
3
- require "rubygems"
4
- require "rubygems/command.rb"
5
- require "rubygems/dependency_installer.rb"
6
-
7
- begin
8
- Gem::Command.build_args = ARGV
9
- rescue NoMethodError
10
- end
11
-
12
- installer = Gem::DependencyInstaller.new
13
-
14
- begin
15
- if RUBY_ENGINE =~ /jruby/i
16
- puts "Engine is jruby... skip installation of pry gems."
17
- else
18
- puts "Installing pry gems..."
19
- installer.install "pry"
20
- installer.install "pry-stack_explorer"
21
- installer.install "pry-rescue"
22
- end
23
- rescue Exception => e
24
- puts e.message
25
- puts e.backtrace.join("\n")
26
- exit 1
27
- end
28
-
29
- # create dummy rakefile to indicate success
30
- File.open(File.expand_path("../Rakefile", __FILE__), "w") do |file|
31
- file.write("task :default\n")
32
- end
33
-
34
- exit 0
@@ -1,31 +0,0 @@
1
- if ENV["PRY_TEST_DEMO"]
2
- require_relative "../test_helper"
3
-
4
- class TestCPULatency < PryTest::Test
5
-
6
- before do
7
- @count = 35
8
- end
9
-
10
- test "fibonacci recursion 1" do
11
- @count.times { |i| TestCPULatency.fib(i) }
12
- assert true
13
- end
14
-
15
- test "fibonacci recursion 2" do
16
- @count.times { |i| TestCPULatency.fib(i) }
17
- assert true
18
- end
19
-
20
- test "fibonacci recursion 3" do
21
- @count.times { |i| TestCPULatency.fib(i) }
22
- assert true
23
- end
24
-
25
- def self.fib(n)
26
- n < 2 ? n : fib(n-1) + fib(n-2)
27
- end
28
-
29
- end
30
- end
31
-