rspec-core 2.0.0.beta.8 → 2.0.0.beta.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/README.markdown +8 -8
  2. data/Rakefile +9 -9
  3. data/Upgrade.markdown +6 -6
  4. data/VERSION +1 -1
  5. data/cucumber.yml +2 -7
  6. data/example_specs/passing/subject_example.rb +45 -0
  7. data/example_specs/spec_helper.rb +1 -1
  8. data/features/command_line/line_number_appended_to_path.feature +11 -13
  9. data/features/command_line/line_number_option.feature +3 -3
  10. data/features/configuration/custom_options.feature +71 -0
  11. data/features/configuration/options_file.feature +13 -13
  12. data/features/example_groups/describe_aliases.feature +1 -1
  13. data/features/example_groups/nested_groups.feature +4 -5
  14. data/features/filtering/inclusion_filters.feature +74 -0
  15. data/features/formatters/custom_formatter.feature +1 -1
  16. data/features/hooks/around_hook.feature +1 -1
  17. data/features/hooks/before_and_after_hooks.feature +61 -33
  18. data/features/hooks/described_class.feature +1 -1
  19. data/features/hooks/halt.feature +2 -2
  20. data/features/mock_framework_integration/use_flexmock.feature +2 -2
  21. data/features/mock_framework_integration/use_mocha.feature +2 -2
  22. data/features/mock_framework_integration/use_rr.feature +2 -2
  23. data/features/mock_framework_integration/use_rspec.feature +2 -2
  24. data/features/pending/pending_examples.feature +5 -5
  25. data/features/subject/explicit_subject.feature +4 -4
  26. data/features/subject/implicit_subject.feature +2 -2
  27. data/features/support/env.rb +1 -1
  28. data/lib/autotest/rspec2.rb +1 -1
  29. data/lib/rspec/autorun.rb +1 -1
  30. data/lib/rspec/core.rb +16 -9
  31. data/lib/rspec/core/around_proxy.rb +1 -1
  32. data/lib/rspec/core/backward_compatibility.rb +29 -1
  33. data/lib/rspec/core/configuration.rb +24 -16
  34. data/lib/rspec/core/configuration_options.rb +2 -2
  35. data/lib/rspec/core/deprecation.rb +3 -3
  36. data/lib/rspec/core/errors.rb +1 -1
  37. data/lib/rspec/core/example.rb +10 -3
  38. data/lib/rspec/core/example_group.rb +83 -58
  39. data/lib/rspec/core/formatters.rb +1 -1
  40. data/lib/rspec/core/formatters/base_formatter.rb +4 -4
  41. data/lib/rspec/core/formatters/base_text_formatter.rb +3 -3
  42. data/lib/rspec/core/formatters/documentation_formatter.rb +6 -9
  43. data/lib/rspec/core/formatters/helpers.rb +5 -4
  44. data/lib/rspec/core/formatters/progress_formatter.rb +1 -1
  45. data/lib/rspec/core/hooks.rb +1 -1
  46. data/lib/rspec/core/kernel_extensions.rb +3 -23
  47. data/lib/rspec/core/let.rb +73 -5
  48. data/lib/rspec/core/load_path.rb +1 -1
  49. data/lib/rspec/core/metadata.rb +20 -8
  50. data/lib/rspec/core/mocking/with_absolutely_nothing.rb +1 -1
  51. data/lib/rspec/core/mocking/with_flexmock.rb +1 -1
  52. data/lib/rspec/core/mocking/with_mocha.rb +1 -1
  53. data/lib/rspec/core/mocking/with_rr.rb +2 -2
  54. data/lib/rspec/core/mocking/with_rspec.rb +3 -3
  55. data/lib/rspec/core/object_extensions.rb +15 -0
  56. data/lib/rspec/core/pending.rb +2 -2
  57. data/lib/rspec/core/rake_task.rb +2 -2
  58. data/lib/rspec/core/ruby_project.rb +1 -1
  59. data/lib/rspec/core/runner.rb +13 -8
  60. data/lib/rspec/core/shared_example_group.rb +16 -6
  61. data/lib/rspec/core/subject.rb +23 -7
  62. data/lib/rspec/core/version.rb +1 -1
  63. data/lib/rspec/core/world.rb +45 -38
  64. data/rspec-core.gemspec +17 -11
  65. data/spec/autotest/failed_results_re_spec.rb +1 -1
  66. data/spec/rspec/core/configuration_options_spec.rb +17 -7
  67. data/spec/rspec/core/configuration_spec.rb +46 -18
  68. data/spec/rspec/core/deprecations_spec.rb +8 -0
  69. data/spec/rspec/core/example_group_spec.rb +194 -56
  70. data/spec/rspec/core/example_spec.rb +18 -6
  71. data/spec/rspec/core/formatters/base_formatter_spec.rb +2 -2
  72. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +18 -2
  73. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +29 -4
  74. data/spec/rspec/core/formatters/helpers_spec.rb +18 -11
  75. data/spec/rspec/core/formatters/progress_formatter_spec.rb +2 -2
  76. data/spec/rspec/core/kernel_extensions_spec.rb +5 -9
  77. data/spec/rspec/core/metadata_spec.rb +29 -8
  78. data/spec/rspec/core/pending_example_spec.rb +7 -7
  79. data/spec/rspec/core/ruby_project_spec.rb +1 -1
  80. data/spec/rspec/core/runner_spec.rb +9 -9
  81. data/spec/rspec/core/shared_example_group_spec.rb +3 -3
  82. data/spec/rspec/core/subject_spec.rb +1 -1
  83. data/spec/rspec/core/world_spec.rb +16 -35
  84. data/spec/rspec/core_spec.rb +9 -9
  85. data/spec/spec_helper.rb +11 -13
  86. data/spec/support/matchers.rb +2 -2
  87. data/specs.watchr +11 -11
  88. metadata +16 -10
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Rspec::Core::Example, :parent_metadata => 'sample' do
3
+ describe RSpec::Core::Example, :parent_metadata => 'sample' do
4
4
  let(:example_group) do
5
- Rspec::Core::ExampleGroup.describe('group description')
5
+ RSpec::Core::ExampleGroup.describe('group description')
6
6
  end
7
7
 
8
8
  let(:example) do
@@ -41,7 +41,7 @@ describe Rspec::Core::Example, :parent_metadata => 'sample' do
41
41
 
42
42
  describe '#described_class' do
43
43
  it "returns the class (if any) of the outermost example group" do
44
- described_class.should == Rspec::Core::Example
44
+ described_class.should == RSpec::Core::Example
45
45
  end
46
46
  end
47
47
 
@@ -59,7 +59,7 @@ describe Rspec::Core::Example, :parent_metadata => 'sample' do
59
59
  describe "#run" do
60
60
  it "runs after(:each) when the example passes" do
61
61
  after_run = false
62
- group = Rspec::Core::ExampleGroup.describe do
62
+ group = RSpec::Core::ExampleGroup.describe do
63
63
  after(:each) { after_run = true }
64
64
  example('example') { 1.should == 1 }
65
65
  end
@@ -69,7 +69,7 @@ describe Rspec::Core::Example, :parent_metadata => 'sample' do
69
69
 
70
70
  it "runs after(:each) when the example fails" do
71
71
  after_run = false
72
- group = Rspec::Core::ExampleGroup.describe do
72
+ group = RSpec::Core::ExampleGroup.describe do
73
73
  after(:each) { after_run = true }
74
74
  example('example') { 1.should == 2 }
75
75
  end
@@ -79,7 +79,7 @@ describe Rspec::Core::Example, :parent_metadata => 'sample' do
79
79
 
80
80
  it "runs after(:each) when the example raises an Exception" do
81
81
  after_run = false
82
- group = Rspec::Core::ExampleGroup.describe do
82
+ group = RSpec::Core::ExampleGroup.describe do
83
83
  after(:each) { after_run = true }
84
84
  example('example') { raise "this error" }
85
85
  end
@@ -87,4 +87,16 @@ describe Rspec::Core::Example, :parent_metadata => 'sample' do
87
87
  after_run.should be_true, "expected after(:each) to be run"
88
88
  end
89
89
  end
90
+
91
+ describe "#in_block?" do
92
+ before do
93
+ running_example.should_not be_in_block
94
+ end
95
+ it "is only true during the example (but not before or after)" do
96
+ running_example.should be_in_block
97
+ end
98
+ after do
99
+ running_example.should_not be_in_block
100
+ end
101
+ end
90
102
  end
@@ -1,8 +1,8 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Rspec::Core::Formatters::BaseFormatter do
3
+ describe RSpec::Core::Formatters::BaseFormatter do
4
4
 
5
- let(:formatter) { Rspec::Core::Formatters::BaseFormatter.new }
5
+ let(:formatter) { RSpec::Core::Formatters::BaseFormatter.new }
6
6
 
7
7
  it "has start as an interface with one argument" do
8
8
  formatter.should have_interface_for(:start).with(1).argument
@@ -1,5 +1,21 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Rspec::Core::Formatters::BaseTextFormatter do
4
-
3
+ module RSpec::Core::Formatters
4
+
5
+ describe BaseTextFormatter do
6
+ describe "#dump_failures" do
7
+ it "preserves formatting" do
8
+ output = StringIO.new
9
+ group = RSpec::Core::ExampleGroup.describe
10
+ example = group.example { "this".should eq("that") }
11
+ formatter = RSpec::Core::Formatters::BaseTextFormatter.new
12
+ group.run_all(formatter)
13
+
14
+ RSpec.configuration.stub(:output) { output }
15
+ RSpec.configuration.stub(:color_enabled?) { false }
16
+ formatter.dump_failures
17
+ output.string.should =~ /(\s+)expected \"that\"\n\1 got \"this\"/m
18
+ end
19
+ end
20
+ end
5
21
  end
@@ -1,5 +1,30 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- describe Rspec::Core::Formatters::DocumentationFormatter do
4
-
5
- end
3
+ module RSpec::Core::Formatters
4
+ describe DocumentationFormatter do
5
+ it "numbers the failures" do
6
+
7
+ examples = [
8
+ double("example 1",
9
+ :description => "first example",
10
+ :execution_result => {:status => 'failed', :exception_encountered => Exception.new }
11
+ ),
12
+ double("example 2",
13
+ :description => "second example",
14
+ :execution_result => {:status => 'failed', :exception_encountered => Exception.new }
15
+ )
16
+ ]
17
+
18
+ output = StringIO.new
19
+ RSpec.configuration.stub(:output) { output }
20
+ RSpec.configuration.stub(:color_enabled?) { false }
21
+
22
+ formatter = RSpec::Core::Formatters::DocumentationFormatter.new
23
+
24
+ examples.each {|e| formatter.example_finished(e) }
25
+
26
+ output.string.should =~ /first example \(FAILED - 1\)/m
27
+ output.string.should =~ /second example \(FAILED - 2\)/m
28
+ end
29
+ end
30
+ end
@@ -1,23 +1,29 @@
1
1
  require 'spec_helper'
2
2
  require 'stringio'
3
3
 
4
- describe Rspec::Core::Formatters::Helpers do
5
- let(:helper) { helper = Object.new.extend(Rspec::Core::Formatters::Helpers) }
4
+ describe RSpec::Core::Formatters::Helpers do
5
+ let(:helper) { helper = Object.new.extend(RSpec::Core::Formatters::Helpers) }
6
6
 
7
7
  describe "format seconds" do
8
- it "uses passed in precision if specified" do
9
- pending("get regex right to handle this case where we don't want it to consume all zeroes") do
10
- helper.format_seconds(0.00005, 2).should == "0.00"
11
- end
12
- end
13
-
14
8
  context "sub second times" do
15
9
  it "returns 5 digits of precision" do
16
- helper.format_seconds(0.000005).should == "0.00001"
10
+ helper.format_seconds(0.000006).should == "0.00001"
11
+ end
12
+
13
+ it "strips off trailing zeroes beyond sub-second precision" do
14
+ helper.format_seconds(0.020000).should == "0.02"
17
15
  end
18
16
 
19
- it "strips off trailing zeroes" do
20
- helper.format_seconds(0.02000).should == "0.02"
17
+ context "0" do
18
+ it "strips off trailing zeroes" do
19
+ helper.format_seconds(0.00000000001).should == "0"
20
+ end
21
+ end
22
+
23
+ context "> 1" do
24
+ it "strips off trailing zeroes" do
25
+ helper.format_seconds(1.00000000001).should == "1"
26
+ end
21
27
  end
22
28
  end
23
29
 
@@ -32,6 +38,7 @@ describe Rspec::Core::Formatters::Helpers do
32
38
  helper.format_seconds(5).should == "5"
33
39
  helper.format_seconds(5.0).should == "5"
34
40
  end
41
+
35
42
  end
36
43
  end
37
44
 
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
  require 'stringio'
3
3
 
4
- describe Rspec::Core::Formatters::ProgressFormatter do
4
+ describe RSpec::Core::Formatters::ProgressFormatter do
5
5
 
6
6
  before do
7
7
  @output = StringIO.new
8
- @formatter = Rspec::Core::Formatters::ProgressFormatter.new
8
+ @formatter = RSpec::Core::Formatters::ProgressFormatter.new
9
9
  @formatter.start(2)
10
10
  @formatter.stub!(:color_enabled?).and_return(false)
11
11
  @formatter.stub!(:output).and_return(@output)
@@ -1,13 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Rspec::Core::KernelExtensions do
4
-
5
- it "should be included in Object" do
6
- Object.included_modules.should include(Rspec::Core::KernelExtensions)
3
+ describe "extensions" do
4
+ describe "debugger" do
5
+ it "is defined on Kernel" do
6
+ Kernel.should respond_to(:debugger)
7
+ end
7
8
  end
8
-
9
- it "should add a describe method to Object" do
10
- Object.should respond_to(:describe)
11
- end
12
-
13
9
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- module Rspec
3
+ module RSpec
4
4
  module Core
5
5
  describe Metadata do
6
6
 
@@ -76,6 +76,18 @@ module Rspec
76
76
  end
77
77
  end
78
78
 
79
+ describe "parent example group" do
80
+ it "nests the parent's example group metadata" do
81
+ parent = Metadata.new
82
+ parent.process(Object, 'parent')
83
+
84
+ child = Metadata.new(parent)
85
+ child.process()
86
+
87
+ child[:example_group][:example_group].should == parent[:example_group]
88
+ end
89
+ end
90
+
79
91
  describe "file path" do
80
92
  it "finds the first spec file in the caller array" do
81
93
  m = Metadata.new
@@ -168,38 +180,47 @@ module Rspec
168
180
  end
169
181
 
170
182
  describe "apply_condition" do
171
- let(:group_metadata) { Metadata.new.process('group', :caller => ["foo_spec.rb:#{__LINE__}"]) }
183
+
184
+
185
+ let(:parent_group_metadata) { Metadata.new.process('parent group', :caller => ["foo_spec.rb:#{__LINE__}"]) }
186
+ let(:parent_group_line_number) { __LINE__ -1 }
187
+ let(:group_metadata) { Metadata.new(parent_group_metadata).process('group', :caller => ["foo_spec.rb:#{__LINE__}"]) }
172
188
  let(:group_line_number) { __LINE__ -1 }
173
189
  let(:example_metadata) { group_metadata.for_example('example', :caller => ["foo_spec.rb:#{__LINE__}"]) }
174
190
  let(:example_line_number) { __LINE__ -1 }
175
191
  let(:next_example_metadata) {group_metadata.for_example('next_example',
176
192
  :caller => ["foo_spec.rb:#{example_line_number + 2}"])}
177
- let(:world) { Rspec::Core.world }
193
+ let(:world) { RSpec.world }
178
194
 
179
195
  it "matches the group when the line_number is the example group line number" do
180
- world.should_receive(:preceding_example_or_group_line).and_return(group_line_number)
196
+ world.should_receive(:preceding_declaration_line).and_return(group_line_number)
181
197
  # this call doesn't really make sense since apply_condition is only called
182
198
  # for example metadata not group metadata
183
199
  group_metadata.apply_condition(:line_number, group_line_number).should be_true
184
200
  end
185
201
 
202
+ it "matches the example when the line_number is the grandparent example group line number" do
203
+ world.should_receive(:preceding_declaration_line).and_return(parent_group_line_number)
204
+ example_metadata.apply_condition(:line_number, parent_group_line_number).should be_true
205
+ end
206
+
186
207
  it "matches the example when the line_number is the parent example group line number" do
187
- world.should_receive(:preceding_example_or_group_line).and_return(group_line_number)
208
+ world.should_receive(:preceding_declaration_line).and_return(group_line_number)
188
209
  example_metadata.apply_condition(:line_number, group_line_number).should be_true
189
210
  end
190
211
 
191
212
  it "matches the example when the line_number is the example line number" do
192
- world.should_receive(:preceding_example_or_group_line).and_return(example_line_number)
213
+ world.should_receive(:preceding_declaration_line).and_return(example_line_number)
193
214
  example_metadata.apply_condition(:line_number, example_line_number).should be_true
194
215
  end
195
216
 
196
217
  it "matches when the line number is between this example and the next" do
197
- world.should_receive(:preceding_example_or_group_line).and_return(example_line_number)
218
+ world.should_receive(:preceding_declaration_line).and_return(example_line_number)
198
219
  example_metadata.apply_condition(:line_number, example_line_number + 1).should be_true
199
220
  end
200
221
 
201
222
  it "does not match when the line number matches the next example" do
202
- world.should_receive(:preceding_example_or_group_line).and_return(example_line_number + 2)
223
+ world.should_receive(:preceding_declaration_line).and_return(example_line_number + 2)
203
224
  example_metadata.apply_condition(:line_number, example_line_number + 2).should be_false
204
225
  end
205
226
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- Rspec::Matchers.define :be_pending_with do |message|
3
+ RSpec::Matchers.define :be_pending_with do |message|
4
4
  match do |example|
5
5
  example.metadata[:pending] && example.metadata[:execution_result][:pending_message] == message
6
6
  end
@@ -13,7 +13,7 @@ end
13
13
  describe "an example" do
14
14
  context "with no block" do
15
15
  it "is listed as pending with 'Not Yet Implemented'" do
16
- group = Rspec::Core::ExampleGroup.describe('group') do
16
+ group = RSpec::Core::ExampleGroup.describe('group') do
17
17
  it "has no block"
18
18
  end
19
19
  example = group.examples.first
@@ -24,7 +24,7 @@ describe "an example" do
24
24
 
25
25
  context "with no args" do
26
26
  it "is listed as pending with 'No reason given'" do
27
- group = Rspec::Core::ExampleGroup.describe('group') do
27
+ group = RSpec::Core::ExampleGroup.describe('group') do
28
28
  it "does something" do
29
29
  pending
30
30
  end
@@ -37,7 +37,7 @@ describe "an example" do
37
37
 
38
38
  context "with a message" do
39
39
  it "is listed as pending with the supplied message" do
40
- group = Rspec::Core::ExampleGroup.describe('group') do
40
+ group = RSpec::Core::ExampleGroup.describe('group') do
41
41
  it "does something" do
42
42
  pending("just because")
43
43
  end
@@ -51,7 +51,7 @@ describe "an example" do
51
51
  context "with a block" do
52
52
  context "that fails" do
53
53
  it "is listed as pending with the supplied message" do
54
- group = Rspec::Core::ExampleGroup.describe('group') do
54
+ group = RSpec::Core::ExampleGroup.describe('group') do
55
55
  it "does something" do
56
56
  pending("just because") do
57
57
  3.should == 4
@@ -66,7 +66,7 @@ describe "an example" do
66
66
 
67
67
  context "that passes" do
68
68
  it "raises a PendingExampleFixedError" do
69
- group = Rspec::Core::ExampleGroup.describe('group') do
69
+ group = RSpec::Core::ExampleGroup.describe('group') do
70
70
  it "does something" do
71
71
  pending("just because") do
72
72
  3.should == 3
@@ -77,7 +77,7 @@ describe "an example" do
77
77
  example.run(group.new, stub.as_null_object)
78
78
  example.metadata[:pending].should be_false
79
79
  example.metadata[:execution_result][:status].should == 'failed'
80
- example.metadata[:execution_result][:exception_encountered].should be_a(Rspec::Core::PendingExampleFixedError)
80
+ example.metadata[:execution_result][:exception_encountered].should be_a(RSpec::Core::PendingExampleFixedError)
81
81
  end
82
82
  end
83
83
  end
@@ -1,4 +1,4 @@
1
- module Rspec
1
+ module RSpec
2
2
  module Core
3
3
  describe RubyProject do
4
4
 
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Rspec::Core::Runner do
3
+ describe RSpec::Core::Runner do
4
4
 
5
5
  describe 'reporter' do
6
6
 
7
7
  it 'should return the configured formatter' do
8
- Rspec::Core::Runner.new.reporter.should == Rspec.configuration.formatter
8
+ RSpec::Core::Runner.new.reporter.should == RSpec.configuration.formatter
9
9
  end
10
10
 
11
11
  end
@@ -13,15 +13,15 @@ describe Rspec::Core::Runner do
13
13
  describe 'at_exit' do
14
14
 
15
15
  it 'should set an at_exit hook if none is already set' do
16
- Rspec::Core::Runner.stub!(:installed_at_exit?).and_return(false)
17
- Rspec::Core::Runner.should_receive(:at_exit)
18
- Rspec::Core::Runner.autorun
16
+ RSpec::Core::Runner.stub!(:installed_at_exit?).and_return(false)
17
+ RSpec::Core::Runner.should_receive(:at_exit)
18
+ RSpec::Core::Runner.autorun
19
19
  end
20
20
 
21
21
  it 'should not set the at_exit hook if it is already set' do
22
- Rspec::Core::Runner.stub!(:installed_at_exit?).and_return(true)
23
- Rspec::Core::Runner.should_receive(:at_exit).never
24
- Rspec::Core::Runner.autorun
22
+ RSpec::Core::Runner.stub!(:installed_at_exit?).and_return(true)
23
+ RSpec::Core::Runner.should_receive(:at_exit).never
24
+ RSpec::Core::Runner.autorun
25
25
  end
26
26
 
27
27
  end
@@ -29,6 +29,6 @@ describe Rspec::Core::Runner do
29
29
  describe 'placeholder' do
30
30
 
31
31
  # it "should "
32
- # Rspec::Core::Runner.new
32
+ # RSpec::Core::Runner.new
33
33
  end
34
34
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- module Rspec::Core
3
+ module RSpec::Core
4
4
 
5
5
  describe SharedExampleGroup do
6
6
 
@@ -27,7 +27,7 @@ module Rspec::Core
27
27
  describe "share_examples_for" do
28
28
 
29
29
  it "should capture the given name and block in the Worlds collection of shared example groups" do
30
- Rspec::Core.world.shared_example_groups.should_receive(:[]=).with(:foo, anything)
30
+ RSpec.world.shared_example_groups.should_receive(:[]=).with(:foo, anything)
31
31
  share_examples_for(:foo) { }
32
32
  end
33
33
 
@@ -41,7 +41,7 @@ module Rspec::Core
41
41
  def self.class_helper; end
42
42
  def extra_helper; end
43
43
  }
44
- Rspec::Core.world.stub(:shared_example_groups).and_return({ :shared_example_group => block })
44
+ RSpec.world.stub(:shared_example_groups).and_return({ :shared_example_group => block })
45
45
  group.it_should_behave_like :shared_example_group
46
46
  group.instance_methods.should include('extra_helper')
47
47
  group.singleton_methods.should include('class_helper')
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- module Rspec::Core
3
+ module RSpec::Core
4
4
 
5
5
  describe Subject do
6
6
 
@@ -3,19 +3,18 @@ require 'spec_helper'
3
3
  class Bar; end
4
4
  class Foo; end
5
5
 
6
- module Rspec::Core
6
+ module RSpec::Core
7
7
 
8
8
  describe World do
9
9
 
10
10
  before do
11
- @world = Rspec::Core::World.new
12
- Rspec::Core.stub(:world).and_return(@world)
11
+ @world = RSpec.world
13
12
  end
14
13
 
15
14
  describe "example_groups" do
16
15
 
17
16
  it "should contain all defined example groups" do
18
- group = Rspec::Core::ExampleGroup.describe("group") {}
17
+ group = RSpec::Core::ExampleGroup.describe("group") {}
19
18
  @world.example_groups.should include(group)
20
19
  end
21
20
 
@@ -23,14 +22,14 @@ module Rspec::Core
23
22
 
24
23
  describe "applying inclusion filters" do
25
24
 
26
- before(:all) do
25
+ before(:each) do
27
26
  options_1 = { :foo => 1, :color => 'blue', :feature => 'reporting' }
28
27
  options_2 = { :pending => true, :feature => 'reporting' }
29
28
  options_3 = { :array => [1,2,3,4], :color => 'blue' }
30
- @bg1 = Rspec::Core::ExampleGroup.describe(Bar, "find group-1", options_1) { }
31
- @bg2 = Rspec::Core::ExampleGroup.describe(Bar, "find group-2", options_2) { }
32
- @bg3 = Rspec::Core::ExampleGroup.describe(Bar, "find group-3", options_3) { }
33
- @bg4 = Rspec::Core::ExampleGroup.describe(Foo, "find these examples") do
29
+ @bg1 = RSpec::Core::ExampleGroup.describe(Bar, "find group-1", options_1) { }
30
+ @bg2 = RSpec::Core::ExampleGroup.describe(Bar, "find group-2", options_2) { }
31
+ @bg3 = RSpec::Core::ExampleGroup.describe(Bar, "find group-3", options_3) { }
32
+ @bg4 = RSpec::Core::ExampleGroup.describe(Foo, "find these examples") do
34
33
  it('I have no options') {}
35
34
  it("this is awesome", :awesome => true) {}
36
35
  it("this is too", :awesome => true) {}
@@ -117,36 +116,18 @@ module Rspec::Core
117
116
  @world.apply_exclusion_filters(group.examples, :name => /exclude/, "another_condition" => "foo").should == group.examples
118
117
  @world.apply_exclusion_filters(group.examples, :name => /exclude/, "another_condition" => "foo1").should == group.examples
119
118
  end
120
-
121
119
  end
122
120
 
123
- describe "filtering example groups" do
124
-
125
- it "should run matches" do
126
- @group1 = ExampleGroup.describe(Bar, "find these examples") do
127
- it('I have no options', :color => :red, :awesome => true) {}
128
- it("I also have no options", :color => :red, :awesome => true) {}
129
- it("not so awesome", :color => :red, :awesome => false) {}
130
- end
131
- Rspec::Core.world.stub(:exclusion_filter).and_return({ :awesome => false })
132
- Rspec::Core.world.stub(:filter).and_return({ :color => :red })
133
- Rspec::Core.world.stub(:example_groups).and_return([@group1])
134
- filtered_example_groups = @world.filtered_example_groups
135
- filtered_example_groups.should == [@group1]
136
- @group1.examples_to_run.should == @group1.examples[0..1]
137
- end
138
-
139
- end
140
121
 
141
- describe "preceding_example_or_group_line" do
122
+ describe "preceding_declaration_line" do
142
123
  before(:each) do
143
124
  @group1_line = 10
144
125
  @group2_line = 20
145
126
  @group2_example1_line = 30
146
127
  @group2_example2_line = 40
147
128
 
148
- @group1 = Rspec::Core::ExampleGroup.describe(Bar, "group-1") { }
149
- @group2 = Rspec::Core::ExampleGroup.describe(Bar, "group-2") do
129
+ @group1 = RSpec::Core::ExampleGroup.describe(Bar, "group-1") { }
130
+ @group2 = RSpec::Core::ExampleGroup.describe(Bar, "group-2") do
150
131
  it('example 1') {}
151
132
  it("example 2") {}
152
133
  end
@@ -157,23 +138,23 @@ module Rspec::Core
157
138
  end
158
139
 
159
140
  it "should return nil if no example or group precedes the line" do
160
- @world.preceding_example_or_group_line(@group1_line-1).should == nil
141
+ @world.preceding_declaration_line(@group1_line-1).should == nil
161
142
  end
162
143
 
163
144
  it "should return the argument line number if a group starts on that line" do
164
- @world.preceding_example_or_group_line(@group1_line).should == @group1_line
145
+ @world.preceding_declaration_line(@group1_line).should == @group1_line
165
146
  end
166
147
 
167
148
  it "should return the argument line number if an example starts on that line" do
168
- @world.preceding_example_or_group_line(@group2_example1_line).should == @group2_example1_line
149
+ @world.preceding_declaration_line(@group2_example1_line).should == @group2_example1_line
169
150
  end
170
151
 
171
152
  it "should return line number of a group that immediately precedes the argument line" do
172
- @world.preceding_example_or_group_line(@group2_line+1).should == @group2_line
153
+ @world.preceding_declaration_line(@group2_line+1).should == @group2_line
173
154
  end
174
155
 
175
156
  it "should return line number of an example that immediately precedes the argument line" do
176
- @world.preceding_example_or_group_line(@group2_example1_line+1).should == @group2_example1_line
157
+ @world.preceding_declaration_line(@group2_example1_line+1).should == @group2_example1_line
177
158
  end
178
159
 
179
160
  end