rspec-core 2.6.0 → 2.7.0.rc1

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 (113) hide show
  1. data/README.md +1 -1
  2. data/features/Upgrade.md +11 -0
  3. data/features/command_line/exit_status.feature +20 -3
  4. data/features/command_line/format_option.feature +8 -0
  5. data/features/command_line/line_number_appended_to_path.feature +35 -1
  6. data/features/command_line/line_number_option.feature +16 -3
  7. data/features/command_line/pattern_option.feature +31 -0
  8. data/features/command_line/rake_task.feature +1 -1
  9. data/features/command_line/ruby.feature +22 -0
  10. data/features/configuration/default_path.feature +38 -0
  11. data/features/example_groups/{shared_example_group.feature → shared_examples.feature} +49 -26
  12. data/features/expectation_framework_integration/configure_expectation_framework.feature +1 -1
  13. data/features/filtering/inclusion_filters.feature +4 -5
  14. data/features/formatters/text_formatter.feature +16 -13
  15. data/features/helper_methods/let.feature +4 -4
  16. data/features/hooks/around_hooks.feature +1 -1
  17. data/features/hooks/before_and_after_hooks.feature +3 -3
  18. data/features/hooks/filtering.feature +13 -6
  19. data/features/metadata/user_defined.feature +12 -10
  20. data/features/pending/pending_examples.feature +21 -8
  21. data/features/step_definitions/additional_cli_steps.rb +1 -1
  22. data/features/subject/attribute_of_subject.feature +2 -2
  23. data/features/support/env.rb +1 -2
  24. data/lib/rspec/core/backward_compatibility.rb +1 -1
  25. data/lib/rspec/core/configuration.rb +71 -16
  26. data/lib/rspec/core/configuration_options.rb +46 -16
  27. data/lib/rspec/core/{extensions/object.rb → dsl.rb} +2 -4
  28. data/lib/rspec/core/example.rb +10 -7
  29. data/lib/rspec/core/example_group.rb +34 -18
  30. data/lib/rspec/core/expecting/with_rspec.rb +0 -2
  31. data/lib/rspec/core/extensions.rb +0 -1
  32. data/lib/rspec/core/formatters/base_formatter.rb +8 -4
  33. data/lib/rspec/core/formatters/base_text_formatter.rb +38 -18
  34. data/lib/rspec/core/formatters/html_formatter.rb +3 -1
  35. data/lib/rspec/core/formatters/snippet_extractor.rb +9 -3
  36. data/lib/rspec/core/formatters/text_mate_formatter.rb +20 -6
  37. data/lib/rspec/core/hooks.rb +7 -6
  38. data/lib/rspec/core/let.rb +5 -5
  39. data/lib/rspec/core/metadata.rb +136 -94
  40. data/lib/rspec/core/metadata_hash_builder.rb +1 -1
  41. data/lib/rspec/core/option_parser.rb +11 -7
  42. data/lib/rspec/core/pending.rb +2 -1
  43. data/lib/rspec/core/rake_task.rb +26 -15
  44. data/lib/rspec/core/reporter.rb +5 -6
  45. data/lib/rspec/core/runner.rb +1 -1
  46. data/lib/rspec/core/shared_example_group.rb +4 -4
  47. data/lib/rspec/core/subject.rb +7 -7
  48. data/lib/rspec/core/version.rb +1 -1
  49. data/lib/rspec/core/world.rb +9 -13
  50. data/lib/rspec/core.rb +14 -21
  51. data/spec/autotest/discover_spec.rb +2 -2
  52. data/spec/autotest/failed_results_re_spec.rb +29 -21
  53. data/spec/autotest/rspec_spec.rb +3 -3
  54. data/spec/rspec/core/command_line_spec.rb +1 -6
  55. data/spec/rspec/core/configuration_options_spec.rb +111 -27
  56. data/spec/rspec/core/configuration_spec.rb +161 -37
  57. data/spec/rspec/core/deprecations_spec.rb +2 -2
  58. data/spec/rspec/core/drb_command_line_spec.rb +6 -6
  59. data/spec/rspec/core/example_group_spec.rb +197 -61
  60. data/spec/rspec/core/example_spec.rb +33 -16
  61. data/spec/rspec/core/formatters/base_formatter_spec.rb +3 -3
  62. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +222 -71
  63. data/spec/rspec/core/formatters/helpers_spec.rb +8 -8
  64. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +90 -26
  65. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +12 -11
  66. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +12 -11
  67. data/spec/rspec/core/formatters/{html_formatted-1.9.1.html → html_formatted-1.9.3.html} +12 -11
  68. data/spec/rspec/core/formatters/html_formatter_spec.rb +5 -5
  69. data/spec/rspec/core/formatters/progress_formatter_spec.rb +2 -2
  70. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +2 -2
  71. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +91 -27
  72. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +13 -12
  73. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +29 -28
  74. data/spec/rspec/core/formatters/{text_mate_formatted-1.9.1.html → text_mate_formatted-1.9.3.html} +29 -28
  75. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +2 -2
  76. data/spec/rspec/core/hooks_filtering_spec.rb +18 -18
  77. data/spec/rspec/core/let_spec.rb +19 -6
  78. data/spec/rspec/core/metadata_spec.rb +146 -61
  79. data/spec/rspec/core/pending_example_spec.rb +4 -4
  80. data/spec/rspec/core/rake_task_spec.rb +71 -50
  81. data/spec/rspec/core/reporter_spec.rb +2 -2
  82. data/spec/rspec/core/ruby_project_spec.rb +2 -2
  83. data/spec/rspec/core/runner_spec.rb +4 -1
  84. data/spec/rspec/core/shared_example_group_spec.rb +15 -119
  85. data/spec/rspec/core/subject_spec.rb +13 -13
  86. data/spec/rspec/core/world_spec.rb +31 -22
  87. data/spec/rspec/core_spec.rb +1 -29
  88. data/spec/spec_helper.rb +51 -50
  89. data/spec/support/shared_example_groups.rb +3 -3
  90. data/spec/support/spec_files.rb +8 -8
  91. metadata +79 -94
  92. data/.document +0 -5
  93. data/.gitignore +0 -12
  94. data/.rspec +0 -0
  95. data/.travis.yml +0 -7
  96. data/Gemfile +0 -50
  97. data/Guardfile +0 -5
  98. data/License.txt +0 -23
  99. data/Rakefile +0 -89
  100. data/cucumber.yml +0 -2
  101. data/features/.nav +0 -57
  102. data/features/Changelog.md +0 -269
  103. data/rspec-core.gemspec +0 -24
  104. data/script/FullBuildRakeFile +0 -63
  105. data/script/console +0 -8
  106. data/script/cucumber +0 -1
  107. data/script/full_build +0 -1
  108. data/script/spec +0 -1
  109. data/spec/rspec/core/formatters/html_formatted-1.8.6.html +0 -398
  110. data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +0 -398
  111. data/spec.txt +0 -1126
  112. /data/{bin → exe}/autospec +0 -0
  113. /data/{bin → exe}/rspec +0 -0
@@ -1,8 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module RSpec::Core
4
-
5
4
  describe SharedExampleGroup do
5
+
6
+ ExampleModule = Module.new
7
+ ExampleClass = Class.new
6
8
 
7
9
  %w[share_examples_for shared_examples_for].each do |method_name|
8
10
  describe method_name do
@@ -17,20 +19,15 @@ module RSpec::Core
17
19
  group.send(method_name, 'shared group') {}
18
20
  end.should raise_error(ArgumentError, "Shared example group 'shared group' already exists")
19
21
  end
20
-
21
- context "given a string" do
22
- it "captures the given string and block in the World's collection of shared example groups" do
23
- implementation = lambda {}
24
- RSpec.world.shared_example_groups.should_receive(:[]=).with("name", implementation)
25
- send(method_name, "name", &implementation)
26
- end
27
- end
28
-
29
- context "given a symbol" do
30
- it "captures the given symbol and block in the World's collection of shared example groups" do
31
- implementation = lambda {}
32
- RSpec.world.shared_example_groups.should_receive(:[]=).with(:name, implementation)
33
- send(method_name, :name, &implementation)
22
+
23
+ ["name", :name, ExampleModule, ExampleClass].each do |object|
24
+ type = object.class.name.downcase
25
+ context "given a #{type}" do
26
+ it "captures the given #{type} and block in the World's collection of shared example groups" do
27
+ implementation = lambda {}
28
+ RSpec.world.shared_example_groups.should_receive(:[]=).with(object, implementation)
29
+ send(method_name, object, &implementation)
30
+ end
34
31
  end
35
32
  end
36
33
 
@@ -64,107 +61,6 @@ module RSpec::Core
64
61
  end
65
62
  end
66
63
 
67
- describe "#it_should_behave_like" do
68
- it "creates a nested group" do
69
- shared_examples_for("thing") {}
70
- group = ExampleGroup.describe('fake group')
71
- group.it_should_behave_like("thing")
72
- group.should have(1).children
73
- end
74
-
75
- it "adds shared examples to nested group" do
76
- shared_examples_for("thing") do
77
- it("does something")
78
- end
79
- group = ExampleGroup.describe('fake group')
80
- shared_group = group.it_should_behave_like("thing")
81
- shared_group.should have(1).examples
82
- end
83
-
84
- it "adds shared instance methods to nested group" do
85
- shared_examples_for("thing") do
86
- def foo; end
87
- end
88
- group = ExampleGroup.describe('fake group')
89
- shared_group = group.it_should_behave_like("thing")
90
- shared_group.public_instance_methods.map{|m| m.to_s}.should include("foo")
91
- end
92
-
93
- it "adds shared class methods to nested group" do
94
- shared_examples_for("thing") do
95
- def self.foo; end
96
- end
97
- group = ExampleGroup.describe('fake group')
98
- shared_group = group.it_should_behave_like("thing")
99
- shared_group.methods.map{|m| m.to_s}.should include("foo")
100
- end
101
-
102
- context "given some parameters" do
103
- it "passes the parameters to the shared example group" do
104
- passed_params = {}
105
-
106
- shared_examples_for("thing") do |param1, param2|
107
- it("has access to the given parameters") do
108
- passed_params[:param1] = param1
109
- passed_params[:param2] = param2
110
- end
111
- end
112
-
113
- group = ExampleGroup.describe("group") do
114
- it_should_behave_like "thing", :value1, :value2
115
- end
116
- group.run
117
-
118
- passed_params.should == { :param1 => :value1, :param2 => :value2 }
119
- end
120
-
121
- it "adds shared instance methods to nested group" do
122
- shared_examples_for("thing") do |param1|
123
- def foo; end
124
- end
125
- group = ExampleGroup.describe('fake group')
126
- shared_group = group.it_should_behave_like("thing", :a)
127
- shared_group.public_instance_methods.map{|m| m.to_s}.should include("foo")
128
- end
129
-
130
- it "evals the shared example group only once" do
131
- eval_count = 0
132
- shared_examples_for("thing") { |p| eval_count += 1 }
133
- group = ExampleGroup.describe('fake group')
134
- shared_group = group.it_should_behave_like("thing", :a)
135
- eval_count.should == 1
136
- end
137
- end
138
-
139
- context "given a block" do
140
- it "evaluates the block in nested group" do
141
- scopes = []
142
- shared_examples_for("thing") do
143
- it("gets run in the nested group") do
144
- scopes << self.class
145
- end
146
- end
147
- group = ExampleGroup.describe("group") do
148
- it_should_behave_like "thing" do
149
- it("gets run in the same nested group") do
150
- scopes << self.class
151
- end
152
- end
153
- end
154
- group.run
155
-
156
- scopes[0].should be(scopes[1])
157
- end
158
- end
159
-
160
- it "raises when named shared example_group can not be found" do
161
- group = ExampleGroup.describe("example_group")
162
- lambda do
163
- group.it_should_behave_like("a group that does not exist")
164
- end.should raise_error(/Could not find shared example group named/)
165
- end
166
- end
167
-
168
64
  describe "#share_as" do
169
65
  it "is exposed to the global namespace" do
170
66
  Kernel.should respond_to("share_as")
@@ -173,15 +69,15 @@ module RSpec::Core
173
69
  it "adds examples to current example_group using include", :compat => 'rspec-1.2' do
174
70
  share_as('Cornucopia') do
175
71
  it "is plentiful" do
176
- 5.should == 4
72
+ 5.should eq(4)
177
73
  end
178
74
  end
179
75
  group = ExampleGroup.describe('group') { include Cornucopia }
180
76
  phantom_group = group.children.first
181
77
  phantom_group.description.should eql("")
182
78
  phantom_group.metadata[:shared_group_name].should eql('Cornucopia')
183
- phantom_group.examples.length.should == 1
184
- phantom_group.examples.first.metadata[:description].should == "is plentiful"
79
+ phantom_group.examples.length.should eq(1)
80
+ phantom_group.examples.first.metadata[:description].should eq("is plentiful")
185
81
  end
186
82
  end
187
83
  end
@@ -8,25 +8,25 @@ module RSpec::Core
8
8
  describe "implicit subject" do
9
9
  describe "with a class" do
10
10
  it "returns an instance of the class" do
11
- ExampleGroup.describe(Array).subject.call.should == []
11
+ ExampleGroup.describe(Array).subject.call.should eq([])
12
12
  end
13
13
  end
14
14
 
15
15
  describe "with a Module" do
16
16
  it "returns the Module" do
17
- ExampleGroup.describe(Enumerable).subject.call.should == Enumerable
17
+ ExampleGroup.describe(Enumerable).subject.call.should eq(Enumerable)
18
18
  end
19
19
  end
20
20
 
21
21
  describe "with a string" do
22
22
  it "return the string" do
23
- ExampleGroup.describe("Foo").subject.call.should == 'Foo'
23
+ ExampleGroup.describe("Foo").subject.call.should eq("Foo")
24
24
  end
25
25
  end
26
26
 
27
27
  describe "with a number" do
28
28
  it "returns the number" do
29
- ExampleGroup.describe(15).subject.call.should == 15
29
+ ExampleGroup.describe(15).subject.call.should eq(15)
30
30
  end
31
31
  end
32
32
 
@@ -56,7 +56,7 @@ module RSpec::Core
56
56
  it "replaces the implicit subject in that group" do
57
57
  group = ExampleGroup.describe(Array)
58
58
  group.subject { [1,2,3] }
59
- group.subject.call.should == [1,2,3]
59
+ group.subject.call.should eq([1,2,3])
60
60
  end
61
61
  end
62
62
 
@@ -69,13 +69,13 @@ module RSpec::Core
69
69
 
70
70
  it "is available in a nested group (subclass)" do
71
71
  nested_group = group.describe("I'm nested!") { }
72
- nested_group.subject.call.should == [4,5,6]
72
+ nested_group.subject.call.should eq([4,5,6])
73
73
  end
74
74
 
75
75
  it "is available in a doubly nested group (subclass)" do
76
76
  nested_group = group.describe("Nesting level 1") { }
77
77
  doubly_nested_group = nested_group.describe("Nesting level 2") { }
78
- doubly_nested_group.subject.call.should == [4,5,6]
78
+ doubly_nested_group.subject.call.should eq([4,5,6])
79
79
  end
80
80
  end
81
81
  end
@@ -149,9 +149,9 @@ module RSpec::Core
149
149
  end
150
150
  end.new
151
151
  end
152
- its([:a]) { should == 'Symbol: a' }
153
- its(['a']) { should == 'String: a' }
154
- its([:b, 'c', 4]) { should == 'Symbol: b; String: c; Fixnum: 4' }
152
+ its([:a]) { should eq("Symbol: a") }
153
+ its(['a']) { should eq("String: a") }
154
+ its([:b, 'c', 4]) { should eq("Symbol: b; String: c; Fixnum: 4") }
155
155
  its(:name) { should = "George" }
156
156
  context "when referring to an attribute without the proper array syntax" do
157
157
  context "it raises an error" do
@@ -170,7 +170,7 @@ module RSpec::Core
170
170
  context "it raises an error" do
171
171
  its([:a]) do
172
172
  expect do
173
- should == 'Symbol: a'
173
+ should eq("Symbol: a")
174
174
  end.to raise_error(NoMethodError)
175
175
  end
176
176
  end
@@ -181,12 +181,12 @@ module RSpec::Core
181
181
  group = ExampleGroup.describe(Array) do
182
182
  subject { [1, 'a'] }
183
183
 
184
- its(:last) { should == 'a' }
184
+ its(:last) { should eq("a") }
185
185
 
186
186
  describe '.first' do
187
187
  def subject; super().first; end
188
188
 
189
- its(:next) { should == 2 }
189
+ its(:next) { should eq(2) }
190
190
  end
191
191
  end
192
192
 
@@ -49,35 +49,35 @@ module RSpec::Core
49
49
  let(:example_groups) { [group1, group2, group3, group4] }
50
50
 
51
51
  it "finds no groups when given no search parameters" do
52
- world.apply_inclusion_filters([]).should == []
52
+ world.apply_inclusion_filters([],{}).should eq([])
53
53
  end
54
54
 
55
55
  it "finds matching groups when filtering on :describes (described class or module)" do
56
- world.apply_inclusion_filters(example_groups, :example_group => { :describes => Bar }).should == [group1, group2, group3]
56
+ world.apply_inclusion_filters(example_groups, :example_group => { :describes => Bar }).should eq([group1, group2, group3])
57
57
  end
58
58
 
59
59
  it "finds matching groups when filtering on :description with text" do
60
- world.apply_inclusion_filters(example_groups, :example_group => { :description => 'Bar find group-1' }).should == [group1]
60
+ world.apply_inclusion_filters(example_groups, :example_group => { :description => 'Bar find group-1' }).should eq([group1])
61
61
  end
62
62
 
63
63
  it "finds matching groups when filtering on :description with a lambda" do
64
- world.apply_inclusion_filters(example_groups, :example_group => { :description => lambda { |v| v.include?('-1') || v.include?('-3') } }).should == [group1, group3]
64
+ world.apply_inclusion_filters(example_groups, :example_group => { :description => lambda { |v| v.include?('-1') || v.include?('-3') } }).should eq([group1, group3])
65
65
  end
66
66
 
67
67
  it "finds matching groups when filtering on :description with a regular expression" do
68
- world.apply_inclusion_filters(example_groups, :example_group => { :description => /find group/ }).should == [group1, group2, group3]
68
+ world.apply_inclusion_filters(example_groups, :example_group => { :description => /find group/ }).should eq([group1, group2, group3])
69
69
  end
70
70
 
71
71
  it "finds one group when searching for :pending => true" do
72
- world.apply_inclusion_filters(example_groups, :pending => true ).should == [group2]
72
+ world.apply_inclusion_filters(example_groups, :pending => true ).should eq([group2])
73
73
  end
74
74
 
75
75
  it "finds matching groups when filtering on arbitrary metadata with a number" do
76
- world.apply_inclusion_filters(example_groups, :foo => 1 ).should == [group1]
76
+ world.apply_inclusion_filters(example_groups, :foo => 1 ).should eq([group1])
77
77
  end
78
78
 
79
79
  it "finds matching groups when filtering on arbitrary metadata with an array" do
80
- world.apply_inclusion_filters(example_groups, :array => [1,2,3,4]).should == [group3]
80
+ world.apply_inclusion_filters(example_groups, :array => [1,2,3,4]).should eq([group3])
81
81
  end
82
82
 
83
83
  it "finds no groups when filtering on arbitrary metadata with an array but the arrays do not match" do
@@ -85,11 +85,11 @@ module RSpec::Core
85
85
  end
86
86
 
87
87
  it "finds matching examples when filtering on arbitrary metadata" do
88
- world.apply_inclusion_filters(group4.examples, :awesome => true).should == [group4.examples[1], group4.examples[2]]
88
+ world.apply_inclusion_filters(group4.examples, :awesome => true).should eq([group4.examples[1], group4.examples[2]])
89
89
  end
90
90
 
91
91
  it "finds matching examples for example that match any of the filters" do
92
- world.apply_inclusion_filters(group4.examples, :awesome => true, :something => :else).should == [group4.examples[1], group4.examples[2]]
92
+ world.apply_inclusion_filters(group4.examples, :awesome => true, :something => :else).should eq([group4.examples[1], group4.examples[2]])
93
93
  end
94
94
  end
95
95
 
@@ -105,7 +105,7 @@ module RSpec::Core
105
105
 
106
106
  world.register(group1)
107
107
 
108
- world.apply_exclusion_filters(group1.examples, :network_access => true).should == []
108
+ world.apply_exclusion_filters(group1.examples, :network_access => true).should eq([])
109
109
 
110
110
  group2 = ExampleGroup.describe(Bar, "find group-1") do
111
111
  it("foo", :network_access => true) {}
@@ -114,7 +114,7 @@ module RSpec::Core
114
114
 
115
115
  world.register(group2)
116
116
 
117
- world.apply_exclusion_filters(group2.examples, :network_access => true).should == [group2.examples.last]
117
+ world.apply_exclusion_filters(group2.examples, :network_access => true).should eq([group2.examples.last])
118
118
  end
119
119
 
120
120
  it "finds nothing if a regexp matches the exclusion filter" do
@@ -123,14 +123,23 @@ module RSpec::Core
123
123
  it("bar") {}
124
124
  end
125
125
  world.register(group)
126
- world.apply_exclusion_filters(group.examples, :name => /exclude/).should == []
127
- world.apply_exclusion_filters(group.examples, :name => /exclude/, :another => "foo").should == []
126
+ world.apply_exclusion_filters(group.examples, :name => /exclude/).should eq([])
127
+ world.apply_exclusion_filters(group.examples, :name => /exclude/, :another => "foo").should eq([])
128
128
  world.apply_exclusion_filters(group.examples, :name => /exclude/, :another => "foo", :example_group => {
129
- :describes => lambda { |b| b == Bar } } ).should == []
129
+ :describes => lambda { |b| b == Bar } } ).should eq([])
130
130
 
131
- world.apply_exclusion_filters(group.examples, :name => /exclude not/).should == group.examples
132
- world.apply_exclusion_filters(group.examples, :name => /exclude/, "another_condition" => "foo").should == []
133
- world.apply_exclusion_filters(group.examples, :name => /exclude/, "another_condition" => "foo1").should == []
131
+ world.apply_exclusion_filters(group.examples, :name => /exclude not/).should eq(group.examples)
132
+ world.apply_exclusion_filters(group.examples, :name => /exclude/, "another_condition" => "foo").should eq([])
133
+ world.apply_exclusion_filters(group.examples, :name => /exclude/, "another_condition" => "foo1").should eq([])
134
+ end
135
+
136
+ it "finds all if filters are empty" do
137
+ group = ExampleGroup.describe(Bar) do
138
+ example("foo") {}
139
+ example("bar") {}
140
+ end
141
+ world.register(group)
142
+ world.apply_exclusion_filters(group.examples, {}).should eq(group.examples)
134
143
  end
135
144
  end
136
145
 
@@ -269,22 +278,22 @@ module RSpec::Core
269
278
  describe "#exclusion_filter" do
270
279
  describe "#description" do
271
280
  it 'returns `{}` when it only contains the default filters' do
272
- world.exclusion_filter.description.should == {}.inspect
281
+ world.exclusion_filter.description.should eq({}.inspect)
273
282
  end
274
283
 
275
284
  it 'includes other filters' do
276
285
  configuration.exclusion_filter[:foo] = :bar
277
- world.exclusion_filter.description.should == { :foo => :bar }.inspect
286
+ world.exclusion_filter.description.should eq({ :foo => :bar }.inspect)
278
287
  end
279
288
 
280
289
  it 'includes an overriden :if filter' do
281
290
  configuration.exclusion_filter[:if] = :custom_filter
282
- world.exclusion_filter.description.should == { :if => :custom_filter }.inspect
291
+ world.exclusion_filter.description.should eq({ :if => :custom_filter }.inspect)
283
292
  end
284
293
 
285
294
  it 'includes an overriden :unless filter' do
286
295
  configuration.exclusion_filter[:unless] = :custom_filter
287
- world.exclusion_filter.description.should == { :unless => :custom_filter }.inspect
296
+ world.exclusion_filter.description.should eq({ :unless => :custom_filter }.inspect)
288
297
  end
289
298
 
290
299
  it 'cleans up the description' do
@@ -11,41 +11,13 @@ describe RSpec::Core do
11
11
  end
12
12
 
13
13
  describe "#configure" do
14
- around(:each) do |example|
15
- RSpec.allowing_configure_warning(&example)
16
- end
17
-
18
- before(:each) do
19
- RSpec.stub(:warn)
20
- end
21
14
 
22
15
  it "yields the current configuration" do
23
16
  RSpec.configure do |config|
24
- config.should == RSpec::configuration
25
- end
26
- end
27
-
28
- context "when an example group has already been defined" do
29
- before(:each) do
30
- RSpec.world.stub(:example_groups).and_return([double.as_null_object])
31
- end
32
-
33
- it "prints a deprecation warning" do
34
- RSpec.should_receive(:warn).with(/configuration should happen before the first example group/)
35
- RSpec.configure { |c| }
17
+ config.should eq(RSpec::configuration)
36
18
  end
37
19
  end
38
20
 
39
- context "when no examples have been defined yet" do
40
- before(:each) do
41
- RSpec.world.stub(:example_groups).and_return([])
42
- end
43
-
44
- it "does not print a deprecation warning" do
45
- RSpec.should_not_receive(:warn)
46
- RSpec.configure { |c| }
47
- end
48
- end
49
21
  end
50
22
 
51
23
  describe "#world" do
data/spec/spec_helper.rb CHANGED
@@ -1,39 +1,55 @@
1
- require 'rspec/core'
2
- require 'autotest/rspec2'
1
+ require 'rubygems'
3
2
 
4
- Dir['./spec/support/**/*.rb'].map {|f| require f}
3
+ begin
4
+ require 'spork'
5
+ rescue LoadError
6
+ module Spork
7
+ def self.prefork
8
+ yield
9
+ end
5
10
 
6
- class NullObject
7
- private
8
- def method_missing(method, *args, &block)
9
- # ignore
11
+ def self.each_run
12
+ yield
13
+ end
10
14
  end
11
15
  end
12
16
 
13
- def sandboxed(&block)
14
- begin
15
- @orig_config = RSpec.configuration
16
- @orig_world = RSpec.world
17
- new_config = RSpec::Core::Configuration.new
18
- new_world = RSpec::Core::World.new(new_config)
19
- RSpec.instance_variable_set(:@configuration, new_config)
20
- RSpec.instance_variable_set(:@world, new_world)
21
- object = Object.new
22
- object.extend(RSpec::Core::ObjectExtensions)
23
- object.extend(RSpec::Core::SharedExampleGroup)
17
+ Spork.prefork do
18
+ require 'rspec/autorun'
19
+ require 'autotest/rspec2'
24
20
 
25
- (class << RSpec::Core::ExampleGroup; self; end).class_eval do
26
- alias_method :orig_run, :run
27
- def run(reporter=nil)
28
- @orig_mock_space = RSpec::Mocks::space
29
- RSpec::Mocks::space = RSpec::Mocks::Space.new
30
- orig_run(reporter || NullObject.new)
31
- ensure
32
- RSpec::Mocks::space = @orig_mock_space
33
- end
21
+ Dir['./spec/support/**/*.rb'].map {|f| require f}
22
+
23
+ class NullObject
24
+ private
25
+ def method_missing(method, *args, &block)
26
+ # ignore
34
27
  end
28
+ end
35
29
 
36
- object.instance_eval(&block)
30
+ def sandboxed(&block)
31
+ begin
32
+ @orig_config = RSpec.configuration
33
+ @orig_world = RSpec.world
34
+ new_config = RSpec::Core::Configuration.new
35
+ new_world = RSpec::Core::World.new(new_config)
36
+ RSpec.instance_variable_set(:@configuration, new_config)
37
+ RSpec.instance_variable_set(:@world, new_world)
38
+ object = Object.new
39
+ object.extend(RSpec::Core::SharedExampleGroup)
40
+
41
+ (class << RSpec::Core::ExampleGroup; self; end).class_eval do
42
+ alias_method :orig_run, :run
43
+ def run(reporter=nil)
44
+ @orig_mock_space = RSpec::Mocks::space
45
+ RSpec::Mocks::space = RSpec::Mocks::Space.new
46
+ orig_run(reporter || NullObject.new)
47
+ ensure
48
+ RSpec::Mocks::space = @orig_mock_space
49
+ end
50
+ end
51
+
52
+ object.instance_eval(&block)
37
53
  ensure
38
54
  (class << RSpec::Core::ExampleGroup; self; end).class_eval do
39
55
  remove_method :run
@@ -43,34 +59,13 @@ def sandboxed(&block)
43
59
 
44
60
  RSpec.instance_variable_set(:@configuration, @orig_config)
45
61
  RSpec.instance_variable_set(:@world, @orig_world)
46
- end
62
+ end
47
63
  end
48
64
 
49
65
  def in_editor?
50
66
  ENV.has_key?('TM_MODE') || ENV.has_key?('EMACS') || ENV.has_key?('VIM')
51
67
  end
52
68
 
53
- class << RSpec
54
- alias_method :original_warn_about_deprecated_configure, :warn_about_deprecated_configure
55
-
56
- def warn_about_deprecated_configure
57
- # no-op: in our specs we don't want to see the warning.
58
- end
59
-
60
- alias_method :null_warn_about_deprecated_configure, :warn_about_deprecated_configure
61
-
62
- def allowing_configure_warning
63
- (class << self; self; end).class_eval do
64
- alias_method :warn_about_deprecated_configure, :original_warn_about_deprecated_configure
65
- begin
66
- yield
67
- ensure
68
- alias_method :warn_about_deprecated_configure, :null_warn_about_deprecated_configure
69
- end
70
- end
71
- end
72
- end
73
-
74
69
  RSpec.configure do |c|
75
70
  c.color_enabled = !in_editor?
76
71
  c.filter_run :focus => true
@@ -85,7 +80,13 @@ RSpec.configure do |c|
85
80
  !(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
86
81
  end
87
82
  }
83
+ c.alias_it_should_behave_like_to 'it_has_behavior'
88
84
  c.around do |example|
89
85
  sandboxed { example.run }
90
86
  end
91
87
  end
88
+ end
89
+
90
+ Spork.each_run do
91
+ end
92
+
@@ -7,12 +7,12 @@ shared_examples_for "metadata hash builder" do
7
7
  end
8
8
 
9
9
  it 'treats symbols as metadata keys with a true value' do
10
- hash[:foo].should == true
11
- hash[:bar].should == true
10
+ hash[:foo].should be(true)
11
+ hash[:bar].should be(true)
12
12
  end
13
13
 
14
14
  it 'still processes hash values normally' do
15
- hash[:bazz].should == 23
15
+ hash[:bazz].should be(23)
16
16
  end
17
17
  end
18
18
 
@@ -10,11 +10,11 @@ shared_context "spec files" do
10
10
  def create_passing_spec_file
11
11
  File.open(passing_spec_filename, 'w') do |f|
12
12
  f.write %q{
13
- describe "passing spec" do
14
- it "passes" do
15
- 1.should eq(1)
16
- end
13
+ describe "passing spec" do
14
+ it "passes" do
15
+ 1.should eq(1)
17
16
  end
17
+ end
18
18
  }
19
19
  end
20
20
  end
@@ -22,11 +22,11 @@ shared_context "spec files" do
22
22
  def create_failing_spec_file
23
23
  File.open(failing_spec_filename, 'w') do |f|
24
24
  f.write %q{
25
- describe "failing spec" do
26
- it "fails" do
27
- 1.should eq(2)
28
- end
25
+ describe "failing spec" do
26
+ it "fails" do
27
+ 1.should eq(2)
29
28
  end
29
+ end
30
30
  }
31
31
  end
32
32
  end