Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

move world from Rspec::Core to Rspec

  • Loading branch information...
commit b0288062ad822fc0d090e8f74adceb2c1d6806f5 1 parent 5d95ab9
David Chelimsky dchelimsky authored
7 lib/rspec/core.rb
View
@@ -40,11 +40,16 @@ def self.configure
end
def self.world
- @world ||= Rspec::Core::World.new
+ Rspec.deprecate('Rspec::Core.world', 'Rspec.world', '2.0.0')
+ Rspec.world
end
end
+ def self.world
+ @world ||= Rspec::Core::World.new
+ end
+
def self.configuration
@configuration ||= Rspec::Core::Configuration.new
end
6 lib/rspec/core/example_group.rb
View
@@ -10,7 +10,7 @@ class ExampleGroup
def self.inherited(klass)
Rspec::Core::Runner.autorun
- Rspec::Core.world.example_groups << klass if klass.superclass == ExampleGroup
+ Rspec.world.example_groups << klass if klass.superclass == ExampleGroup
end
class << self
@@ -56,7 +56,7 @@ class << self
def self.it_should_behave_like(*names)
names.each do |name|
begin
- module_eval &Rspec::Core.world.shared_example_groups[name]
+ module_eval &Rspec.world.shared_example_groups[name]
rescue ArgumentError
raise "Could not find shared example group named #{name.inspect}"
end
@@ -75,7 +75,7 @@ def self.filtered_examples(fresh = false)
end
def self.world
- Rspec::Core.world
+ Rspec.world
end
def self.superclass_metadata
4 lib/rspec/core/formatters/base_formatter.rb
View
@@ -18,11 +18,11 @@ def output
end
def pending_examples
- @pending_examples ||= ::Rspec::Core.world.find(examples, :execution_result => { :status => 'pending' })
+ @pending_examples ||= ::Rspec.world.find(examples, :execution_result => { :status => 'pending' })
end
def failed_examples
- @failed_examples ||= ::Rspec::Core.world.find(examples, :execution_result => { :status => 'failed' })
+ @failed_examples ||= ::Rspec.world.find(examples, :execution_result => { :status => 'failed' })
end
def report(count)
2  lib/rspec/core/metadata.rb
View
@@ -119,7 +119,7 @@ def apply_condition(filter_on, filter, metadata=nil)
private
def world
- Rspec::Core.world
+ Rspec.world
end
def superclass_metadata
6 lib/rspec/core/runner.rb
View
@@ -39,7 +39,7 @@ def run(args = [])
def announce_inclusion_filter
if inclusion_filter
- if Rspec.configuration.run_all_when_everything_filtered? && Rspec::Core.world.example_count == 0
+ if Rspec.configuration.run_all_when_everything_filtered? && Rspec.world.example_count == 0
Rspec.configuration.puts "No examples were matched by #{inclusion_filter.inspect}, running all"
Rspec.configuration.clear_inclusion_filter
else
@@ -55,11 +55,11 @@ def configure(args)
end
def example_count
- Rspec::Core.world.example_count
+ Rspec.world.example_count
end
def example_groups
- Rspec::Core.world.example_groups.extend(ExampleGroups)
+ Rspec.world.example_groups.extend(ExampleGroups)
end
module ExampleGroups
6 lib/rspec/core/shared_example_group.rb
View
@@ -4,7 +4,7 @@ module SharedExampleGroup
def share_examples_for(name, &block)
ensure_shared_example_group_name_not_taken(name)
- Rspec::Core.world.shared_example_groups[name] = block
+ Rspec.world.shared_example_groups[name] = block
end
def share_as(name, &block)
@@ -27,7 +27,7 @@ def self.included(kls)
end
shared_const = Object.const_set(name, mod)
- Rspec::Core.world.shared_example_groups[shared_const] = block
+ Rspec.world.shared_example_groups[shared_const] = block
end
alias :shared_examples_for :share_examples_for
@@ -39,7 +39,7 @@ def raise_name_error
end
def ensure_shared_example_group_name_not_taken(name)
- if Rspec::Core.world.shared_example_groups.has_key?(name)
+ if Rspec.world.shared_example_groups.has_key?(name)
raise ArgumentError.new("Shared example group '#{name}' already exists")
end
end
2  spec/rspec/core/configuration_spec.rb
View
@@ -7,7 +7,7 @@ module Rspec::Core
let(:config) { subject }
before(:each) do
- Rspec::Core.world.stub(:configuration).and_return(config)
+ Rspec.world.stub(:configuration).and_return(config)
end
describe "#mock_framework_class" do
12 spec/rspec/core/example_group_spec.rb
View
@@ -52,13 +52,13 @@ module Rspec::Core
it "is not registered in world" do
parent = ExampleGroup.describe
child = parent.describe
- Rspec::Core.world.example_groups.should == [parent]
+ Rspec.world.example_groups.should == [parent]
end
end
describe "filtering" do
it "includes all examples in an explicitly included group" do
- Rspec::Core.world.stub(:inclusion_filter).and_return({ :awesome => true })
+ Rspec.world.stub(:inclusion_filter).and_return({ :awesome => true })
group = ExampleGroup.describe("does something", :awesome => true)
examples = [
group.example("first"),
@@ -68,7 +68,7 @@ module Rspec::Core
end
it "includes explicitly included examples" do
- Rspec::Core.world.stub(:inclusion_filter).and_return({ :awesome => true })
+ Rspec.world.stub(:inclusion_filter).and_return({ :awesome => true })
group = ExampleGroup.describe
example = group.example("does something", :awesome => true)
group.example("don't run me")
@@ -76,7 +76,7 @@ module Rspec::Core
end
it "excludes all examples in an excluded group" do
- Rspec::Core.world.stub(:exclusion_filter).and_return({ :awesome => false })
+ Rspec.world.stub(:exclusion_filter).and_return({ :awesome => false })
group = ExampleGroup.describe("does something", :awesome => false)
examples = [
group.example("first"),
@@ -86,7 +86,7 @@ module Rspec::Core
end
it "filters out excluded examples" do
- Rspec::Core.world.stub(:exclusion_filter).and_return({ :awesome => false })
+ Rspec.world.stub(:exclusion_filter).and_return({ :awesome => false })
group = ExampleGroup.describe("does something")
examples = [
group.example("first", :awesome => false),
@@ -105,7 +105,7 @@ module Rspec::Core
context "with no examples or groups that match filters" do
it "returns none" do
- Rspec::Core.world.stub(:inclusion_filter).and_return({ :awesome => false })
+ Rspec.world.stub(:inclusion_filter).and_return({ :awesome => false })
group = ExampleGroup.describe
example = group.example("does something")
group.filtered_examples.should == []
2  spec/rspec/core/metadata_spec.rb
View
@@ -190,7 +190,7 @@ module Core
let(:example_line_number) { __LINE__ -1 }
let(:next_example_metadata) {group_metadata.for_example('next_example',
:caller => ["foo_spec.rb:#{example_line_number + 2}"])}
- let(:world) { Rspec::Core.world }
+ let(:world) { Rspec.world }
it "matches the group when the line_number is the example group line number" do
world.should_receive(:preceding_declaration_line).and_return(group_line_number)
4 spec/rspec/core/shared_example_group_spec.rb
View
@@ -27,7 +27,7 @@ module Rspec::Core
describe "share_examples_for" do
it "should capture the given name and block in the Worlds collection of shared example groups" do
- Rspec::Core.world.shared_example_groups.should_receive(:[]=).with(:foo, anything)
+ Rspec.world.shared_example_groups.should_receive(:[]=).with(:foo, anything)
share_examples_for(:foo) { }
end
@@ -41,7 +41,7 @@ module Rspec::Core
def self.class_helper; end
def extra_helper; end
}
- Rspec::Core.world.stub(:shared_example_groups).and_return({ :shared_example_group => block })
+ Rspec.world.stub(:shared_example_groups).and_return({ :shared_example_group => block })
group.it_should_behave_like :shared_example_group
group.instance_methods.should include('extra_helper')
group.singleton_methods.should include('class_helper')
3  spec/rspec/core/world_spec.rb
View
@@ -8,8 +8,7 @@ module Rspec::Core
describe World do
before do
- @world = Rspec::Core::World.new
- Rspec::Core.stub(:world).and_return(@world)
+ @world = Rspec.world
end
describe "example_groups" do
2  spec/rspec/core_spec.rb
View
@@ -31,7 +31,7 @@
describe "#world" do
it "should return the Rspec::Core::World instance the current run is using" do
- Rspec::Core.world.should be_instance_of(Rspec::Core::World)
+ Rspec.world.should be_instance_of(Rspec::Core::World)
end
end
6 spec/spec_helper.rb
View
@@ -46,10 +46,10 @@ def in_editor?
!(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
}}
c.before(:each) do
- @real_world = Rspec::Core.world
- Rspec::Core.instance_variable_set(:@world, Rspec::Core::World.new)
+ @real_world = Rspec.world
+ Rspec.instance_variable_set(:@world, Rspec::Core::World.new)
end
c.after(:each) do
- Rspec::Core.instance_variable_set(:@world, @real_world)
+ Rspec.instance_variable_set(:@world, @real_world)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.