micro_test 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source :rubygems
2
2
 
3
3
  gem "slop"
4
4
  gem "pry"
5
+ gem "pry-stack_explorer"
6
+ gem "pry-exception_explorer"
7
+ gem "pry-remote"
8
+ gem "coderay"
@@ -1,17 +1,29 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ binding_of_caller (0.6.8)
4
5
  coderay (1.0.7)
5
6
  method_source (0.8)
6
7
  pry (0.9.10)
7
8
  coderay (~> 1.0.5)
8
9
  method_source (~> 0.8)
9
10
  slop (~> 3.3.1)
11
+ pry-exception_explorer (0.1.9)
12
+ pry-stack_explorer (>= 0.3.9)
13
+ pry-remote (0.1.6)
14
+ pry (~> 0.9)
15
+ slop (~> 3.0)
16
+ pry-stack_explorer (0.4.6)
17
+ binding_of_caller (~> 0.6.2)
10
18
  slop (3.3.3)
11
19
 
12
20
  PLATFORMS
13
21
  ruby
14
22
 
15
23
  DEPENDENCIES
24
+ coderay
16
25
  pry
26
+ pry-exception_explorer
27
+ pry-remote
28
+ pry-stack_explorer
17
29
  slop
data/README.md CHANGED
@@ -121,5 +121,5 @@ Run tests.
121
121
 
122
122
  ```bash
123
123
  $ mt
124
- $ mt /example/test
125
- $ mt /example/test/math_test.rb
124
+ $ mt -p /example/test
125
+ $ mt -p /example/test/math_test.rb
data/bin/mt CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "slop"
3
- require "pry"
4
3
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "micro_test"))
5
4
 
6
5
  opts = Slop.parse(:strict => true, :help => true) do
@@ -26,14 +25,14 @@ else
26
25
  end
27
26
 
28
27
  formatter_name = opts[:formatter] || "default"
29
- formatter_path = File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "formatters", formatter_name + ".rb"))
28
+ formatter_path = File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "micro_test", "formatters", formatter_name + ".rb"))
30
29
  unless File.exist?(formatter_path)
31
30
  puts "#{formatter_path} not found."
32
31
  puts "Please check the formatter name and try again."
33
32
  exit
34
33
  end
35
34
  begin
36
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "formatters", formatter_name))
35
+ require formatter_path
37
36
  formatter = MicroTest.const_get("Formatter").new
38
37
  rescue Exception => ex
39
38
  puts "Failed to load the formatter."
@@ -41,4 +40,18 @@ rescue Exception => ex
41
40
  exit
42
41
  end
43
42
 
44
- MicroTest::Runner.run formatter, :pry => !!opts[:pry]
43
+ MicroTest::PRY = !!opts[:pry]
44
+ if MicroTest::PRY
45
+ require "pry"
46
+ require "pry-stack_explorer"
47
+ # require "pry-exception_explorer"
48
+ Pry.config.hooks.add_hook :before_session, :print_instructions do
49
+ puts "#{MicroTest::Color.red "Assert Failed!"} #{MicroTest::Color.yellow "Type 'up' to see the line that failed."}"
50
+ end
51
+ # EE.enabled = true
52
+ # EE.intercept do |frame , ex|
53
+ # !ex.is_a?(LoadError)
54
+ # end
55
+ end
56
+
57
+ MicroTest::Runner.run formatter
@@ -0,0 +1,21 @@
1
+ module MicroTest
2
+ module Color
3
+ extend self
4
+
5
+ colors = {
6
+ :red => 31,
7
+ :green => 32,
8
+ :yellow => 33,
9
+ :blue => 34,
10
+ :magenta => 35,
11
+ :cyan => 36,
12
+ :white => 37
13
+ }
14
+
15
+ colors.each do |name, code|
16
+ define_method name do |text|
17
+ "\e[#{code}m#{text}\e[0m"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,8 @@
1
+ require File.join(File.dirname(__FILE__), "..", "color")
2
+
1
3
  module MicroTest
2
4
  class Formatter
5
+ include MicroTest::Color
3
6
 
4
7
  def initialize
5
8
  @total = 0
@@ -42,19 +45,5 @@ module MicroTest
42
45
  puts "---"
43
46
  end
44
47
 
45
- private
46
-
47
- def red(text)
48
- "\e[31m#{text}\e[0m"
49
- end
50
-
51
- def yellow(text)
52
- "\e[33m#{text}\e[0m"
53
- end
54
-
55
- def green(text)
56
- "\e[32m#{text}\e[0m"
57
- end
58
-
59
48
  end
60
49
  end
@@ -48,14 +48,8 @@ module MicroTest
48
48
  @failed = false
49
49
  @asserts = []
50
50
  test_class.invoke :before, :each
51
- begin
52
- test_class.tests[desc].call
53
- rescue Exception => e
54
- @failed = true
55
- error = e
56
- end
57
- test_class.tests[desc].pry if @failed && opts[:pry]
58
- formatter.test :name => desc, :passed => !@failed, :asserts => @asserts, :error => error
51
+ test_class.tests[desc].call
52
+ formatter.test :name => desc, :passed => !@failed, :asserts => @asserts
59
53
  test_class.invoke :after, :each
60
54
  end
61
55
 
@@ -39,6 +39,7 @@ module MicroTest
39
39
  end
40
40
 
41
41
  def assert(value)
42
+ binding.pry if MicroTest::PRY && !value
42
43
  notify(:assert, value)
43
44
  end
44
45
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: micro_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: pry-stack_explorer
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
46
62
  description: ! " Testing frameworks often lose their focus and become an end unto
47
63
  themselves.\n MicroTest avoids this pitfall with a relentless focus on simplicity.\n"
48
64
  email:
@@ -52,7 +68,8 @@ executables:
52
68
  extensions: []
53
69
  extra_rdoc_files: []
54
70
  files:
55
- - lib/formatters/default.rb
71
+ - lib/micro_test/color.rb
72
+ - lib/micro_test/formatters/default.rb
56
73
  - lib/micro_test/runner.rb
57
74
  - lib/micro_test/test.rb
58
75
  - lib/micro_test.rb
@@ -86,3 +103,4 @@ signing_key:
86
103
  specification_version: 3
87
104
  summary: Ruby's no-nonsense testing framework.
88
105
  test_files: []
106
+ has_rdoc: