Browse files

Move Rspec::Core.configuration to Rspec.configuration

  • Loading branch information...
1 parent 3c44743 commit 72be374084e793f92f6f7f8956d0f4e22de3c496 @dchelimsky dchelimsky committed Mar 9, 2010
View
6 features/configuration/spec_opts.feature
@@ -22,7 +22,7 @@ Feature: spec/spec.opts
describe "color_enabled" do
context "when set with Rspec.configure" do
it "is true" do
- Rspec::Core.configuration.color_enabled?.should be_true
+ Rspec.configuration.color_enabled?.should be_true
end
end
end
@@ -42,7 +42,7 @@ Feature: spec/spec.opts
describe "color_enabled" do
context "when set with Rspec.configure" do
it "is true" do
- Rspec::Core.configuration.color_enabled?.should be_true
+ Rspec.configuration.color_enabled?.should be_true
end
end
end
@@ -68,7 +68,7 @@ Feature: spec/spec.opts
describe "formatter" do
context "when set with Rspec.configure and in spec.opts" do
it "takes the value set in spec.opts" do
- Rspec::Core.configuration.formatter.should be_an(Rspec::Core::Formatters::DocumentationFormatter)
+ Rspec.configuration.formatter.should be_an(Rspec::Core::Formatters::DocumentationFormatter)
end
end
end
View
9 lib/rspec/core.rb
@@ -23,7 +23,8 @@ def self.install_directory
end
def self.configuration
- @configuration ||= Rspec::Core::Configuration.new
+ Rspec.deprecate('Rspec::Core.configuration', 'Rspec.configuration', '2.0.0')
+ Rspec.configuration
end
def self.configure
@@ -37,8 +38,12 @@ def self.world
end
+ def self.configuration
+ @configuration ||= Rspec::Core::Configuration.new
+ end
+
def self.configure
- yield Core.configuration if block_given?
+ yield configuration if block_given?
end
end
View
2 lib/rspec/core/example_group.rb
@@ -118,7 +118,7 @@ def self.create(*args, &example_group_block)
def self._build(klass, given_caller, args, &example_group_block)
args << {} unless args.last.is_a?(Hash)
args.last.update(:example_group_block => example_group_block, :caller => given_caller)
- args.unshift Rspec::Core.configuration unless args.first.is_a?(Rspec::Core::Configuration)
+ args.unshift Rspec.configuration unless args.first.is_a?(Rspec::Core::Configuration)
klass.set_it_up(*args)
klass.module_eval(&example_group_block) if example_group_block
klass
View
6 lib/rspec/core/formatters/base_formatter.rb
@@ -15,15 +15,15 @@ def initialize
end
def configuration
- Rspec::Core.configuration
+ Rspec.configuration
end
def output
- Rspec::Core.configuration.output
+ Rspec.configuration.output
end
def profile_examples?
- Rspec::Core.configuration.profile_examples
+ Rspec.configuration.profile_examples
end
def color_enabled?
View
2 lib/rspec/core/mocking/with_rr.rb
@@ -1,6 +1,6 @@
require 'rr'
-Rspec::Core.configuration.backtrace_clean_patterns.push(RR::Errors::BACKTRACE_IDENTIFIER)
+Rspec.configuration.backtrace_clean_patterns.push(RR::Errors::BACKTRACE_IDENTIFIER)
module Rspec
module Core
View
2 lib/rspec/core/runner.rb
@@ -14,7 +14,7 @@ def self.autorun
end
def configuration
- Rspec::Core.configuration
+ Rspec.configuration
end
def reporter
View
10 lib/rspec/core/world.rb
@@ -9,11 +9,11 @@ def initialize
end
def filter
- Rspec::Core.configuration.filter
+ Rspec.configuration.filter
end
def exclusion_filter
- Rspec::Core.configuration.exclusion_filter
+ Rspec.configuration.exclusion_filter
end
def shared_example_groups
@@ -26,13 +26,13 @@ def example_groups_to_run
if filter || exclusion_filter
@example_groups_to_run = filter_example_groups
- if @example_groups_to_run.size == 0 && Rspec::Core.configuration.run_all_when_everything_filtered?
- Rspec::Core.configuration.puts "No examples were matched by #{filter.inspect}, running all"
+ if @example_groups_to_run.size == 0 && Rspec.configuration.run_all_when_everything_filtered?
+ Rspec.configuration.puts "No examples were matched by #{filter.inspect}, running all"
# reset the behaviour list to all example groups, and add back all examples
@example_groups_to_run = @example_groups
@example_groups.each { |b| b.examples_to_run.replace(b.examples) }
else
- Rspec::Core.configuration.puts "Run filtered using #{filter.inspect}"
+ Rspec.configuration.puts "Run filtered using #{filter.inspect}"
end
else
@example_groups_to_run = @example_groups
View
2 spec/rspec/core/runner_spec.rb
@@ -5,7 +5,7 @@
describe 'reporter' do
it 'should return the configured formatter' do
- Rspec::Core::Runner.new.reporter.should == Rspec::Core.configuration.formatter
+ Rspec::Core::Runner.new.reporter.should == Rspec.configuration.formatter
end
end
View
12 spec/rspec/core_spec.rb
@@ -4,17 +4,21 @@
describe "#configuration" do
- it "should return an instance of Rspec::Core::Configuration" do
- Rspec::Core.configuration.should be_an_instance_of(Rspec::Core::Configuration)
+ it "returns an instance of Rspec::Core::Configuration" do
+ Rspec.configuration.should be_an_instance_of(Rspec::Core::Configuration)
end
-
+
+ it "returns the same object every time" do
+ Rspec.configuration.should equal(Rspec.configuration)
+ end
+
end
describe "#configure" do
it "should yield the current configuration" do
Rspec.configure do |config|
- config.should == Rspec::Core.configuration
+ config.should == Rspec::configuration
end
end
View
6 spec/spec_helper.rb
@@ -23,11 +23,11 @@ def fail_with(message)
end
def use_formatter(new_formatter)
- original_formatter = Rspec::Core.configuration.formatter
- Rspec::Core.configuration.instance_variable_set(:@formatter, new_formatter)
+ original_formatter = Rspec.configuration.formatter
+ Rspec.configuration.instance_variable_set(:@formatter, new_formatter)
yield
ensure
- Rspec::Core.configuration.instance_variable_set(:@formatter, original_formatter)
+ Rspec.configuration.instance_variable_set(:@formatter, original_formatter)
end
def in_editor?

3 comments on commit 72be374

@rsanheim

Requesting a new gem release to pick up this change so we can clean up the related deprecation warning =).

@dchelimsky
RSpec member

Hey Rob - just released beta.4. Enjoy!

@rsanheim

Thanks!

Please sign in to comment.