Permalink
Browse files

Deprecate around hook

- it was experimental and didn't really work
- it didn't really have a useful API
- before/after is a perfectly good solution
  • Loading branch information...
1 parent bd7a28e commit b611184f50aab13b0c2671f861d78a725defe4f8 @dchelimsky dchelimsky committed Jun 13, 2010
View
36 features/hooks/around_hook.feature
@@ -1,36 +0,0 @@
-Feature: around hook
-
- Scenario: define around(:each) block in example group
- Given a file named "around_each_in_example_group_spec.rb" with:
- """
- require 'rspec/expectations'
-
- class Thing
- def self.cache
- @cache ||= []
- end
-
- def initialize
- self.class.cache << self
- end
- end
-
- describe Thing do
- around(:each) do |example|
- Thing.new
- example.run
- Thing.cache.clear
- end
-
- it "has 1 Thing (1)" do
- Thing.cache.length.should == 1
- end
-
- it "has 1 Thing (2)" do
- Thing.cache.length.should == 1
- end
- end
- """
- When I run "rspec ./around_each_in_example_group_spec.rb"
- Then the stderr should not contain "NoMethodError"
- Then I should see "2 examples, 0 failures"
View
7 features/hooks/halt.feature
@@ -1,10 +1,9 @@
Feature: halt
- In an example, before hook, after hook, or around hook, you can
- halt the current example, group, or suite based on arbitrary
- criteria.
+ In an example, before or after hook, you can halt the current example, group,
+ or suite based on arbitrary criteria.
- @wip
+@wip
Scenario: halt group on failure
Given a directory named "spec"
And a file named "spec/example_spec.rb" with:
View
1 lib/rspec/core/hooks.rb
@@ -42,6 +42,7 @@ def around_eachs
end
def around(type=:each, &block)
+ RSpec::deprecate("around", "before and after")
around_blocks[type] << block
end
end
View
3 rspec-core.gemspec
@@ -39,7 +39,6 @@ Gem::Specification.new do |s|
"features/example_groups/nested_groups.feature",
"features/filtering/inclusion_filters.feature",
"features/formatters/custom_formatter.feature",
- "features/hooks/around_hook.feature",
"features/hooks/before_and_after_hooks.feature",
"features/hooks/described_class.feature",
"features/hooks/halt.feature",
@@ -107,6 +106,7 @@ Gem::Specification.new do |s|
"spec/rspec/core/formatters/documentation_formatter_spec.rb",
"spec/rspec/core/formatters/helpers_spec.rb",
"spec/rspec/core/formatters/progress_formatter_spec.rb",
+ "spec/rspec/core/hooks_spec.rb",
"spec/rspec/core/kernel_extensions_spec.rb",
"spec/rspec/core/let_spec.rb",
"spec/rspec/core/metadata_spec.rb",
@@ -154,6 +154,7 @@ Gem::Specification.new do |s|
"spec/rspec/core/formatters/documentation_formatter_spec.rb",
"spec/rspec/core/formatters/helpers_spec.rb",
"spec/rspec/core/formatters/progress_formatter_spec.rb",
+ "spec/rspec/core/hooks_spec.rb",
"spec/rspec/core/kernel_extensions_spec.rb",
"spec/rspec/core/let_spec.rb",
"spec/rspec/core/metadata_spec.rb",
View
10 spec/rspec/core/configuration_options_spec.rb
@@ -289,10 +289,12 @@ def options_from_args(*args)
end
context "with SPEC_OPTS" do
- around do |example|
- orig_spec_opts = ENV["SPEC_OPTS"]
- example.run
- ENV["SPEC_OPTS"] = orig_spec_opts
+ before do
+ @orig_spec_opts = ENV["SPEC_OPTS"]
+ end
+
+ after do
+ ENV["SPEC_OPTS"] = @orig_spec_opts
end
it "prefers SPEC_OPTS options over file options" do
View
22 spec/rspec/core/example_group_spec.rb
@@ -249,12 +249,6 @@ module RSpec::Core
end.to_not raise_error
end
- it "exposes the around each blocks at after_alls" do
- group = ExampleGroup.describe
- group.around(:each) { 'foo' }
- group.should have(1).around_eachs
- end
-
it "treats an error in before(:each) as a failure" do
group = ExampleGroup.describe
group.before(:each) { raise "error in before each" }
@@ -426,22 +420,6 @@ module RSpec::Core
end
end
- describe "#around" do
- around(:each) do |example|
- SelfObserver.new
- example.run
- SelfObserver.cache.clear
- end
-
- it "has 1 SelfObserver (1)" do
- SelfObserver.cache.length.should == 1
- end
-
- it "has 1 SelfObserver (2)" do
- SelfObserver.cache.length.should == 1
- end
- end
-
describe "#its" do
its(:class) { should == RSpec::Core::ExampleGroup }
it "does not interfere between examples" do
View
13 spec/rspec/core/hooks_spec.rb
@@ -0,0 +1,13 @@
+require "spec_helper"
+
+module RSpec::Core
+ describe Hooks do
+ describe "#around" do
+ it "is deprecated" do
+ RSpec.should_receive(:deprecate)
+ subject = Object.new.extend(Hooks)
+ subject.around(:each) {}
+ end
+ end
+ end
+end

0 comments on commit b611184

Please sign in to comment.