rspec 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +78 -1
- data/EXAMPLES.rd +8 -5
- data/README +1 -0
- data/Rakefile +1 -1
- data/examples/pending_example.rb +20 -0
- data/lib/autotest/rspec.rb +46 -18
- data/lib/spec/dsl.rb +1 -0
- data/lib/spec/dsl/behaviour.rb +37 -27
- data/lib/spec/dsl/behaviour_callbacks.rb +4 -0
- data/lib/spec/dsl/behaviour_eval.rb +27 -16
- data/lib/spec/dsl/behaviour_factory.rb +2 -2
- data/lib/spec/dsl/composite_proc_builder.rb +9 -4
- data/lib/spec/dsl/configuration.rb +20 -4
- data/lib/spec/dsl/description.rb +7 -0
- data/lib/spec/dsl/errors.rb +9 -0
- data/lib/spec/dsl/example.rb +18 -10
- data/lib/spec/matchers/have.rb +10 -13
- data/lib/spec/matchers/operator_matcher.rb +3 -3
- data/lib/spec/matchers/raise_error.rb +8 -3
- data/lib/spec/mocks/error_generator.rb +1 -1
- data/lib/spec/mocks/message_expectation.rb +11 -0
- data/lib/spec/mocks/methods.rb +9 -5
- data/lib/spec/mocks/proxy.rb +13 -9
- data/lib/spec/rake/spectask.rb +80 -38
- data/lib/spec/runner/backtrace_tweaker.rb +2 -1
- data/lib/spec/runner/behaviour_runner.rb +37 -16
- data/lib/spec/runner/formatter/base_formatter.rb +23 -15
- data/lib/spec/runner/formatter/base_text_formatter.rb +39 -11
- data/lib/spec/runner/formatter/failing_behaviours_formatter.rb +7 -3
- data/lib/spec/runner/formatter/failing_examples_formatter.rb +3 -3
- data/lib/spec/runner/formatter/html_formatter.rb +32 -25
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +6 -5
- data/lib/spec/runner/formatter/rdoc_formatter.rb +6 -6
- data/lib/spec/runner/formatter/specdoc_formatter.rb +7 -6
- data/lib/spec/runner/option_parser.rb +6 -5
- data/lib/spec/runner/options.rb +60 -43
- data/lib/spec/runner/reporter.rb +17 -6
- data/lib/spec/runner/spec_parser.rb +1 -1
- data/lib/spec/translator.rb +8 -0
- data/lib/spec/version.rb +3 -3
- data/plugins/mock_frameworks/flexmock.rb +14 -18
- data/plugins/mock_frameworks/mocha.rb +0 -2
- data/plugins/mock_frameworks/rr.rb +21 -0
- data/spec/autotest/discover_spec.rb +19 -0
- data/spec/autotest/rspec_spec.rb +257 -0
- data/spec/autotest_helper.rb +4 -0
- data/spec/spec/dsl/behaviour_eval_spec.rb +30 -0
- data/spec/spec/dsl/behaviour_factory_spec.rb +18 -0
- data/spec/spec/dsl/behaviour_spec.rb +95 -58
- data/spec/spec/dsl/composite_proc_builder_spec.rb +0 -13
- data/spec/spec/dsl/configuration_spec.rb +6 -1
- data/spec/spec/dsl/description_spec.rb +9 -1
- data/spec/spec/dsl/example_class_spec.rb +3 -3
- data/spec/spec/dsl/example_instance_spec.rb +26 -28
- data/spec/spec/dsl/example_matcher_spec.rb +91 -0
- data/spec/spec/dsl/shared_behaviour_spec.rb +24 -0
- data/spec/spec/expectations/extensions/object_spec.rb +2 -2
- data/spec/spec/expectations/fail_with_spec.rb +2 -2
- data/spec/spec/matchers/have_spec.rb +1 -1
- data/spec/spec/matchers/operator_matcher_spec.rb +10 -10
- data/spec/spec/matchers/raise_error_spec.rb +38 -0
- data/spec/spec/mocks/argument_expectation_spec.rb +18 -14
- data/spec/spec/mocks/at_most_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_11545_spec.rb +31 -0
- data/spec/spec/mocks/partial_mock_spec.rb +33 -1
- data/spec/spec/runner/behaviour_runner_spec.rb +72 -49
- data/spec/spec/runner/command_line_spec.rb +1 -1
- data/spec/spec/runner/context_matching_spec.rb +10 -10
- data/spec/spec/runner/drb_command_line_spec.rb +62 -59
- data/spec/spec/runner/extensions/bug_report_10577_spec.rb +35 -0
- data/spec/spec/runner/formatter/failing_behaviours_formatter_spec.rb +15 -2
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +3 -3
- data/spec/spec/runner/formatter/html_formatter_spec.rb +1 -1
- data/spec/spec/runner/formatter/progress_bar_formatter_dry_run_spec.rb +14 -15
- data/spec/spec/runner/formatter/progress_bar_formatter_failure_dump_spec.rb +1 -1
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +42 -9
- data/spec/spec/runner/formatter/rdoc_formatter_spec.rb +40 -40
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +55 -49
- data/spec/spec/runner/option_parser_spec.rb +16 -15
- data/spec/spec/runner/options_spec.rb +64 -31
- data/spec/spec/runner/reporter_spec.rb +67 -15
- data/spec/spec/spec_classes.rb +9 -1
- data/spec/spec/translator_spec.rb +48 -0
- data/spec/spec_helper.rb +5 -2
- metadata +13 -6
- data/examples/not_yet_implemented_spec.rb +0 -12
- data/spec/spec/runner/example_matcher_spec.rb +0 -127
@@ -24,6 +24,44 @@ describe "should_not raise_error" do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
describe "should raise_error(message)" do
|
28
|
+
it "should pass if RuntimeError is raised with the right message" do
|
29
|
+
lambda {raise 'blah'}.should raise_error('blah')
|
30
|
+
end
|
31
|
+
it "should pass if any other error is raised with the right message" do
|
32
|
+
lambda {raise NameError.new('blah')}.should raise_error('blah')
|
33
|
+
end
|
34
|
+
it "should fail if RuntimeError error is raised with the wrong message" do
|
35
|
+
lambda do
|
36
|
+
lambda {raise 'blarg'}.should raise_error('blah')
|
37
|
+
end.should fail_with("expected Exception with \"blah\", got #<RuntimeError: blarg>")
|
38
|
+
end
|
39
|
+
it "should fail if any other error is raised with the wrong message" do
|
40
|
+
lambda do
|
41
|
+
lambda {raise NameError.new('blarg')}.should raise_error('blah')
|
42
|
+
end.should fail_with("expected Exception with \"blah\", got #<NameError: blarg>")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "should_not raise_error(message)" do
|
47
|
+
it "should pass if RuntimeError error is raised with the different message" do
|
48
|
+
lambda {raise 'blarg'}.should_not raise_error('blah')
|
49
|
+
end
|
50
|
+
it "should pass if any other error is raised with the wrong message" do
|
51
|
+
lambda {raise NameError.new('blarg')}.should_not raise_error('blah')
|
52
|
+
end
|
53
|
+
it "should fail if RuntimeError is raised with message" do
|
54
|
+
lambda do
|
55
|
+
lambda {raise 'blah'}.should_not raise_error('blah')
|
56
|
+
end.should fail_with(%Q|expected no Exception with "blah", got #<RuntimeError: blah>|)
|
57
|
+
end
|
58
|
+
it "should fail if any other error is raised with message" do
|
59
|
+
lambda do
|
60
|
+
lambda {raise NameError.new('blah')}.should_not raise_error('blah')
|
61
|
+
end.should fail_with(%Q|expected no Exception with "blah", got #<NameError: blah>|)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
27
65
|
describe "should raise_error(NamedError)" do
|
28
66
|
it "should pass if named error is raised" do
|
29
67
|
lambda { non_existent_method }.should raise_error(NameError)
|
@@ -1,19 +1,23 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
module Spec
|
4
|
+
module Mocks
|
5
|
+
describe ArgumentExpectation do
|
6
|
+
it "should consider an object that responds to #matches? and #description to be a matcher" do
|
7
|
+
argument_expecatation = Spec::Mocks::ArgumentExpectation.new([])
|
8
|
+
obj = mock("matcher")
|
9
|
+
obj.should_receive(:respond_to?).with(:matches?).and_return(true)
|
10
|
+
obj.should_receive(:respond_to?).with(:description).and_return(true)
|
11
|
+
argument_expecatation.is_matcher?(obj).should be_true
|
12
|
+
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
it "should NOT consider an object that only responds to #matches? to be a matcher" do
|
15
|
+
argument_expecatation = Spec::Mocks::ArgumentExpectation.new([])
|
16
|
+
obj = mock("matcher")
|
17
|
+
obj.should_receive(:respond_to?).with(:matches?).and_return(true)
|
18
|
+
obj.should_receive(:respond_to?).with(:description).and_return(false)
|
19
|
+
argument_expecatation.is_matcher?(obj).should be_false
|
20
|
+
end
|
21
|
+
end
|
18
22
|
end
|
19
23
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
class LiarLiarPantsOnFire
|
4
|
+
def respond_to?(sym)
|
5
|
+
true
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.respond_to?(sym)
|
9
|
+
true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'should_receive' do
|
14
|
+
before(:each) do
|
15
|
+
@liar = LiarLiarPantsOnFire.new
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should work when object lies about responding to a method" do
|
19
|
+
@liar.should_receive(:something)
|
20
|
+
@liar.something
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should work when class lies about responding to a method' do
|
24
|
+
LiarLiarPantsOnFire.should_receive(:something)
|
25
|
+
LiarLiarPantsOnFire.something
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should cleanup after itself' do
|
29
|
+
LiarLiarPantsOnFire.metaclass.instance_methods.should_not include("something")
|
30
|
+
end
|
31
|
+
end
|
@@ -6,7 +6,20 @@ module Spec
|
|
6
6
|
before(:each) do
|
7
7
|
@object = Object.new
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
|
+
it "should name the class in the failure message" do
|
11
|
+
@object.should_receive(:foo)
|
12
|
+
lambda do
|
13
|
+
@object.rspec_verify
|
14
|
+
end.should raise_error(Spec::Mocks::MockExpectationError, /Object/)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should not conflict with @options in the object" do
|
18
|
+
@object.instance_eval { @options = Object.new }
|
19
|
+
@object.should_receive(:blah)
|
20
|
+
@object.blah
|
21
|
+
end
|
22
|
+
|
10
23
|
it "should_not_receive should mock out the method" do
|
11
24
|
@object.should_not_receive(:fuhbar)
|
12
25
|
@object.fuhbar
|
@@ -47,6 +60,25 @@ module Spec
|
|
47
60
|
end.should raise_error(Spec::Mocks::MockExpectationError)
|
48
61
|
end
|
49
62
|
|
63
|
+
it "should_receive should also take a String argument" do
|
64
|
+
@object.should_receive('foobar')
|
65
|
+
@object.foobar
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should_not_receive should also take a String argument" do
|
69
|
+
@object.should_not_receive('foobar')
|
70
|
+
@object.foobar
|
71
|
+
lambda do
|
72
|
+
@object.rspec_verify
|
73
|
+
end.should raise_error(Spec::Mocks::MockExpectationError)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should use report nil in the error message" do
|
77
|
+
@this_will_resolve_to_nil.should_receive(:foobar)
|
78
|
+
lambda do
|
79
|
+
@this_will_resolve_to_nil.rspec_verify
|
80
|
+
end.should raise_error(Spec::Mocks::MockExpectationError, /NilClass.*expected :foobar with/)
|
81
|
+
end
|
50
82
|
end
|
51
83
|
end
|
52
84
|
end
|
@@ -4,7 +4,9 @@ module Spec
|
|
4
4
|
module Runner
|
5
5
|
describe BehaviourRunner, "#add_behaviour affecting passed in behaviour" do
|
6
6
|
before do
|
7
|
-
@
|
7
|
+
@err = StringIO.new('')
|
8
|
+
@out = StringIO.new('')
|
9
|
+
@options = Options.new(@err,@out)
|
8
10
|
@runner = BehaviourRunner.new(@options)
|
9
11
|
class << @runner
|
10
12
|
attr_reader :behaviours
|
@@ -49,7 +51,9 @@ module Spec
|
|
49
51
|
|
50
52
|
describe BehaviourRunner, "#add_behaviour affecting behaviours" do
|
51
53
|
before do
|
52
|
-
@
|
54
|
+
@err = StringIO.new('')
|
55
|
+
@out = StringIO.new('')
|
56
|
+
@options = Options.new(@err,@out)
|
53
57
|
@runner = BehaviourRunner.new(@options)
|
54
58
|
class << @runner
|
55
59
|
attr_reader :behaviours
|
@@ -91,27 +95,32 @@ module Spec
|
|
91
95
|
end
|
92
96
|
|
93
97
|
describe BehaviourRunner do
|
98
|
+
before do
|
99
|
+
@err = StringIO.new('')
|
100
|
+
@out = StringIO.new('')
|
101
|
+
@options = Options.new(@err,@out)
|
102
|
+
end
|
94
103
|
|
95
104
|
it "should only run behaviours with at least one example" do
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
105
|
+
desired_behaviour = mock("desired behaviour")
|
106
|
+
desired_behaviour.should_receive(:run)
|
107
|
+
desired_behaviour.should_receive(:retain_examples_matching!)
|
108
|
+
desired_behaviour.should_receive(:number_of_examples).twice.and_return(1)
|
109
|
+
desired_behaviour.should_receive(:shared?).and_return(false)
|
110
|
+
desired_behaviour.should_receive(:set_sequence_numbers).with(0, anything)
|
111
|
+
|
112
|
+
other_behaviour = mock("other behaviour")
|
113
|
+
other_behaviour.should_receive(:run).never
|
114
|
+
other_behaviour.should_receive(:retain_examples_matching!)
|
115
|
+
other_behaviour.should_receive(:number_of_examples).and_return(0)
|
106
116
|
|
107
117
|
reporter = mock("reporter")
|
108
|
-
options =
|
109
|
-
options.
|
110
|
-
options.examples = ["desired context legal spec"]
|
118
|
+
@options.reporter = reporter
|
119
|
+
@options.examples = ["desired behaviour legal spec"]
|
111
120
|
|
112
|
-
runner = Spec::Runner::BehaviourRunner.new(options)
|
113
|
-
runner.add_behaviour(
|
114
|
-
runner.add_behaviour(
|
121
|
+
runner = Spec::Runner::BehaviourRunner.new(@options)
|
122
|
+
runner.add_behaviour(desired_behaviour)
|
123
|
+
runner.add_behaviour(other_behaviour)
|
115
124
|
reporter.should_receive(:start)
|
116
125
|
reporter.should_receive(:end)
|
117
126
|
reporter.should_receive(:dump)
|
@@ -119,7 +128,7 @@ module Spec
|
|
119
128
|
end
|
120
129
|
|
121
130
|
it "should dump even if Interrupt exception is occurred" do
|
122
|
-
behaviour = Spec::DSL::Behaviour.new("
|
131
|
+
behaviour = Spec::DSL::Behaviour.new("behaviour") do
|
123
132
|
it "no error" do
|
124
133
|
end
|
125
134
|
|
@@ -130,7 +139,7 @@ module Spec
|
|
130
139
|
|
131
140
|
reporter = mock("reporter")
|
132
141
|
reporter.should_receive(:start)
|
133
|
-
reporter.should_receive(:add_behaviour)
|
142
|
+
reporter.should_receive(:add_behaviour)
|
134
143
|
reporter.should_receive(:example_started).twice
|
135
144
|
reporter.should_receive(:example_finished).twice
|
136
145
|
reporter.should_receive(:rspec_verify)
|
@@ -138,18 +147,17 @@ module Spec
|
|
138
147
|
reporter.should_receive(:end)
|
139
148
|
reporter.should_receive(:dump)
|
140
149
|
|
141
|
-
options =
|
142
|
-
|
143
|
-
runner = Spec::Runner::BehaviourRunner.new(options)
|
150
|
+
@options.reporter = reporter
|
151
|
+
runner = Spec::Runner::BehaviourRunner.new(@options)
|
144
152
|
runner.add_behaviour(behaviour)
|
145
153
|
runner.run([], false)
|
146
154
|
end
|
147
155
|
|
148
156
|
it "should heckle when options have heckle_runner" do
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
157
|
+
behaviour = mock("behaviour", :null_object => true)
|
158
|
+
behaviour.should_receive(:number_of_examples).twice.and_return(1)
|
159
|
+
behaviour.should_receive(:run).and_return(0)
|
160
|
+
behaviour.should_receive(:shared?).and_return(false)
|
153
161
|
|
154
162
|
reporter = mock("reporter")
|
155
163
|
reporter.should_receive(:start).with(1)
|
@@ -159,39 +167,39 @@ module Spec
|
|
159
167
|
heckle_runner = mock("heckle_runner")
|
160
168
|
heckle_runner.should_receive(:heckle_with)
|
161
169
|
|
162
|
-
options =
|
163
|
-
options.
|
164
|
-
options.heckle_runner = heckle_runner
|
170
|
+
@options.reporter = reporter
|
171
|
+
@options.heckle_runner = heckle_runner
|
165
172
|
|
166
|
-
runner = Spec::Runner::BehaviourRunner.new(options)
|
167
|
-
runner.add_behaviour(
|
173
|
+
runner = Spec::Runner::BehaviourRunner.new(@options)
|
174
|
+
runner.add_behaviour(behaviour)
|
168
175
|
runner.run([], false)
|
169
176
|
end
|
170
177
|
|
171
|
-
it "should run
|
172
|
-
options =
|
173
|
-
options.reverse = true
|
178
|
+
it "should run examples backwards if options.reverse is true" do
|
179
|
+
@options.reverse = true
|
174
180
|
|
175
181
|
reporter = mock("reporter")
|
176
182
|
reporter.should_receive(:start).with(3)
|
177
183
|
reporter.should_receive(:end)
|
178
184
|
reporter.should_receive(:dump).and_return(0)
|
179
|
-
options.reporter = reporter
|
180
|
-
|
181
|
-
runner = Spec::Runner::BehaviourRunner.new(options)
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
185
|
+
@options.reporter = reporter
|
186
|
+
|
187
|
+
runner = Spec::Runner::BehaviourRunner.new(@options)
|
188
|
+
b1 = mock("b1")
|
189
|
+
b1.should_receive(:number_of_examples).twice.and_return(1)
|
190
|
+
b1.should_receive(:shared?).and_return(false)
|
191
|
+
b1.should_receive(:set_sequence_numbers).with(12, true).and_return(18)
|
192
|
+
|
193
|
+
b2 = mock("b2")
|
194
|
+
b2.should_receive(:number_of_examples).twice.and_return(2)
|
195
|
+
b2.should_receive(:shared?).and_return(false)
|
196
|
+
b2.should_receive(:set_sequence_numbers).with(0, true).and_return(12)
|
197
|
+
b2.should_receive(:run) do
|
198
|
+
b1.should_receive(:run)
|
191
199
|
end
|
192
200
|
|
193
|
-
runner.add_behaviour(
|
194
|
-
runner.add_behaviour(
|
201
|
+
runner.add_behaviour(b1)
|
202
|
+
runner.add_behaviour(b2)
|
195
203
|
|
196
204
|
runner.run([], false)
|
197
205
|
end
|
@@ -201,6 +209,21 @@ module Spec
|
|
201
209
|
config.should equal(Spec::Runner.configuration)
|
202
210
|
end
|
203
211
|
end
|
212
|
+
|
213
|
+
it "should pass its Description to the reporter" do
|
214
|
+
behaviour = Spec::DSL::Behaviour.new("behaviour") do
|
215
|
+
it "should" do
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
reporter = mock("reporter", :null_object => true)
|
220
|
+
reporter.should_receive(:add_behaviour).with(an_instance_of(Spec::DSL::Description))
|
221
|
+
|
222
|
+
@options.reporter = reporter
|
223
|
+
runner = Spec::Runner::BehaviourRunner.new(@options)
|
224
|
+
runner.add_behaviour(behaviour)
|
225
|
+
runner.run([], false)
|
226
|
+
end
|
204
227
|
end
|
205
228
|
end
|
206
229
|
end
|
@@ -2,24 +2,24 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
2
|
|
3
3
|
module Spec
|
4
4
|
module DSL
|
5
|
-
describe
|
5
|
+
describe Behaviour do
|
6
6
|
|
7
7
|
before(:each) do
|
8
8
|
@formatter = Spec::Mocks::Mock.new("formatter")
|
9
|
-
@behaviour = Behaviour.new("
|
9
|
+
@behaviour = Behaviour.new("behaviour") {}
|
10
10
|
end
|
11
11
|
|
12
|
-
it "
|
13
|
-
@behaviour.it("
|
14
|
-
@behaviour.it("
|
15
|
-
@behaviour.retain_examples_matching!(["
|
12
|
+
it "should retain examples that don't match" do
|
13
|
+
@behaviour.it("example1") {}
|
14
|
+
@behaviour.it("example2") {}
|
15
|
+
@behaviour.retain_examples_matching!(["behaviour"])
|
16
16
|
@behaviour.number_of_examples.should == 2
|
17
17
|
end
|
18
18
|
|
19
|
-
it "should
|
20
|
-
@behaviour.it("
|
21
|
-
@behaviour.it("
|
22
|
-
@behaviour.retain_examples_matching!(["
|
19
|
+
it "should remove examples that match" do
|
20
|
+
@behaviour.it("example1") {}
|
21
|
+
@behaviour.it("example2") {}
|
22
|
+
@behaviour.retain_examples_matching!(["behaviour example1"])
|
23
23
|
@behaviour.number_of_examples.should == 1
|
24
24
|
end
|
25
25
|
end
|
@@ -1,81 +1,84 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
2
|
|
3
|
-
|
3
|
+
module Spec
|
4
|
+
module Runner
|
5
|
+
describe DrbCommandLine, "without running local server" do
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
unless Config::CONFIG['ruby_install_name'] == 'jruby'
|
8
|
+
it "should print error when there is no running local server" do
|
9
|
+
err = StringIO.new
|
10
|
+
out = StringIO.new
|
11
|
+
DrbCommandLine.run(['--version'], err, out, false)
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
err.rewind
|
14
|
+
err.read.should =~ /No server is running/
|
15
|
+
end
|
16
|
+
end
|
13
17
|
end
|
14
|
-
end
|
15
|
-
end
|
16
18
|
|
17
|
-
describe
|
19
|
+
describe DrbCommandLine, "with local server" do
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
unless Config::CONFIG['ruby_install_name'] == 'jruby'
|
22
|
+
before(:all) do
|
23
|
+
DRb.start_service("druby://localhost:8989", Spec::Runner::CommandLine)
|
24
|
+
$drb_example_file_counter = 0
|
25
|
+
end
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
before(:each) do
|
28
|
+
create_dummy_spec_file
|
29
|
+
$drb_example_file_counter = $drb_example_file_counter + 1
|
30
|
+
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
after(:each) do
|
33
|
+
File.delete(@dummy_spec_filename)
|
34
|
+
end
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
after(:all) do
|
37
|
+
DRb.stop_service
|
38
|
+
end
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
it "should run against local server" do
|
41
|
+
out = run_spec_via_druby(['--version'])
|
42
|
+
out.should =~ /RSpec/n
|
43
|
+
end
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
it "should output green colorized text when running with --colour option" do
|
46
|
+
out = run_spec_via_druby(["--colour", @dummy_spec_filename])
|
47
|
+
out.should =~ /\e\[32m/n
|
48
|
+
end
|
47
49
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
it "should output red colorized text when running with -c option" do
|
51
|
+
out = run_spec_via_druby(["-c", @dummy_spec_filename])
|
52
|
+
out.should =~ /\e\[31m/n
|
53
|
+
end
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
describe "DUMMY CONTEXT for 'DrbCommandLine with -c option'" do
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
def create_dummy_spec_file
|
56
|
+
@dummy_spec_filename = File.expand_path(File.dirname(__FILE__)) + "/_dummy_spec#{$drb_example_file_counter}.rb"
|
57
|
+
File.open(@dummy_spec_filename, 'w') do |f|
|
58
|
+
f.write %{
|
59
|
+
describe "DUMMY CONTEXT for 'DrbCommandLine with -c option'" do
|
60
|
+
it "should be output with green bar" do
|
61
|
+
true.should be_true
|
62
|
+
end
|
61
63
|
|
62
|
-
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|
66
|
-
}
|
64
|
+
it "should be output with red bar" do
|
65
|
+
violated("I want to see a red bar!")
|
67
66
|
end
|
68
67
|
end
|
68
|
+
}
|
69
|
+
end
|
70
|
+
end
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
72
|
+
def run_spec_via_druby(args)
|
73
|
+
err, out = StringIO.new, StringIO.new
|
74
|
+
out.instance_eval do
|
75
|
+
def tty?; true end
|
76
|
+
end
|
77
|
+
Spec::Runner::DrbCommandLine.run(args, err, out, false, true)
|
78
|
+
out.rewind; out.read
|
79
|
+
end
|
74
80
|
end
|
75
|
-
|
76
|
-
out.rewind; out.read
|
81
|
+
|
77
82
|
end
|
78
83
|
end
|
79
|
-
|
80
84
|
end
|
81
|
-
|