forrest 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +24 -9
- data/bin/forrest +53 -71
- data/forrest-0.1.0.gem +0 -0
- data/forrest.gemspec +1 -1
- data/lib/forrest/runner.rb +1 -0
- data/lib/forrest/scenario_runner.rb +77 -0
- data/lib/forrest/scenario_runner.rb~ +0 -0
- data/pri +1 -1
- metadata +6 -4
- data/test/forrest_stories_test.rb~ +0 -12
data/README.markdown
CHANGED
@@ -8,19 +8,27 @@ or print the list of stories inside a file.
|
|
8
8
|
Print the stories/scenarios list
|
9
9
|
--------------------------------
|
10
10
|
|
11
|
-
forrest test/forrest_stories_test.rb
|
11
|
+
$ forrest test/forrest_stories_test.rb
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
==> Printing all stories/scenarios...
|
14
|
+
|
15
|
+
|
16
|
+
+ ForrestStoriesTest::TestAsAStoriesUserIWantToSeeTheBenchmarkForEachScenario%%--test/forrest_stories_test.rb
|
17
|
+
|__ ForrestStoriesTest::TestAsAStoriesUserIWantToSeeTheBenchmarkForEachScenario#test_A_user_run_forrest_with_a_StoryName_as_a_param%%--test/forrest_stories_test.rb
|
18
|
+
|
19
|
+
|
20
|
+
+ ForrestStoriesTest::TestAsAStoriesUserIWantToSeeTheStoriesReportInAVeryNiceFormat%%--test/forrest_stories_test.rb
|
21
|
+
|__ ForrestStoriesTest::TestAsAStoriesUserIWantToSeeTheStoriesReportInAVeryNiceFormat#test_A_user_run_forrest_with_a_StoryName_as_a_param%%--test/forrest_stories_test.rb
|
22
|
+
|
23
|
+
|__ ForrestStoriesTest::TestAsAStoriesUserIWantToSeeTheStoriesReportInAVeryNiceFormat#test_A_user_run_forrest_with_a_filepath_as_a_param%%--test/forrest_stories_test.rb
|
15
24
|
|
16
|
-
+ ForrestStoriesTest::TestAsAStoriesUserIWantToSeeTheStoriesReportInAVeryNiceFormat
|
17
|
-
|__ ForrestStoriesTest::TestAsAStoriesUserIWantToSeeTheStoriesReportInAVeryNiceFormat#test_A_user_run_forrest_with_a_StoryName_as_a_param
|
18
|
-
|__ ForrestStoriesTest::TestAsAStoriesUserIWantToSeeTheStoriesReportInAVeryNiceFormat#test_A_user_run_forrest_with_a_filepath_as_a_param
|
19
25
|
Loaded suite
|
20
26
|
|
21
|
-
Run a
|
27
|
+
Run a specific story
|
22
28
|
----------------------
|
23
29
|
|
30
|
+
$ forrest ForrestStoriesTest::TestAsAStoriesUserIWantToSeeTheBenchmarkForEachScenario%%--test/forrest_stories_test.rb
|
31
|
+
|
24
32
|
==> Runing story...
|
25
33
|
|
26
34
|
Loaded suite ForrestStoriesTest::TestAsAStoriesUserIWantToSeeTheStoriesReportInAVeryNiceFormat
|
@@ -36,10 +44,10 @@ Run a particular story
|
|
36
44
|
2 tests, 0 assertions, 0 failures, 0 errors
|
37
45
|
1 story, 2 scenarios
|
38
46
|
|
39
|
-
Run a
|
47
|
+
Run a specific scenario
|
40
48
|
-------------------------
|
41
49
|
|
42
|
-
forrest ForrestStoriesTest::TestAsAStoriesUserIWantToSeeTheStoriesReportInAVeryNiceFormat#
|
50
|
+
$ forrest ForrestStoriesTest::TestAsAStoriesUserIWantToSeeTheStoriesReportInAVeryNiceFormat#test_A_user_run_forrest_with_a_StoryName_as_a_param%%--test/forrest_stories_test.rb
|
43
51
|
|
44
52
|
==> Runing scenario...
|
45
53
|
|
@@ -52,5 +60,12 @@ Run a particular scenario
|
|
52
60
|
1 tests, 0 assertions, 0 failures, 0 errors
|
53
61
|
|
54
62
|
|
63
|
+
**Yes, you are thinking:** *this is a very large param, BUT, you can use this flow:*
|
64
|
+
|
65
|
+
1. Print all stories & scenarios in a file
|
66
|
+
|
67
|
+
2. use de forrest command and copy and paste the story or scenario (from the step 1) as the param
|
68
|
+
|
69
|
+
In this was is very easy to use.
|
55
70
|
|
56
71
|
**and have fun!**
|
data/bin/forrest
CHANGED
@@ -6,113 +6,95 @@ require 'test/unit/ui/console/testrunner'
|
|
6
6
|
require File.join(File.dirname(__FILE__), '../lib/object')
|
7
7
|
require File.join(File.dirname(__FILE__), '../lib/forrest/unix_console_styler')
|
8
8
|
require File.join(File.dirname(__FILE__), '../lib/forrest/runner')
|
9
|
-
|
10
|
-
FILE_S = "%%--"
|
9
|
+
require File.join(File.dirname(__FILE__), '../lib/forrest/scenario_runner')
|
11
10
|
|
12
11
|
# --------------------------------------------------------------------------
|
13
12
|
|
14
|
-
def
|
15
|
-
|
13
|
+
def colorize(text, color)
|
14
|
+
"#{UnixConsoleStyler::STYLE[color]}#{text}\e[0m"
|
16
15
|
end
|
17
16
|
|
18
17
|
def print_test_cases(test_cases)
|
19
18
|
test_cases.each{|tc|
|
20
19
|
tests = tc.suite.tests
|
21
|
-
puts "\n+ #{colorize(tc, :bold)}
|
20
|
+
puts "\n+ #{colorize(tc, :bold)}"
|
22
21
|
tests.each{|t|
|
23
|
-
puts "|__ #{colorize(tc, :cyan)}##{colorize(t.method_name, :yellow)}"
|
24
|
-
|
22
|
+
puts "|__ #{colorize(tc, :cyan)}##{colorize(t.method_name, :yellow)}"
|
23
|
+
|
25
24
|
}
|
26
25
|
}
|
27
26
|
end
|
28
27
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
begin
|
35
|
-
require File.join(@test_dir, "../../config/environment")
|
36
|
-
return true
|
37
|
-
rescue LoadError
|
38
|
-
return false
|
39
|
-
end
|
28
|
+
def test_class
|
29
|
+
if @running == 'scenario'
|
30
|
+
@test_class = ARGV[0].split("#")[0].constantize
|
31
|
+
else
|
32
|
+
@test_class = File.basename(@test_file, ".rb").camelize.constantize
|
40
33
|
end
|
41
34
|
end
|
42
35
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
|
36
|
+
def test_file_from_arg
|
37
|
+
if @running == 'scenario'
|
38
|
+
ARGV[0].split("#")[0].split("::")[0].underscore
|
39
|
+
else
|
40
|
+
ARGV[0].split("::")[0].underscore
|
47
41
|
end
|
48
42
|
end
|
49
43
|
|
50
|
-
def
|
51
|
-
@
|
52
|
-
require @test_file
|
53
|
-
require_active_support_or_rails_env
|
54
|
-
@test_cases = test_class.subclasses
|
55
|
-
print_test_cases(@test_cases)
|
56
|
-
begin
|
57
|
-
Test::Unit::UI::Console::TestRunner.run(nil)
|
58
|
-
rescue NoMethodError
|
59
|
-
end
|
44
|
+
def test_name
|
45
|
+
@test_name = ARGV[0].split("#")[1]
|
60
46
|
end
|
61
47
|
|
62
|
-
def
|
63
|
-
|
64
|
-
Stories::ForrestRunner.run(@test_class.constantize)
|
48
|
+
def test_cases
|
49
|
+
test_class.subclasses
|
65
50
|
end
|
66
51
|
|
67
|
-
def
|
68
|
-
|
69
|
-
|
70
|
-
test = @test_class.constantize.suite.tests.find{|t|
|
71
|
-
t.method_name == @test_name
|
52
|
+
def extract_scenario(arg)
|
53
|
+
scenario = test_class.suite.tests.find{|sc|
|
54
|
+
sc.method_name == test_name
|
72
55
|
}
|
73
|
-
|
74
|
-
Test::Unit::UI::Console::TestRunner.run(test)
|
56
|
+
scenario
|
75
57
|
end
|
76
58
|
|
77
|
-
def
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
83
|
-
end
|
59
|
+
def run_scenario(arg)
|
60
|
+
@running = 'scenario'
|
61
|
+
puts "==> Runing scenario...\n\n"
|
62
|
+
require "config/environment"
|
63
|
+
require "test/stories/#{test_file_from_arg}"
|
84
64
|
|
85
|
-
|
86
|
-
@test_class = File.basename(@test_file, ".rb").camelize.constantize
|
65
|
+
Stories::ForrestScenarioRunner.run(extract_scenario(arg))
|
87
66
|
end
|
88
67
|
|
89
|
-
def
|
90
|
-
@
|
91
|
-
|
68
|
+
def run_story(story_name)
|
69
|
+
@running = 'story'
|
70
|
+
puts "==> Runing story...\n\n"
|
71
|
+
require "config/environment"
|
72
|
+
require "test/stories/#{test_file_from_arg}"
|
92
73
|
|
93
|
-
|
94
|
-
"#{UnixConsoleStyler::STYLE[color]}#{text}\e[0m"
|
74
|
+
Stories::ForrestRunner.run(story_name.constantize)
|
95
75
|
end
|
96
76
|
|
97
|
-
|
77
|
+
def show(test_file)
|
98
78
|
puts "==> Printing all stories/scenarios...\n\n"
|
99
|
-
|
100
|
-
|
101
|
-
else
|
102
|
-
@test_dir = File.join(File.dirname(ARGV[0].split("#{FILE_S}")[1]))
|
79
|
+
require test_file
|
80
|
+
print_test_cases(test_cases)
|
103
81
|
|
82
|
+
begin
|
83
|
+
Test::Unit::UI::Console::TestRunner.run(nil)
|
84
|
+
rescue NoMethodError
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# ------------------------------------------------------------------------------
|
89
|
+
|
90
|
+
if File.file?(@test_file = ARGV[0])
|
91
|
+
@running = ''
|
92
|
+
show(@test_file)
|
93
|
+
else
|
104
94
|
if ARGV[0].include? "#"
|
105
|
-
|
106
|
-
@test_class = ARGV[0].split("#")[0]
|
107
|
-
@test_name = ARGV[0].split("#")[1].split("#{FILE_S}")[0]
|
108
|
-
require_active_support_or_rails_env
|
109
|
-
run_scenario
|
95
|
+
run_scenario(ARGV[0])
|
110
96
|
else
|
111
|
-
|
112
|
-
@test_class = ARGV[0].split("#{FILE_S}")[0]
|
113
|
-
|
114
|
-
require_active_support_or_rails_env
|
115
|
-
run_story
|
97
|
+
run_story(ARGV[0])
|
116
98
|
end
|
117
99
|
end
|
118
100
|
|
data/forrest-0.1.0.gem
ADDED
Binary file
|
data/forrest.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'date'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{forrest}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.1"
|
6
6
|
s.date = Date.today.to_s
|
7
7
|
s.summary = %q{Forrest is a runner for stories framework, you can run one story inside of a file that have many stories, can run one scenario or print the list of stories inside a file.}
|
8
8
|
s.description =<<DESCRIPTION
|
data/lib/forrest/runner.rb
CHANGED
@@ -0,0 +1,77 @@
|
|
1
|
+
module Test
|
2
|
+
module Unit
|
3
|
+
class Error
|
4
|
+
# Returns a verbose version of the error description.
|
5
|
+
|
6
|
+
def long_display
|
7
|
+
backtrace = filter_backtrace(@exception.backtrace).join("\n ")
|
8
|
+
"#{colorize('Error:', :red)}\n #{colorize(message, :red)}\n#{backtrace}"
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module Stories
|
16
|
+
|
17
|
+
class ForrestScenarioRunner < Test::Unit::UI::Console::TestRunner
|
18
|
+
|
19
|
+
def test_finished(name)
|
20
|
+
@scenario_name = name.split("(")[0].gsub(/^test_/, "").humanize
|
21
|
+
@story_name = name.split("(")[1].gsub(/\)$/, "")
|
22
|
+
set_story
|
23
|
+
set_scenario
|
24
|
+
end
|
25
|
+
|
26
|
+
def add_fault(fault)
|
27
|
+
@faults << fault
|
28
|
+
end
|
29
|
+
|
30
|
+
def set_story
|
31
|
+
s ||= Story.new @suite.name
|
32
|
+
@story ||= Stories.all[@story_name.constantize]
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_scenario
|
36
|
+
@scenario = @story.scenarios.find{|sc| sc.name == @scenario_name}
|
37
|
+
end
|
38
|
+
|
39
|
+
def print_scenario
|
40
|
+
@scenario.steps.each do |step|
|
41
|
+
puts " #{step}"
|
42
|
+
end
|
43
|
+
|
44
|
+
@scenario.assertions.each do |assertion|
|
45
|
+
puts " #{assertion}"
|
46
|
+
end
|
47
|
+
|
48
|
+
puts
|
49
|
+
end
|
50
|
+
|
51
|
+
def print_story
|
52
|
+
puts "=" * 80
|
53
|
+
puts "\n- #{colorize(@story.name, :bold)} \n\n"
|
54
|
+
|
55
|
+
if @faults.empty?
|
56
|
+
puts " #{colorize(@scenario.name, :green)}"
|
57
|
+
else
|
58
|
+
puts " #{colorize(@scenario.name, :red)}"
|
59
|
+
end
|
60
|
+
|
61
|
+
unless @scenario.steps.empty? && @scenario.assertions.empty?
|
62
|
+
print_scenario
|
63
|
+
end
|
64
|
+
|
65
|
+
puts "=" * 80
|
66
|
+
end
|
67
|
+
|
68
|
+
def finished(elapsed_time)
|
69
|
+
puts
|
70
|
+
|
71
|
+
print_story
|
72
|
+
super
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
File without changes
|
data/pri
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Gaston Ramos
|
@@ -14,7 +14,7 @@ autorequire: forrest
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-16 00:00:00 -03:00
|
18
18
|
default_executable: forrest
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -31,16 +31,18 @@ extensions: []
|
|
31
31
|
extra_rdoc_files: []
|
32
32
|
|
33
33
|
files:
|
34
|
-
- test/forrest_stories_test.rb~
|
35
34
|
- test/forest_stories_test.rb~
|
36
35
|
- test/forrest_stories_test.rb
|
37
36
|
- README.markdown
|
38
37
|
- forrest.gemspec
|
39
38
|
- bin/forrest
|
39
|
+
- forrest-0.1.1.gem
|
40
40
|
- pri
|
41
41
|
- forrest-0.1.0.gem
|
42
42
|
- lib/forrest/runner.rb
|
43
|
+
- lib/forrest/scenario_runner.rb~
|
43
44
|
- lib/forrest/unix_console_styler.rb
|
45
|
+
- lib/forrest/scenario_runner.rb
|
44
46
|
- lib/forrest/runner.rb~
|
45
47
|
- lib/object.rb
|
46
48
|
- lib/object.rb~
|