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.
Files changed (87) hide show
  1. data/CHANGES +78 -1
  2. data/EXAMPLES.rd +8 -5
  3. data/README +1 -0
  4. data/Rakefile +1 -1
  5. data/examples/pending_example.rb +20 -0
  6. data/lib/autotest/rspec.rb +46 -18
  7. data/lib/spec/dsl.rb +1 -0
  8. data/lib/spec/dsl/behaviour.rb +37 -27
  9. data/lib/spec/dsl/behaviour_callbacks.rb +4 -0
  10. data/lib/spec/dsl/behaviour_eval.rb +27 -16
  11. data/lib/spec/dsl/behaviour_factory.rb +2 -2
  12. data/lib/spec/dsl/composite_proc_builder.rb +9 -4
  13. data/lib/spec/dsl/configuration.rb +20 -4
  14. data/lib/spec/dsl/description.rb +7 -0
  15. data/lib/spec/dsl/errors.rb +9 -0
  16. data/lib/spec/dsl/example.rb +18 -10
  17. data/lib/spec/matchers/have.rb +10 -13
  18. data/lib/spec/matchers/operator_matcher.rb +3 -3
  19. data/lib/spec/matchers/raise_error.rb +8 -3
  20. data/lib/spec/mocks/error_generator.rb +1 -1
  21. data/lib/spec/mocks/message_expectation.rb +11 -0
  22. data/lib/spec/mocks/methods.rb +9 -5
  23. data/lib/spec/mocks/proxy.rb +13 -9
  24. data/lib/spec/rake/spectask.rb +80 -38
  25. data/lib/spec/runner/backtrace_tweaker.rb +2 -1
  26. data/lib/spec/runner/behaviour_runner.rb +37 -16
  27. data/lib/spec/runner/formatter/base_formatter.rb +23 -15
  28. data/lib/spec/runner/formatter/base_text_formatter.rb +39 -11
  29. data/lib/spec/runner/formatter/failing_behaviours_formatter.rb +7 -3
  30. data/lib/spec/runner/formatter/failing_examples_formatter.rb +3 -3
  31. data/lib/spec/runner/formatter/html_formatter.rb +32 -25
  32. data/lib/spec/runner/formatter/progress_bar_formatter.rb +6 -5
  33. data/lib/spec/runner/formatter/rdoc_formatter.rb +6 -6
  34. data/lib/spec/runner/formatter/specdoc_formatter.rb +7 -6
  35. data/lib/spec/runner/option_parser.rb +6 -5
  36. data/lib/spec/runner/options.rb +60 -43
  37. data/lib/spec/runner/reporter.rb +17 -6
  38. data/lib/spec/runner/spec_parser.rb +1 -1
  39. data/lib/spec/translator.rb +8 -0
  40. data/lib/spec/version.rb +3 -3
  41. data/plugins/mock_frameworks/flexmock.rb +14 -18
  42. data/plugins/mock_frameworks/mocha.rb +0 -2
  43. data/plugins/mock_frameworks/rr.rb +21 -0
  44. data/spec/autotest/discover_spec.rb +19 -0
  45. data/spec/autotest/rspec_spec.rb +257 -0
  46. data/spec/autotest_helper.rb +4 -0
  47. data/spec/spec/dsl/behaviour_eval_spec.rb +30 -0
  48. data/spec/spec/dsl/behaviour_factory_spec.rb +18 -0
  49. data/spec/spec/dsl/behaviour_spec.rb +95 -58
  50. data/spec/spec/dsl/composite_proc_builder_spec.rb +0 -13
  51. data/spec/spec/dsl/configuration_spec.rb +6 -1
  52. data/spec/spec/dsl/description_spec.rb +9 -1
  53. data/spec/spec/dsl/example_class_spec.rb +3 -3
  54. data/spec/spec/dsl/example_instance_spec.rb +26 -28
  55. data/spec/spec/dsl/example_matcher_spec.rb +91 -0
  56. data/spec/spec/dsl/shared_behaviour_spec.rb +24 -0
  57. data/spec/spec/expectations/extensions/object_spec.rb +2 -2
  58. data/spec/spec/expectations/fail_with_spec.rb +2 -2
  59. data/spec/spec/matchers/have_spec.rb +1 -1
  60. data/spec/spec/matchers/operator_matcher_spec.rb +10 -10
  61. data/spec/spec/matchers/raise_error_spec.rb +38 -0
  62. data/spec/spec/mocks/argument_expectation_spec.rb +18 -14
  63. data/spec/spec/mocks/at_most_spec.rb +1 -1
  64. data/spec/spec/mocks/bug_report_11545_spec.rb +31 -0
  65. data/spec/spec/mocks/partial_mock_spec.rb +33 -1
  66. data/spec/spec/runner/behaviour_runner_spec.rb +72 -49
  67. data/spec/spec/runner/command_line_spec.rb +1 -1
  68. data/spec/spec/runner/context_matching_spec.rb +10 -10
  69. data/spec/spec/runner/drb_command_line_spec.rb +62 -59
  70. data/spec/spec/runner/extensions/bug_report_10577_spec.rb +35 -0
  71. data/spec/spec/runner/formatter/failing_behaviours_formatter_spec.rb +15 -2
  72. data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +3 -3
  73. data/spec/spec/runner/formatter/html_formatter_spec.rb +1 -1
  74. data/spec/spec/runner/formatter/progress_bar_formatter_dry_run_spec.rb +14 -15
  75. data/spec/spec/runner/formatter/progress_bar_formatter_failure_dump_spec.rb +1 -1
  76. data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +42 -9
  77. data/spec/spec/runner/formatter/rdoc_formatter_spec.rb +40 -40
  78. data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +55 -49
  79. data/spec/spec/runner/option_parser_spec.rb +16 -15
  80. data/spec/spec/runner/options_spec.rb +64 -31
  81. data/spec/spec/runner/reporter_spec.rb +67 -15
  82. data/spec/spec/spec_classes.rb +9 -1
  83. data/spec/spec/translator_spec.rb +48 -0
  84. data/spec/spec_helper.rb +5 -2
  85. metadata +13 -6
  86. data/examples/not_yet_implemented_spec.rb +0 -12
  87. 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
- describe "An ArgumentExpectation" do
4
- it "should consider an object that responds to #matches? and #description to be a matcher" do
5
- argument_expecatation = Spec::Mocks::ArgumentExpectation.new([])
6
- obj = mock("matcher")
7
- obj.should_receive(:respond_to?).with(:matches?).and_return(true)
8
- obj.should_receive(:respond_to?).with(:description).and_return(true)
9
- argument_expecatation.is_matcher?(obj).should be_true
10
- end
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
- it "should NOT consider an object that only responds to #matches? to be a matcher" do
13
- argument_expecatation = Spec::Mocks::ArgumentExpectation.new([])
14
- obj = mock("matcher")
15
- obj.should_receive(:respond_to?).with(:matches?).and_return(true)
16
- obj.should_receive(:respond_to?).with(:description).and_return(false)
17
- argument_expecatation.is_matcher?(obj).should be_false
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
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
2
 
3
3
  module Spec
4
4
  module Mocks
5
- describe "AtMost" do
5
+ describe "at_most" do
6
6
  before(:each) do
7
7
  @mock = Mock.new("test mock")
8
8
  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
- @options = Options.new
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
- @options = Options.new
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
- desired_context = mock("desired context")
97
- desired_context.should_receive(:run)
98
- desired_context.should_receive(:retain_examples_matching!)
99
- desired_context.should_receive(:number_of_examples).twice.and_return(1)
100
- desired_context.should_receive(:shared?).and_return(false)
101
-
102
- other_context = mock("other context")
103
- other_context.should_receive(:run).never
104
- other_context.should_receive(:retain_examples_matching!)
105
- other_context.should_receive(:number_of_examples).and_return(0)
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 = Options.new
109
- options.reporter = reporter
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(desired_context)
114
- runner.add_behaviour(other_context)
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("context") do
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).with("context")
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 = Options.new
142
- options.reporter = reporter
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
- context = mock("context", :null_object => true)
150
- context.should_receive(:number_of_examples).twice.and_return(1)
151
- context.should_receive(:run).and_return(0)
152
- context.should_receive(:shared?).and_return(false)
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 = Options.new
163
- options.reporter = reporter
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(context)
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 specs backward if options.reverse is true" do
172
- options = Options.new
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
- c1 = mock("c1")
183
- c1.should_receive(:number_of_examples).twice.and_return(1)
184
- c1.should_receive(:shared?).and_return(false)
185
-
186
- c2 = mock("c2")
187
- c2.should_receive(:number_of_examples).twice.and_return(2)
188
- c2.should_receive(:shared?).and_return(false)
189
- c2.should_receive(:run) do
190
- c1.should_receive(:run)
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(c1)
194
- runner.add_behaviour(c2)
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
@@ -8,7 +8,7 @@ describe "CommandLine" do
8
8
  Spec::Runner::CommandLine.run([file], err, out, false, true)
9
9
 
10
10
  out.rewind
11
- out.read.should =~ /77 examples, 0 failures/n
11
+ out.read.should =~ /78 examples, 0 failures, 3 pending/n
12
12
  end
13
13
 
14
14
  it "should run file" do
@@ -2,24 +2,24 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
2
 
3
3
  module Spec
4
4
  module DSL
5
- describe "ContextMatching" do
5
+ describe Behaviour do
6
6
 
7
7
  before(:each) do
8
8
  @formatter = Spec::Mocks::Mock.new("formatter")
9
- @behaviour = Behaviour.new("context") {}
9
+ @behaviour = Behaviour.new("behaviour") {}
10
10
  end
11
11
 
12
- it "run all specs when spec is not specified" do
13
- @behaviour.it("spec1") {}
14
- @behaviour.it("spec2") {}
15
- @behaviour.retain_examples_matching!(["context"])
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 only run specified examples when specified" do
20
- @behaviour.it("spec1") {}
21
- @behaviour.it("spec2") {}
22
- @behaviour.retain_examples_matching!(["context spec1"])
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
- describe "DrbCommandLine without running local server" do
3
+ module Spec
4
+ module Runner
5
+ describe DrbCommandLine, "without running local server" do
4
6
 
5
- unless Config::CONFIG['ruby_install_name'] == 'jruby'
6
- it "should print error when there is no running local server" do
7
- err = StringIO.new
8
- out = StringIO.new
9
- Spec::Runner::DrbCommandLine.run(['--version'], err, out, false)
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
- err.rewind
12
- err.read.should =~ /No server is running/
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 "DrbCommandLine with local server" do
19
+ describe DrbCommandLine, "with local server" do
18
20
 
19
- unless Config::CONFIG['ruby_install_name'] == 'jruby'
20
- before(:all) do
21
- DRb.start_service("druby://localhost:8989", Spec::Runner::CommandLine)
22
- $drb_example_file_counter = 0
23
- end
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
- before(:each) do
26
- create_dummy_spec_file
27
- $drb_example_file_counter = $drb_example_file_counter + 1
28
- end
27
+ before(:each) do
28
+ create_dummy_spec_file
29
+ $drb_example_file_counter = $drb_example_file_counter + 1
30
+ end
29
31
 
30
- after(:each) do
31
- File.delete(@dummy_spec_filename)
32
- end
32
+ after(:each) do
33
+ File.delete(@dummy_spec_filename)
34
+ end
33
35
 
34
- after(:all) do
35
- DRb.stop_service
36
- end
36
+ after(:all) do
37
+ DRb.stop_service
38
+ end
37
39
 
38
- it "should run against local server" do
39
- out = run_spec_via_druby(['--version'])
40
- out.should =~ /RSpec/n
41
- end
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
- it "should output green colorized text when running with --colour option" do
44
- out = run_spec_via_druby(["--colour", @dummy_spec_filename])
45
- out.should =~ /\e\[32m/n
46
- end
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
- it "should output red colorized text when running with -c option" do
49
- out = run_spec_via_druby(["-c", @dummy_spec_filename])
50
- out.should =~ /\e\[31m/n
51
- end
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
- def create_dummy_spec_file
54
- @dummy_spec_filename = File.expand_path(File.dirname(__FILE__)) + "/_dummy_spec#{$drb_example_file_counter}.rb"
55
- File.open(@dummy_spec_filename, 'w') do |f|
56
- f.write %{
57
- describe "DUMMY CONTEXT for 'DrbCommandLine with -c option'" do
58
- it "should be output with green bar" do
59
- true.should be_true
60
- end
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
- it "should be output with red bar" do
63
- violated("I want to see a red bar!")
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
- def run_spec_via_druby(args)
71
- err, out = StringIO.new, StringIO.new
72
- out.instance_eval do
73
- def tty?; true end
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
- Spec::Runner::DrbCommandLine.run(args, err, out, false, true)
76
- out.rewind; out.read
81
+
77
82
  end
78
83
  end
79
-
80
84
  end
81
-