diff --git a/features/hooks/halt.feature b/features/hooks/halt.feature index 2d0a2feddd..31e8f7dc42 100644 --- a/features/hooks/halt.feature +++ b/features/hooks/halt.feature @@ -10,7 +10,7 @@ Feature: halt """ RSpec.configure do |c| c.after(:each) do - running_example.halt(:group, :status => 'failed') + example.halt(:group, :status => 'failed') end end describe "something" do diff --git a/lib/rspec/core/example.rb b/lib/rspec/core/example.rb index 825866f416..35a2d66fbd 100644 --- a/lib/rspec/core/example.rb +++ b/lib/rspec/core/example.rb @@ -33,7 +33,7 @@ def in_block? def run(example_group_instance, reporter) @in_block = false @example_group_instance = example_group_instance - @example_group_instance.running_example = self + @example_group_instance.example = self run_started @@ -62,7 +62,7 @@ def run(example_group_instance, reporter) rescue Exception => e exception ||= e ensure - @example_group_instance.running_example = nil + @example_group_instance.example = nil end if exception diff --git a/lib/rspec/core/example_group.rb b/lib/rspec/core/example_group.rb index dcbc25dab6..9ca2e221c7 100644 --- a/lib/rspec/core/example_group.rb +++ b/lib/rspec/core/example_group.rb @@ -6,7 +6,7 @@ class ExampleGroup include Let include Pending - attr_accessor :running_example + attr_accessor :example def self.world RSpec.world diff --git a/lib/rspec/core/pending.rb b/lib/rspec/core/pending.rb index cbd250118d..453391e03f 100644 --- a/lib/rspec/core/pending.rb +++ b/lib/rspec/core/pending.rb @@ -2,12 +2,12 @@ module RSpec module Core module Pending def pending(message = 'No reason given') - running_example.metadata[:pending] = true - running_example.metadata[:execution_result][:pending_message] = message + example.metadata[:pending] = true + example.metadata[:execution_result][:pending_message] = message if block_given? begin result = yield - running_example.metadata[:pending] = false + example.metadata[:pending] = false rescue Exception => e end raise RSpec::Core::PendingExampleFixedError.new if result diff --git a/lib/rspec/core/subject.rb b/lib/rspec/core/subject.rb index 240d034b91..9ba6410cbd 100644 --- a/lib/rspec/core/subject.rb +++ b/lib/rspec/core/subject.rb @@ -80,12 +80,12 @@ def original_subject end def attribute_of_subject - original_subject.send(running_example.description) if using_attribute? + original_subject.send(example.description) if using_attribute? end def using_attribute? - running_example.in_block? && - running_example.metadata[:attribute_of_subject] + example.in_block? && + example.metadata[:attribute_of_subject] end end diff --git a/spec/rspec/core/example_group_spec.rb b/spec/rspec/core/example_group_spec.rb index 3019bff1eb..23f03c6b0c 100644 --- a/spec/rspec/core/example_group_spec.rb +++ b/spec/rspec/core/example_group_spec.rb @@ -20,7 +20,7 @@ module RSpec::Core group = ExampleGroup.describe("parent") do describe("child") do it "does something" do - examples_run << running_example + examples_run << example end end end @@ -308,19 +308,19 @@ module RSpec::Core describe "A sample nested group", :nested_describe => "yep" do it "sets the described class to the constant Object" do - running_example.example_group.describes.should == Object + example.example_group.describes.should == Object end it "sets the description to 'A sample nested describe'" do - running_example.example_group.description.should == 'A sample nested group' + example.example_group.description.should == 'A sample nested group' end it "has top level metadata from the example_group and its ancestors" do - running_example.example_group.metadata.should include(:little_less_nested => 'yep', :nested_describe => 'yep') + example.example_group.metadata.should include(:little_less_nested => 'yep', :nested_describe => 'yep') end it "exposes the parent metadata to the contained examples" do - running_example.metadata.should include(:little_less_nested => 'yep', :nested_describe => 'yep') + example.metadata.should include(:little_less_nested => 'yep', :nested_describe => 'yep') end end @@ -379,11 +379,11 @@ module RSpec::Core end it "should be able to access the before all ivars in the before_all_ivars hash", :ruby => 1.8 do - running_example.example_group.before_all_ivars.should include('@before_all_top_level' => 'before_all_top_level') + example.example_group.before_all_ivars.should include('@before_all_top_level' => 'before_all_top_level') end it "should be able to access the before all ivars in the before_all_ivars hash", :ruby => 1.9 do - running_example.example_group.before_all_ivars.should include(:@before_all_top_level => 'before_all_top_level') + example.example_group.before_all_ivars.should include(:@before_all_top_level => 'before_all_top_level') end describe "but now I am nested" do diff --git a/spec/rspec/core/example_spec.rb b/spec/rspec/core/example_spec.rb index 362478b8ba..496c1b2385 100644 --- a/spec/rspec/core/example_spec.rb +++ b/spec/rspec/core/example_spec.rb @@ -5,37 +5,37 @@ RSpec::Core::ExampleGroup.describe('group description') end - let(:example) do + let(:example_instance) do example_group.example('example description') end describe "attr readers" do it "should have one for the parent example group" do - example.should respond_to(:example_group) + example_instance.should respond_to(:example_group) end - it "should have one for it's description" do - example.should respond_to(:description) + it "should have one for its description" do + example_instance.should respond_to(:description) end - it "should have one for it's metadata" do - example.should respond_to(:metadata) + it "should have one for its metadata" do + example_instance.should respond_to(:metadata) end - it "should have one for it's block" do - example.should respond_to(:example_block) + it "should have one for its block" do + example_instance.should respond_to(:example_block) end end describe '#inspect' do it "should return 'group description - description'" do - example.inspect.should == 'group description example description' + example_instance.inspect.should == 'group description example description' end end describe '#to_s' do it "should return #inspect" do - example.to_s.should == example.inspect + example_instance.to_s.should == example_instance.inspect end end @@ -47,12 +47,12 @@ describe "accessing metadata within a running example" do it "should have a reference to itself when running" do - running_example.description.should == "should have a reference to itself when running" + example.description.should == "should have a reference to itself when running" end it "should be able to access the example group's top level metadata as if it were its own" do - running_example.example_group.metadata.should include(:parent_metadata => 'sample') - running_example.metadata.should include(:parent_metadata => 'sample') + example.example_group.metadata.should include(:parent_metadata => 'sample') + example.metadata.should include(:parent_metadata => 'sample') end end @@ -81,7 +81,7 @@ after_run = false group = RSpec::Core::ExampleGroup.describe do after(:each) { after_run = true } - example('example') { raise "this error" } + example('example') { raise "this error" } end group.run_all after_run.should be_true, "expected after(:each) to be run" @@ -90,13 +90,13 @@ describe "#in_block?" do before do - running_example.should_not be_in_block + example.should_not be_in_block end it "is only true during the example (but not before or after)" do - running_example.should be_in_block + example.should be_in_block end after do - running_example.should_not be_in_block + example.should_not be_in_block end end end diff --git a/spec/rspec/core/shared_example_group_spec.rb b/spec/rspec/core/shared_example_group_spec.rb index 4e4ce5c190..44c71a9221 100644 --- a/spec/rspec/core/shared_example_group_spec.rb +++ b/spec/rspec/core/shared_example_group_spec.rb @@ -172,7 +172,7 @@ def count(scope) it "has one example" do; end it "has another example" do; end it "includes modules, included into shared example_group, into current example_group", :compat => 'rspec-1.2' do - raise "FAIL" unless running_example.example_group.included_modules.include?(RunningSharedExamplesJustForTesting) + raise "FAIL" unless example.example_group.included_modules.include?(RunningSharedExamplesJustForTesting) end end end