rspec-longrun 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -13
- data/examples/example_spec.rb +52 -0
- data/lib/rspec/longrun/formatter.rb +55 -13
- data/lib/rspec/longrun/version.rb +1 -1
- data/spec/rspec/longrun/formatter_spec.rb +22 -24
- metadata +5 -4
data/README.md
CHANGED
@@ -22,14 +22,13 @@ Specify the custom output format when invoking RSpec, as follows:
|
|
22
22
|
|
23
23
|
The resulting test output looks something like:
|
24
24
|
|
25
|
-
Example group
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
* Third example
|
31
|
-
PENDING (Not implemented yet)
|
25
|
+
Example group {
|
26
|
+
First example OK (1.2s)
|
27
|
+
Second example OK (3.4s)
|
28
|
+
Third example PENDING (Not implemented yet) (0.2s)
|
29
|
+
} (5.2s)
|
32
30
|
|
31
|
+
(though a little more colourful).
|
33
32
|
|
34
33
|
### Tracking progress
|
35
34
|
|
@@ -61,12 +60,13 @@ Include RSpec::Longrun::DSL to define the 'step' method, which can be used to gr
|
|
61
60
|
|
62
61
|
The resulting test output looks something like:
|
63
62
|
|
64
|
-
Account management
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
63
|
+
Account management {
|
64
|
+
Log in and alter preferences {
|
65
|
+
Log in (0.5s)
|
66
|
+
Navigate to preferences page (0.2s)
|
67
|
+
Change preferences (5.2s)
|
68
|
+
} OK (7.1s)
|
69
|
+
} OK (7.2s)
|
70
70
|
|
71
71
|
which gives you some extra context in the event that something fails, or hangs, during the test run.
|
72
72
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'rspec/longrun'
|
3
|
+
|
4
|
+
describe "Underpants gnomes" do
|
5
|
+
|
6
|
+
include RSpec::Longrun::DSL
|
7
|
+
|
8
|
+
it "The plan" do
|
9
|
+
step "Collect underpants" do
|
10
|
+
end
|
11
|
+
step "Umm ..." do
|
12
|
+
sleep 0.3 # thinking
|
13
|
+
end
|
14
|
+
step "Profit!" do
|
15
|
+
pending "need a real business plan"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "Killer app" do
|
22
|
+
|
23
|
+
include RSpec::Longrun::DSL
|
24
|
+
|
25
|
+
describe "Some feature" do
|
26
|
+
|
27
|
+
it "Scenario 1" do
|
28
|
+
step "Step 1" do
|
29
|
+
end
|
30
|
+
step "Step 2" do
|
31
|
+
end
|
32
|
+
step "Step 3" do
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it "Scenario 2" do
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "Another feature" do
|
42
|
+
|
43
|
+
it "Scenario" do
|
44
|
+
step "Step 1" do
|
45
|
+
end
|
46
|
+
step "Step 2" do
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -7,12 +7,12 @@ module RSpec
|
|
7
7
|
|
8
8
|
def initialize(output)
|
9
9
|
super(output)
|
10
|
-
@
|
10
|
+
@blocks = [Block.new(true)]
|
11
11
|
end
|
12
12
|
|
13
13
|
def example_group_started(example_group)
|
14
14
|
super(example_group)
|
15
|
-
|
15
|
+
begin_block(example_group.description)
|
16
16
|
end
|
17
17
|
|
18
18
|
def example_group_finished(example_group)
|
@@ -22,7 +22,7 @@ module RSpec
|
|
22
22
|
|
23
23
|
def example_started(example)
|
24
24
|
super(example)
|
25
|
-
|
25
|
+
begin_block(cyan(example.description))
|
26
26
|
end
|
27
27
|
|
28
28
|
def example_passed(example)
|
@@ -41,7 +41,7 @@ module RSpec
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def step_started(description)
|
44
|
-
|
44
|
+
begin_block(description)
|
45
45
|
end
|
46
46
|
|
47
47
|
def step_finished(description)
|
@@ -50,28 +50,70 @@ module RSpec
|
|
50
50
|
|
51
51
|
private
|
52
52
|
|
53
|
-
def
|
54
|
-
|
55
|
-
@indent_level += 1
|
53
|
+
def current_block
|
54
|
+
@blocks.last
|
56
55
|
end
|
57
56
|
|
58
|
-
def
|
59
|
-
|
60
|
-
|
57
|
+
def begin_block(message)
|
58
|
+
unless current_block.nested?
|
59
|
+
output << faint("{\n")
|
60
|
+
current_block.nested!
|
61
|
+
end
|
62
|
+
output << current_indentation
|
63
|
+
output << message.strip
|
64
|
+
output << ' '
|
65
|
+
@blocks.push(Block.new)
|
61
66
|
end
|
62
67
|
|
63
|
-
def
|
64
|
-
|
68
|
+
def end_block(message = nil)
|
69
|
+
block = @blocks.pop
|
70
|
+
block.finished!
|
71
|
+
if block.nested?
|
72
|
+
output << current_indentation
|
73
|
+
output << faint('} ')
|
74
|
+
end
|
75
|
+
if message
|
76
|
+
output << message.strip
|
77
|
+
output << ' '
|
78
|
+
end
|
79
|
+
output << faint('(' + block.timing + ')')
|
80
|
+
output << "\n"
|
65
81
|
end
|
66
82
|
|
67
83
|
def current_indentation
|
68
|
-
' ' * @
|
84
|
+
' ' * (@blocks.size - 1)
|
69
85
|
end
|
70
86
|
|
71
87
|
def faint(text)
|
72
88
|
color(text, "\e[2m")
|
73
89
|
end
|
74
90
|
|
91
|
+
class Block
|
92
|
+
|
93
|
+
def initialize(nested = false)
|
94
|
+
@began_at = Time.now
|
95
|
+
@nested = nested
|
96
|
+
end
|
97
|
+
|
98
|
+
def finished!
|
99
|
+
@finished_at = Time.now
|
100
|
+
end
|
101
|
+
|
102
|
+
def timing
|
103
|
+
delta = @finished_at - @began_at
|
104
|
+
'%.2fs' % delta
|
105
|
+
end
|
106
|
+
|
107
|
+
def nested!
|
108
|
+
@nested = true
|
109
|
+
end
|
110
|
+
|
111
|
+
def nested?
|
112
|
+
@nested
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
75
117
|
end
|
76
118
|
|
77
119
|
end
|
@@ -3,8 +3,6 @@ require "stringio"
|
|
3
3
|
|
4
4
|
describe RSpec::Longrun::Formatter do
|
5
5
|
|
6
|
-
include RSpec::Longrun::DSL
|
7
|
-
|
8
6
|
let(:output_buffer) { StringIO.new }
|
9
7
|
let(:formatter) { described_class.new(output_buffer) }
|
10
8
|
|
@@ -47,12 +45,14 @@ describe RSpec::Longrun::Formatter do
|
|
47
45
|
end
|
48
46
|
end
|
49
47
|
|
50
|
-
it "outputs nested group
|
48
|
+
it "outputs nested group names" do
|
51
49
|
output.should eql(undent(<<-EOF))
|
52
|
-
foo
|
53
|
-
bar
|
54
|
-
baz
|
55
|
-
|
50
|
+
foo {
|
51
|
+
bar {
|
52
|
+
baz (0.00s)
|
53
|
+
} (0.00s)
|
54
|
+
qux (0.00s)
|
55
|
+
} (0.00s)
|
56
56
|
EOF
|
57
57
|
end
|
58
58
|
|
@@ -74,13 +74,11 @@ describe RSpec::Longrun::Formatter do
|
|
74
74
|
|
75
75
|
it "outputs example names and status" do
|
76
76
|
output.should eql(undent(<<-EOF))
|
77
|
-
suite
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
* fails
|
83
|
-
FAILED
|
77
|
+
suite {
|
78
|
+
works OK (0.00s)
|
79
|
+
is unimplemented PENDING: implement me (0.00s)
|
80
|
+
fails FAILED (0.00s)
|
81
|
+
} (0.00s)
|
84
82
|
EOF
|
85
83
|
end
|
86
84
|
|
@@ -104,16 +102,16 @@ describe RSpec::Longrun::Formatter do
|
|
104
102
|
end
|
105
103
|
|
106
104
|
it "outputs steps" do
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
105
|
+
output.should eql(undent(<<-EOF))
|
106
|
+
suite {
|
107
|
+
has steps {
|
108
|
+
Collect underpants (0.00s)
|
109
|
+
Er ... {
|
110
|
+
(thinking) (0.00s)
|
111
|
+
} (0.00s)
|
112
|
+
} PENDING: Profit! (0.00s)
|
113
|
+
} (0.00s)
|
114
|
+
EOF
|
117
115
|
end
|
118
116
|
|
119
117
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-longrun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec-core
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- LICENSE
|
41
41
|
- README.md
|
42
42
|
- Rakefile
|
43
|
+
- examples/example_spec.rb
|
43
44
|
- lib/rspec/longrun.rb
|
44
45
|
- lib/rspec/longrun/core_ext.rb
|
45
46
|
- lib/rspec/longrun/dsl.rb
|
@@ -61,7 +62,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
62
|
version: '0'
|
62
63
|
segments:
|
63
64
|
- 0
|
64
|
-
hash: -
|
65
|
+
hash: -2839138365557975715
|
65
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
67
|
none: false
|
67
68
|
requirements:
|
@@ -70,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
71
|
version: '0'
|
71
72
|
segments:
|
72
73
|
- 0
|
73
|
-
hash: -
|
74
|
+
hash: -2839138365557975715
|
74
75
|
requirements: []
|
75
76
|
rubyforge_project:
|
76
77
|
rubygems_version: 1.8.23
|