Skip to content

Commit

Permalink
change top-level module from Rspec to RSpec
Browse files Browse the repository at this point in the history
- capture const_missing on Rspec and return RSpec
  • Loading branch information
dchelimsky committed May 17, 2010
1 parent 25e1496 commit 2019053
Show file tree
Hide file tree
Showing 69 changed files with 244 additions and 242 deletions.
8 changes: 4 additions & 4 deletions README.markdown
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,9 @@
# Rspec Core # RSpec Core


Rspec is an automated testing framework for Ruby, designed for use in Behaviour RSpec is an automated testing framework for Ruby, designed for use in Behaviour
Driven Development and Test Driven Development. Driven Development and Test Driven Development.


rspec-core includes the Rspec runner, output formatters, and the `rspec` rspec-core includes the RSpec runner, output formatters, and the `rspec`
command. command.


## Upgrading from rspec-1.x ## Upgrading from rspec-1.x
Expand Down Expand Up @@ -46,7 +46,7 @@ Implement the simplest solution:
Be sure to require the implementation file in the spec: Be sure to require the implementation file in the spec:


# in spec/calculator_spec.rb # in spec/calculator_spec.rb
# - Rspec adds ./lib to the $LOAD_PATH, so you can # - RSpec adds ./lib to the $LOAD_PATH, so you can
# just require "calculator" directly # just require "calculator" directly
require "calculator" require "calculator"


Expand Down
18 changes: 9 additions & 9 deletions Rakefile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ begin
require 'jeweler' require 'jeweler'
Jeweler::Tasks.new do |gem| Jeweler::Tasks.new do |gem|
gem.name = "rspec-core" gem.name = "rspec-core"
gem.version = Rspec::Core::Version::STRING gem.version = RSpec::Core::Version::STRING
gem.summary = "rspec-core-#{Rspec::Core::Version::STRING}" gem.summary = "rspec-core-#{RSpec::Core::Version::STRING}"
gem.description = 'Rspec runner and example group classes' gem.description = 'RSpec runner and example group classes'
gem.email = "dchelimsky@gmail.com;chad.humphries@gmail.com" gem.email = "dchelimsky@gmail.com;chad.humphries@gmail.com"
gem.homepage = "http://github.com/rspec/core" gem.homepage = "http://github.com/rspec/core"
gem.authors = ["Chad Humphries", "David Chelimsky"] gem.authors = ["Chad Humphries", "David Chelimsky"]
gem.rubyforge_project = "rspec" gem.rubyforge_project = "rspec"
gem.add_development_dependency "rspec-expectations", ">= #{Rspec::Core::Version::STRING}" gem.add_development_dependency "rspec-expectations", ">= #{RSpec::Core::Version::STRING}"
gem.add_development_dependency "rspec-mocks", ">= #{Rspec::Core::Version::STRING}" gem.add_development_dependency "rspec-mocks", ">= #{RSpec::Core::Version::STRING}"
gem.add_development_dependency('cucumber', '>= 0.5.3') gem.add_development_dependency('cucumber', '>= 0.5.3')
gem.add_development_dependency('autotest', '>= 4.2.9') gem.add_development_dependency('autotest', '>= 4.2.9')
gem.post_install_message = <<-EOM gem.post_install_message = <<-EOM
Expand All @@ -43,14 +43,14 @@ end
namespace :gem do namespace :gem do
desc "push to gemcutter" desc "push to gemcutter"
task :push => :build do task :push => :build do
system "gem push pkg/rspec-core-#{Rspec::Core::Version::STRING}.gem" system "gem push pkg/rspec-core-#{RSpec::Core::Version::STRING}.gem"
end end
end end


Rspec::Core::RakeTask.new(:spec) RSpec::Core::RakeTask.new(:spec)


desc "Run all examples using rcov" desc "Run all examples using rcov"
Rspec::Core::RakeTask.new :rcov => :cleanup_rcov_files do |t| RSpec::Core::RakeTask.new :rcov => :cleanup_rcov_files do |t|
t.rcov = true t.rcov = true
t.rcov_opts = %[-Ilib -Ispec --exclude "mocks,expectations,gems/*,spec/resources,spec/lib,spec/spec_helper.rb,db/*,/Library/Ruby/*,config/*"] t.rcov_opts = %[-Ilib -Ispec --exclude "mocks,expectations,gems/*,spec/resources,spec/lib,spec/spec_helper.rb,db/*,/Library/Ruby/*,config/*"]
t.rcov_opts << %[--no-html --aggregate coverage.data] t.rcov_opts << %[--no-html --aggregate coverage.data]
Expand Down Expand Up @@ -85,7 +85,7 @@ end


Rake::RDocTask.new do |rdoc| Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'rdoc' rdoc.rdoc_dir = 'rdoc'
rdoc.title = "rspec-core #{Rspec::Core::Version::STRING}" rdoc.title = "rspec-core #{RSpec::Core::Version::STRING}"
rdoc.rdoc_files.include('README*') rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb') rdoc.rdoc_files.include('lib/**/*.rb')
end end
Expand Down
12 changes: 6 additions & 6 deletions Upgrade.markdown
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@


## What's changed ## What's changed


### Rspec namespace ### RSpec namespace


The root namespace is now `Rspec` instead of `Spec`, and the root directory The root namespace is now `RSpec` instead of `Spec`, and the root directory
under `lib` is `rspec` instead of `spec`. under `lib` is `rspec` instead of `spec`.


### Configuration ### Configuration


Typically in `spec/spec_helper.rb`, configuration is now done like this: Typically in `spec/spec_helper.rb`, configuration is now done like this:


Rspec.configure do |c| RSpec.configure do |c|
# .... # ....
end end


Expand All @@ -38,7 +38,7 @@ each example in a variety of ways.
The most obvious use is for filtering the run. For example: The most obvious use is for filtering the run. For example:


# in spec/spec_helper.rb # in spec/spec_helper.rb
Rspec.configure do |c| RSpec.configure do |c|
c.filter_run :focus => true c.filter_run :focus => true
end end


Expand All @@ -54,7 +54,7 @@ When you run the `rspec` command, rspec will run only the examples that have


You can also add `run_all_when_everything_filtered` to the config: You can also add `run_all_when_everything_filtered` to the config:


Rspec.configure do |c| RSpec.configure do |c|
c.filter_run :focus => true c.filter_run :focus => true
c.run_all_when_everything_filtered = true c.run_all_when_everything_filtered = true
end end
Expand All @@ -72,7 +72,7 @@ rspec-core, and here's how we're getting the right stuff to run under the
right version: right version:


# in spec/spec_helper.rb # in spec/spec_helper.rb
Rspec.configure do |c| RSpec.configure do |c|
c.exclusion_filter = { :ruby => lambda {|version| c.exclusion_filter = { :ruby => lambda {|version|
!(RUBY_VERSION.to_s =~ /^#{version.to_s}/) !(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
}} }}
Expand Down
2 changes: 1 addition & 1 deletion example_specs/spec_helper.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require 'rspec/expectations' require 'rspec/expectations'
require 'rspec/core' require 'rspec/core'


Rspec.configure do |c| RSpec.configure do |c|
c.mock_with :rspec c.mock_with :rspec
end end


2 changes: 1 addition & 1 deletion features/command_line/line_number_option.feature
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
Feature: line number option Feature: line number option


As an Rspec user As an RSpec user
I want to run one example identified by the line number I want to run one example identified by the line number


Scenario: standard examples Scenario: standard examples
Expand Down
24 changes: 12 additions & 12 deletions features/configuration/custom_options.feature
Original file line number Original file line Diff line number Diff line change
@@ -1,23 +1,23 @@
Feature: custom options Feature: custom options


In order to seamlessly provide my users more options In order to seamlessly provide my users more options
As an Rspec extenstion-library author As an RSpec extenstion-library author
I want to define new options on the Rspec.configuration I want to define new options on the RSpec.configuration


Scenario: boolean option with default settings Scenario: boolean option with default settings
Given a file named "boolean_option_spec.rb" with: Given a file named "boolean_option_spec.rb" with:
""" """
Rspec.configure do |c| RSpec.configure do |c|
c.add_option :custom_option, :type => :boolean c.add_option :custom_option, :type => :boolean
end end
describe "custom option" do describe "custom option" do
it "is false by default" do it "is false by default" do
Rspec.configuration.custom_option.should be_false RSpec.configuration.custom_option.should be_false
end end
it "is exposed as a predicate" do it "is exposed as a predicate" do
Rspec.configuration.custom_option?.should be_false RSpec.configuration.custom_option?.should be_false
end end
end end
""" """
Expand All @@ -27,17 +27,17 @@ Feature: custom options
Scenario: boolean option set to default to true Scenario: boolean option set to default to true
Given a file named "boolean_option_spec.rb" with: Given a file named "boolean_option_spec.rb" with:
""" """
Rspec.configure do |c| RSpec.configure do |c|
c.add_option :custom_option, :type => :boolean, :default => true c.add_option :custom_option, :type => :boolean, :default => true
end end
describe "custom option" do describe "custom option" do
it "is true by default" do it "is true by default" do
Rspec.configuration.custom_option.should be_true RSpec.configuration.custom_option.should be_true
end end
it "is exposed as a predicate" do it "is exposed as a predicate" do
Rspec.configuration.custom_option?.should be_true RSpec.configuration.custom_option?.should be_true
end end
end end
""" """
Expand All @@ -48,21 +48,21 @@ Feature: custom options
Scenario: boolean option overridden in client app Scenario: boolean option overridden in client app
Given a file named "boolean_option_spec.rb" with: Given a file named "boolean_option_spec.rb" with:
""" """
Rspec.configure do |c| RSpec.configure do |c|
c.add_option :custom_option, :type => :boolean c.add_option :custom_option, :type => :boolean
end end
Rspec.configure do |c| RSpec.configure do |c|
c.custom_option = true c.custom_option = true
end end
describe "custom option" do describe "custom option" do
it "returns the value set in the client app" do it "returns the value set in the client app" do
Rspec.configuration.custom_option.should be_true RSpec.configuration.custom_option.should be_true
end end
it "is exposed as a predicate" do it "is exposed as a predicate" do
Rspec.configuration.custom_option?.should be_true RSpec.configuration.custom_option?.should be_true
end end
end end
""" """
Expand Down
20 changes: 10 additions & 10 deletions features/configuration/options_file.feature
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ Feature: spec/spec.opts
automatically. automatically.


Options declared in spec/spec.opts will override configuration Options declared in spec/spec.opts will override configuration
set up in Rspec.configure blocks. set up in RSpec.configure blocks.


Scenario: color set in Rspec.configure Scenario: color set in RSpec.configure
Given a file named "spec/example_spec.rb" with: Given a file named "spec/example_spec.rb" with:
""" """
Rspec.configure {|c| c.color_enabled = true } RSpec.configure {|c| c.color_enabled = true }
describe "color_enabled" do describe "color_enabled" do
context "when set with Rspec.configure" do context "when set with RSpec.configure" do
it "is true" do it "is true" do
Rspec.configuration.color_enabled?.should be_true RSpec.configuration.color_enabled?.should be_true
end end
end end
end end
Expand All @@ -31,9 +31,9 @@ Feature: spec/spec.opts
And a file named "spec/example_spec.rb" with: And a file named "spec/example_spec.rb" with:
""" """
describe "color_enabled" do describe "color_enabled" do
context "when set with Rspec.configure" do context "when set with RSpec.configure" do
it "is true" do it "is true" do
Rspec.configuration.color_enabled?.should be_true RSpec.configuration.color_enabled?.should be_true
end end
end end
end end
Expand All @@ -49,16 +49,16 @@ Feature: spec/spec.opts
""" """
And a file named "spec/spec_helper.rb" with: And a file named "spec/spec_helper.rb" with:
""" """
Rspec.configure {|c| c.formatter = 'progress'} RSpec.configure {|c| c.formatter = 'progress'}
""" """
And a file named "spec/example_spec.rb" with: And a file named "spec/example_spec.rb" with:
""" """
require "spec_helper" require "spec_helper"
describe "formatter" do describe "formatter" do
context "when set with Rspec.configure and in spec.opts" do context "when set with RSpec.configure and in spec.opts" do
it "takes the value set in spec.opts" do it "takes the value set in spec.opts" do
Rspec.configuration.formatter.should be_an(Rspec::Core::Formatters::DocumentationFormatter) RSpec.configuration.formatter.should be_an(RSpec::Core::Formatters::DocumentationFormatter)
end end
end end
end end
Expand Down
6 changes: 3 additions & 3 deletions features/filtering/inclusion_filters.feature
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Feature: inclusion feature
Scenario: focus on one example Scenario: focus on one example
Given a file named "spec/sample_spec.rb" with: Given a file named "spec/sample_spec.rb" with:
""" """
Rspec.configure do |c| RSpec.configure do |c|
c.filter_run :focus => true c.filter_run :focus => true
end end
Expand All @@ -22,7 +22,7 @@ Feature: inclusion feature
Scenario: focus on one group Scenario: focus on one group
Given a file named "spec/sample_spec.rb" with: Given a file named "spec/sample_spec.rb" with:
""" """
Rspec.configure do |c| RSpec.configure do |c|
c.filter_run :focus => true c.filter_run :focus => true
end end
Expand All @@ -47,7 +47,7 @@ Feature: inclusion feature
Scenario: no examples match filter Scenario: no examples match filter
Given a file named "spec/sample_spec.rb" with: Given a file named "spec/sample_spec.rb" with:
""" """
Rspec.configure do |c| RSpec.configure do |c|
c.filter_run :focus => true c.filter_run :focus => true
c.run_all_when_everything_filtered = true c.run_all_when_everything_filtered = true
end end
Expand Down
2 changes: 1 addition & 1 deletion features/hooks/before_and_after_hooks.feature
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Feature: before and after hooks
""" """
require "rspec/expectations" require "rspec/expectations"
Rspec.configure do |config| RSpec.configure do |config|
config.before(:each) do config.before(:each) do
@before_each = "before each" @before_each = "before each"
end end
Expand Down
2 changes: 1 addition & 1 deletion features/hooks/halt.feature
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: halt
Given a directory named "spec" Given a directory named "spec"
And a file named "spec/example_spec.rb" with: And a file named "spec/example_spec.rb" with:
""" """
Rspec.configure do |c| RSpec.configure do |c|
c.after(:each) do c.after(:each) do
running_example.halt(:group, :status => 'failed') running_example.halt(:group, :status => 'failed')
end end
Expand Down
2 changes: 1 addition & 1 deletion features/mock_framework_integration/use_flexmock.feature
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature: mock with flexmock
Scenario: Mock with flexmock Scenario: Mock with flexmock
Given a file named "flexmock_example_spec.rb" with: Given a file named "flexmock_example_spec.rb" with:
""" """
Rspec.configure do |config| RSpec.configure do |config|
config.mock_framework = :flexmock config.mock_framework = :flexmock
end end
Expand Down
2 changes: 1 addition & 1 deletion features/mock_framework_integration/use_mocha.feature
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature: mock with mocha
Scenario: Mock with mocha Scenario: Mock with mocha
Given a file named "mocha_example_spec.rb" with: Given a file named "mocha_example_spec.rb" with:
""" """
Rspec.configure do |config| RSpec.configure do |config|
config.mock_framework = :mocha config.mock_framework = :mocha
end end
Expand Down
2 changes: 1 addition & 1 deletion features/mock_framework_integration/use_rr.feature
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature: mock with rr
Scenario: Mock with rr Scenario: Mock with rr
Given a file named "rr_example_spec.rb" with: Given a file named "rr_example_spec.rb" with:
""" """
Rspec.configure do |config| RSpec.configure do |config|
config.mock_framework = :rr config.mock_framework = :rr
end end
Expand Down
2 changes: 1 addition & 1 deletion features/mock_framework_integration/use_rspec.feature
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature: mock with rspec
Scenario: Mock with rspec Scenario: Mock with rspec
Given a file named "rspec_example_spec.rb" with: Given a file named "rspec_example_spec.rb" with:
""" """
Rspec.configure do |config| RSpec.configure do |config|
config.mock_framework = :rspec config.mock_framework = :rspec
end end
Expand Down
2 changes: 1 addition & 1 deletion features/pending/pending_examples.feature
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
Feature: pending examples Feature: pending examples


Rspec offers three ways to indicate that an example is disabled pending RSpec offers three ways to indicate that an example is disabled pending
some action. some action.


Scenario: pending implementation Scenario: pending implementation
Expand Down
2 changes: 1 addition & 1 deletion lib/autotest/rspec2.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
} }
end end


class RspecCommandError < StandardError; end class RSpecCommandError < StandardError; end


class Autotest::Rspec2 < Autotest class Autotest::Rspec2 < Autotest


Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/autorun.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,2 +1,2 @@
require 'rspec/core' require 'rspec/core'
Rspec::Core::Runner.autorun RSpec::Core::Runner.autorun
Loading

4 comments on commit 2019053

@rsanheim
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definitely looks nicer, but is it worth the additional magic needed to capture Rspec and return RSpec?

@dchelimsky
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it is, for a variety of reasons, not the least of which is The RSpec Book (not The Rspec Book).

The reason for capturing Rspec is because there are libs (Cucumber) out there depending on that name already. Also, some other players in the eco-system (rails generators, autotest) need the name to be Rspec and not RSpec, so I think it's best to support both so as not to confuse users who may see the Rspec name in those files.

That all make sense?

@jacquescrocker
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, great change. Thanks!

@rsanheim
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely understand the motivation =). I just get worried about adding complexity, no matter how slight, for something that is mostly cosmetic.

Please sign in to comment.