Browse files

Rename "running_example" to "example"

  • Loading branch information...
1 parent f9bcb44 commit 39d692b99636870aff1c13c02b022949b5ff374e @wincent wincent committed with dchelimsky Jun 17, 2010
View
2 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
View
4 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
View
2 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
View
6 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
View
6 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
View
14 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
View
34 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
View
2 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

0 comments on commit 39d692b

Please sign in to comment.