micro_test 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/mt +12 -9
- data/lib/micro_test/runner.rb +2 -1
- metadata +1 -1
data/bin/mt
CHANGED
@@ -12,6 +12,7 @@ opts = Slop.parse(:strict => true, :help => true) do
|
|
12
12
|
banner "mt [options]"
|
13
13
|
on :p, :path, "The path to the test directory or file.", :argument => true
|
14
14
|
on :f, :formatter, "The name of the formatter to use. [#{green formatters.join(", ")}]", :argument => true
|
15
|
+
on "fail-fast", "Stops the running of tests after the first test failure."
|
15
16
|
on :pry, "Starts a pry session whenever tests fail."
|
16
17
|
on :demo, "Runs the MicroTest test suite."
|
17
18
|
end
|
@@ -51,17 +52,19 @@ rescue Exception => ex
|
|
51
52
|
exit
|
52
53
|
end
|
53
54
|
|
54
|
-
MicroTest::
|
55
|
-
|
55
|
+
MicroTest::Test.add_observer(Class.new do
|
56
|
+
def self.update(event, arg)
|
57
|
+
if event == :assert && !arg
|
58
|
+
binding.pry(:quiet => true) if MicroTest::Runner.options[:pry]
|
59
|
+
exit if MicroTest::Runner.options[:"fail-fast"]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end)
|
63
|
+
|
64
|
+
if opts[:pry]
|
56
65
|
require "pry"
|
57
66
|
require "pry-stack_explorer"
|
58
67
|
|
59
|
-
MicroTest::Test.add_observer(Class.new do
|
60
|
-
def self.update(event, arg)
|
61
|
-
binding.pry(:quiet => true) if event == :assert && !arg
|
62
|
-
end
|
63
|
-
end)
|
64
|
-
|
65
68
|
Pry.config.hooks.add_hook :before_session, :print_instructions do |_, _, _pry_|
|
66
69
|
_pry_.commands.create_command "line", "View the assert line that failed." do
|
67
70
|
def process
|
@@ -86,4 +89,4 @@ if MicroTest::PRY
|
|
86
89
|
end
|
87
90
|
end
|
88
91
|
|
89
|
-
MicroTest::Runner.run formatter
|
92
|
+
MicroTest::Runner.run formatter, opts.to_hash
|
data/lib/micro_test/runner.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module MicroTest
|
2
2
|
module Runner
|
3
3
|
class << self
|
4
|
-
attr_reader :current_test
|
4
|
+
attr_reader :options, :current_test
|
5
5
|
|
6
6
|
def update(event, arg)
|
7
7
|
send(event, arg) if respond_to?(event)
|
@@ -39,6 +39,7 @@ module MicroTest
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def run(formatter, opts={})
|
42
|
+
@options = opts
|
42
43
|
@current_test = nil
|
43
44
|
formatter.header
|
44
45
|
|