rocha 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -0
- data/lib/rocha/version.rb +1 -1
- data/lib/rocha.rb +1 -0
- data/rocha.gemspec +3 -0
- data/spec/formatter_spec.rb +69 -0
- data/spec/reporter/example_group_spec.rb +64 -0
- data/spec/reporter/example_spec.rb +77 -0
- data/spec/reporter/metadata_spec.rb +73 -0
- data/spec/reporter_spec.rb +123 -0
- data/spec/spec_helper.rb +7 -0
- metadata +68 -2
data/Rakefile
CHANGED
data/lib/rocha/version.rb
CHANGED
data/lib/rocha.rb
CHANGED
data/rocha.gemspec
CHANGED
@@ -9,6 +9,9 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.homepage = ""
|
10
10
|
|
11
11
|
gem.add_dependency "colorize"
|
12
|
+
gem.add_dependency "activesupport"
|
13
|
+
gem.add_dependency "rake"
|
14
|
+
gem.add_development_dependency "rspec"
|
12
15
|
|
13
16
|
gem.files = `git ls-files`.split($\)
|
14
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rocha::Formatter do
|
4
|
+
let(:io) { StringIO.new }
|
5
|
+
subject { described_class.new(io) }
|
6
|
+
|
7
|
+
shared_examples "test result" do |method, dot|
|
8
|
+
it "stores the example in the examples array" do
|
9
|
+
subject.send(method, nil)
|
10
|
+
subject.examples.should be_present
|
11
|
+
end
|
12
|
+
|
13
|
+
it "outputs the dot" do
|
14
|
+
subject.send(method, nil)
|
15
|
+
io.rewind
|
16
|
+
io.read.should include(dot)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#example_passed" do
|
21
|
+
it_behaves_like "test result", :example_passed, "."
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#example_failed" do
|
25
|
+
it_behaves_like "test result", :example_failed, "F"
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#example_pending" do
|
29
|
+
it_behaves_like "test result", :example_pending, "P"
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#dump_pending" do
|
33
|
+
let(:example) { double('example', :pending? => true, :full_description => "Pending example") }
|
34
|
+
before { subject.stub(:examples => [example]) }
|
35
|
+
|
36
|
+
it "outputs the pending message" do
|
37
|
+
subject.dump_pending
|
38
|
+
io.rewind
|
39
|
+
io.read.should include(" Pending: Pending example")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#dump_failures" do
|
44
|
+
let(:example) do
|
45
|
+
double('example',
|
46
|
+
:failed? => true,
|
47
|
+
:full_description => "Failed example",
|
48
|
+
:exception => double('exception',
|
49
|
+
:message => "exception",
|
50
|
+
:backtrace => nil))
|
51
|
+
end
|
52
|
+
|
53
|
+
before { subject.stub(:examples => [example]) }
|
54
|
+
|
55
|
+
it "outputs the failure message" do
|
56
|
+
subject.dump_failures
|
57
|
+
io.rewind
|
58
|
+
io.read.should include(" Failed: Failed example\n exception")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#dump_summary" do
|
63
|
+
it "outputs the summary" do
|
64
|
+
subject.dump_summary(10, 10, 2, 3)
|
65
|
+
io.rewind
|
66
|
+
io.read.should == "\nFinished in 10.00 seconds\n10 examples, 2 failed, 3 pending\n"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rocha::Reporter::ExampleGroup do
|
4
|
+
subject { described_class.new({}, nil) }
|
5
|
+
|
6
|
+
describe "#initialize" do
|
7
|
+
it "loads up a metadata instance and the parent" do
|
8
|
+
data = double('data')
|
9
|
+
parent = double('parent')
|
10
|
+
example_group = described_class.new(data, parent)
|
11
|
+
|
12
|
+
example_group.parent.should == parent
|
13
|
+
example_group.metadata.should be_a(Rocha::Reporter::Metadata)
|
14
|
+
example_group.metadata.data.should == data
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "delegated methods" do
|
19
|
+
let(:metadata) { double('metadata') }
|
20
|
+
before { Rocha::Reporter::Metadata.stub(:new) { metadata } }
|
21
|
+
|
22
|
+
[:full_description, :description, :file_path, :described_class].each do |method|
|
23
|
+
it "delegates #{method} to metadata" do
|
24
|
+
metadata.should_receive(method)
|
25
|
+
subject.send(method)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "aliased_methods" do
|
31
|
+
it "aliases display_name to description" do
|
32
|
+
subject.display_name.should == subject.description
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#parent_groups" do
|
37
|
+
let(:parent) { double('parent') }
|
38
|
+
let(:grandparent) { double('grandparent') }
|
39
|
+
|
40
|
+
before do
|
41
|
+
grandparent.stub(:parent => nil)
|
42
|
+
parent.stub(:parent => grandparent)
|
43
|
+
subject.stub(:parent => parent)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "finds all of this group's ancestors" do
|
47
|
+
subject.parent_groups.should == [parent, grandparent]
|
48
|
+
end
|
49
|
+
|
50
|
+
it "works via #ancestors" do
|
51
|
+
subject.ancestors.should == [parent, grandparent]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#update_metadata" do
|
56
|
+
it "calls metadata.update" do
|
57
|
+
data = double('data')
|
58
|
+
metadata = double('metadata')
|
59
|
+
metadata.should_receive(:update).with(data)
|
60
|
+
Rocha::Reporter::Metadata.stub(:new) { metadata }
|
61
|
+
subject.update_metadata(data)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rocha::Reporter::Example do
|
4
|
+
subject { described_class.new({}, nil) }
|
5
|
+
|
6
|
+
describe "#initialize" do
|
7
|
+
it "loads up a metadata instance and the parent" do
|
8
|
+
data = double('data')
|
9
|
+
parent = double('parent')
|
10
|
+
example = described_class.new(data, parent)
|
11
|
+
|
12
|
+
example.parent.should == parent
|
13
|
+
example.metadata.should be_a(Rocha::Reporter::Metadata)
|
14
|
+
example.metadata.data.should == data
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "delegated methods" do
|
19
|
+
let(:metadata) { double('metadata') }
|
20
|
+
before { Rocha::Reporter::Metadata.stub(:new) { metadata } }
|
21
|
+
|
22
|
+
[:full_description, :description, :location, :file_path, :line_number, :pending, :pending_message, :exception, :execution_result].each do |method|
|
23
|
+
it "delegates #{method} to metadata" do
|
24
|
+
metadata.should_receive(method)
|
25
|
+
subject.send(method)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "aliased_methods" do
|
31
|
+
it "aliases pending? to pending" do
|
32
|
+
subject.pending?.should == subject.pending
|
33
|
+
end
|
34
|
+
|
35
|
+
it "aliases options to metadata" do
|
36
|
+
subject.options.should == subject.metadata
|
37
|
+
end
|
38
|
+
|
39
|
+
it "aliases example_group to parent" do
|
40
|
+
subject.example_group.should == subject.parent
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#passed?" do
|
45
|
+
it "returns true iff execution_result[:status] is passed" do
|
46
|
+
subject.should_receive(:execution_result) { {:status => "passed"} }
|
47
|
+
subject.passed?.should be_true
|
48
|
+
end
|
49
|
+
|
50
|
+
it "returns false" do
|
51
|
+
subject.should_receive(:execution_result) { {} }
|
52
|
+
subject.passed?.should be_false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#failed?" do
|
57
|
+
it "returns true iff execution_result[:status] is failed" do
|
58
|
+
subject.should_receive(:execution_result) { {:status => "failed"} }
|
59
|
+
subject.failed?.should be_true
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns false" do
|
63
|
+
subject.should_receive(:execution_result) { {} }
|
64
|
+
subject.failed?.should be_false
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "#update_metadata" do
|
69
|
+
it "calls metadata.update" do
|
70
|
+
data = double('data')
|
71
|
+
metadata = double('metadata')
|
72
|
+
metadata.should_receive(:update).with(data)
|
73
|
+
Rocha::Reporter::Metadata.stub(:new) { metadata }
|
74
|
+
subject.update_metadata(data)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rocha::Reporter::Metadata do
|
4
|
+
subject { described_class.new({}) }
|
5
|
+
|
6
|
+
describe "#[]" do
|
7
|
+
it "calls the method on self if available" do
|
8
|
+
subject.should_receive(:full_description)
|
9
|
+
subject[:full_description]
|
10
|
+
end
|
11
|
+
|
12
|
+
it "looks in the data hash" do
|
13
|
+
subject.should_receive(:data) { {} }
|
14
|
+
subject[:title]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#update" do
|
19
|
+
it "merges the new data into the data hash" do
|
20
|
+
subject.update(:title => "test")
|
21
|
+
subject.data.should == {:title => "test"}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#exception" do
|
26
|
+
it "returns unless the spec failed" do
|
27
|
+
subject.exception.should be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it "builds a SpecException object" do
|
31
|
+
subject.update('status' => 'failed', 'error' => {'name' => 'Error', 'message' => 'expected this to work'})
|
32
|
+
subject.exception.should be_a(Rocha::Reporter::SpecException)
|
33
|
+
subject.exception.message.should == 'Error: expected this to work'
|
34
|
+
subject.exception.backtrace.should == []
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#execution_result" do
|
39
|
+
it "returns a hash with execution details" do
|
40
|
+
subject.execution_result.keys.map(&:to_s).sort.should == [:exception, :finished_at, :run_time, :started_at, :status].map(&:to_s)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#pending" do
|
45
|
+
it "returns true iff status is pending" do
|
46
|
+
subject.update('status' => 'pending')
|
47
|
+
subject.pending.should be_true
|
48
|
+
end
|
49
|
+
|
50
|
+
it "returns false" do
|
51
|
+
subject.pending.should be_false
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
shared_examples_for "data delegation method" do |key, method|
|
56
|
+
it "returns data['#{key}']" do
|
57
|
+
subject.update(key => 'super test')
|
58
|
+
subject.send(method).should == 'super test'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#file_path" do
|
63
|
+
it_behaves_like "data delegation method", "path", "file_path"
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#description" do
|
67
|
+
it_behaves_like "data delegation method", "title", "description"
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#full_description" do
|
71
|
+
it_behaves_like "data delegation method", "fullTitle", "full_description"
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rocha::Reporter do
|
4
|
+
let(:formatter) { double('formatter').as_null_object }
|
5
|
+
subject { described_class.new(formatter) }
|
6
|
+
|
7
|
+
describe "#start" do
|
8
|
+
it "sets the start time to the current time" do
|
9
|
+
subject.start
|
10
|
+
subject.start_time.should be_within(1.second).of(Time.now)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "processes the start event" do
|
14
|
+
subject.should_receive(:process_event).with(:start, nil)
|
15
|
+
subject.start
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#finish" do
|
20
|
+
it "calls #stop" do
|
21
|
+
subject.should_receive(:stop)
|
22
|
+
subject.finish
|
23
|
+
end
|
24
|
+
|
25
|
+
it "processes events" do
|
26
|
+
subject.stub(:stop)
|
27
|
+
subject.should_receive(:process_event).with(:start_dump).ordered
|
28
|
+
subject.should_receive(:process_event).with(:dump_pending).ordered
|
29
|
+
subject.should_receive(:process_event).with(:dump_failures).ordered
|
30
|
+
subject.should_receive(:process_event).with(:dump_summary, nil, 0, 0, 0).ordered
|
31
|
+
subject.should_receive(:process_event).with(:close).ordered
|
32
|
+
subject.finish
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#stop" do
|
37
|
+
it "calculates duration" do
|
38
|
+
subject.start
|
39
|
+
subject.stop
|
40
|
+
subject.duration.should_not be_nil
|
41
|
+
end
|
42
|
+
|
43
|
+
it "processes the stop event" do
|
44
|
+
subject.should_receive(:process_event).with(:stop)
|
45
|
+
subject.stop
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#process_mocha_event" do
|
50
|
+
before { subject.stub(:process_event) }
|
51
|
+
|
52
|
+
it "calls #start if passed the start event" do
|
53
|
+
subject.should_receive(:start).with(4)
|
54
|
+
subject.process_mocha_event({'event' => 'start', 'testCount' => 4})
|
55
|
+
end
|
56
|
+
|
57
|
+
it "calls #finish if passed the end event" do
|
58
|
+
subject.should_receive(:finish)
|
59
|
+
subject.process_mocha_event({'event' => 'end'})
|
60
|
+
end
|
61
|
+
|
62
|
+
it "creates the object" do
|
63
|
+
subject.should_receive(:update_or_create_object).with('data', 'type')
|
64
|
+
subject.process_mocha_event({'data' => 'data', 'type' => 'type'})
|
65
|
+
end
|
66
|
+
|
67
|
+
it "calls #process_event with the converted event name" do
|
68
|
+
object = double('test')
|
69
|
+
subject.stub(:update_or_create_object) { object }
|
70
|
+
subject.should_receive(:process_event).with(:example_started, object)
|
71
|
+
subject.process_mocha_event({'event' => 'test', 'type' => 'test'})
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "#process_event" do
|
76
|
+
describe "increments counts" do
|
77
|
+
it "increments example count" do
|
78
|
+
subject.process_event(:example_started)
|
79
|
+
subject.example_count.should == 1
|
80
|
+
end
|
81
|
+
|
82
|
+
it "increments pending count" do
|
83
|
+
subject.process_event(:example_pending)
|
84
|
+
subject.pending_count.should == 1
|
85
|
+
end
|
86
|
+
|
87
|
+
it "increments failed count" do
|
88
|
+
subject.process_event(:example_failed)
|
89
|
+
subject.failure_count.should == 1
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it "forwards the call on to the formatters" do
|
94
|
+
formatter.should_receive(:example_started).with('arg!')
|
95
|
+
subject.process_event(:example_started, 'arg!')
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "#update_or_create_object" do
|
100
|
+
describe "creates the right type of object" do
|
101
|
+
it "creates example if test" do
|
102
|
+
subject.update_or_create_object({}, 'test').should be_a(Rocha::Reporter::Example)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "creates example_group if suite" do
|
106
|
+
subject.update_or_create_object({}, 'suite').should be_a(Rocha::Reporter::ExampleGroup)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
it "updates if the object with same fullTitle exists" do
|
111
|
+
data = {'fullTitle' => 'title'}
|
112
|
+
object = subject.update_or_create_object(data, 'test')
|
113
|
+
object.should_receive(:update_metadata).with(data)
|
114
|
+
subject.update_or_create_object(data, 'test').should == object
|
115
|
+
end
|
116
|
+
|
117
|
+
it "links up the parent correctly" do
|
118
|
+
suite = subject.update_or_create_object({'fullTitle' => 'suite'}, 'suite')
|
119
|
+
object = subject.update_or_create_object({'fullTitle' => 'suite awesome', 'parentFullTitle' => 'suite'}, 'test')
|
120
|
+
object.parent.should == suite
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rocha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,6 +27,54 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: activesupport
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
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'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
30
78
|
description: RSpec reporter for mocha
|
31
79
|
email:
|
32
80
|
- paul@chavard.net
|
@@ -47,6 +95,12 @@ files:
|
|
47
95
|
- lib/rocha/reporter/metadata.rb
|
48
96
|
- lib/rocha/version.rb
|
49
97
|
- rocha.gemspec
|
98
|
+
- spec/formatter_spec.rb
|
99
|
+
- spec/reporter/example_group_spec.rb
|
100
|
+
- spec/reporter/example_spec.rb
|
101
|
+
- spec/reporter/metadata_spec.rb
|
102
|
+
- spec/reporter_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
50
104
|
homepage: ''
|
51
105
|
licenses: []
|
52
106
|
post_install_message:
|
@@ -59,16 +113,28 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
113
|
- - ! '>='
|
60
114
|
- !ruby/object:Gem::Version
|
61
115
|
version: '0'
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
hash: 1361958445993374469
|
62
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
120
|
none: false
|
64
121
|
requirements:
|
65
122
|
- - ! '>='
|
66
123
|
- !ruby/object:Gem::Version
|
67
124
|
version: '0'
|
125
|
+
segments:
|
126
|
+
- 0
|
127
|
+
hash: 1361958445993374469
|
68
128
|
requirements: []
|
69
129
|
rubyforge_project:
|
70
130
|
rubygems_version: 1.8.23
|
71
131
|
signing_key:
|
72
132
|
specification_version: 3
|
73
133
|
summary: RSpec reporter for mocha
|
74
|
-
test_files:
|
134
|
+
test_files:
|
135
|
+
- spec/formatter_spec.rb
|
136
|
+
- spec/reporter/example_group_spec.rb
|
137
|
+
- spec/reporter/example_spec.rb
|
138
|
+
- spec/reporter/metadata_spec.rb
|
139
|
+
- spec/reporter_spec.rb
|
140
|
+
- spec/spec_helper.rb
|