Permalink
Browse files

merge in changes from master

  • Loading branch information...
2 parents 9ca00ac + e99026f commit fe164f4207c428f5a4b704574ae3d415f6cd9633 @jimbreen jimbreen committed Apr 15, 2010
View
@@ -0,0 +1 @@
+-Ispec
View
@@ -63,6 +63,18 @@ Use the documentation formatter to see the resulting spec:
Finished in 0.000379 seconds
1 example, 0 failures
+## Configuration
+
+You can define runtime configuration options in four places. They
+are loaded and processed in this order:
+
+* ~/.rspec
+* .rspec
+* RSpec.configure
+* command line
+
+Run `rspec --help` to see supported configuration options.
+
#### Also see
* [http://github.com/rspec/rspec](http://github.com/rspec/rspec)
View
@@ -1 +1 @@
-2.0.0.beta.4
+2.0.0.beta.6
@@ -2,9 +2,9 @@ Feature: example name option
Use the --example (or -e) option to filter the examples to be run by name.
- The submitted argument is compiled to a Ruby Regexp, and matched against the
- full description of the example, which is the concatenation of descriptions
- of the group (including any nested groups) and the example.
+ The argument is compiled to a Ruby Regexp, and matched against the full
+ description of the example, which is the concatenation of descriptions of the
+ group (including any nested groups) and the example.
This allows you to run a single uniquely named example, all examples with
similar names, all the example in a uniquely named group, etc, etc.
@@ -7,33 +7,53 @@ Feature: line number appended to file path
Background:
Given a file named "example_spec.rb" with:
"""
- describe "a group" do
+ describe "outer group" do
- it "has a first example" do
+ it "first example in outer group" do
end
- it "has a second example" do
+ it "second example in outer group" do
end
+
+ describe "nested group" do
+
+ it "example in nested group" do
+
+ end
+ end
+
end
"""
- Scenario: two examples - both examples from the group declaration
+@wip
+ Scenario: nested groups - outer group on declaration line
When I run "rspec example_spec.rb:1 --format doc"
- Then I should see "2 examples, 0 failures"
- And I should see "has a second example"
- And I should see "has a first example"
+ Then I should see "3 examples, 0 failures"
+ And I should see "second example in outer group"
+ And I should see "first example in outer group"
+ And I should see "example in nested group"
+
+@wip
+ Scenario: nested groups - inner group on declaration line
+ When I run "rspec example_spec.rb:11 --format doc"
+ Then I should see "3 examples, 0 failures"
+ And I should see "example in nested group"
+ And I should not see "second example in outer group"
+ And I should not see "first example in outer group"
Scenario: two examples - first example on declaration line
When I run "rspec example_spec.rb:3 --format doc"
Then I should see "1 example, 0 failures"
- And I should see "has a first example"
- But the stdout should not contain "has a second example"
+ And I should see "first example in outer group"
+ But I should not see "second example in outer group"
+ And I should not see "example in nested group"
Scenario: two examples - second example on declaration line
When I run "rspec example_spec.rb:7 --format doc"
Then I should see "1 example, 0 failures"
- And I should see "has a second example"
- But the stdout should not contain "has a first example"
+ And I should see "second example in outer group"
+ But I should not see "first example in outer group"
+ And I should not see "example in nested group"
@@ -7,18 +7,11 @@ Feature: spec/spec.opts
Options declared in spec/spec.opts will override configuration
set up in Rspec.configure blocks.
- Background:
- Given a directory named "spec"
-
Scenario: color set in Rspec.configure
- Given a file named "spec/spec_helper.rb" with:
+ Given a file named "spec/example_spec.rb" with:
"""
- require "rspec/expectations"
Rspec.configure {|c| c.color_enabled = true }
- """
- And a file named "spec/example_spec.rb" with:
- """
- require "spec_helper"
+
describe "color_enabled" do
context "when set with Rspec.configure" do
it "is true" do
@@ -30,15 +23,13 @@ Feature: spec/spec.opts
When I run "rspec spec/example_spec.rb"
Then I should see "1 example, 0 failures"
- Scenario: color set in spec/spec.opts
- Given a file named "spec/spec.opts" with:
+ Scenario: color set in .rspec
+ Given a file named ".rspec" with:
"""
--color
"""
And a file named "spec/example_spec.rb" with:
"""
- require "rspec/expectations"
-
describe "color_enabled" do
context "when set with Rspec.configure" do
it "is true" do
@@ -49,16 +40,15 @@ Feature: spec/spec.opts
"""
When I run "rspec spec/example_spec.rb"
Then I should see "1 example, 0 failures"
-
- @wip
- Scenario: formatter set in both (spec.opts wins)
- Given a file named "spec/spec.opts" with:
+
+@wip
+ Scenario: formatter set in both (.rspec wins)
+ Given a file named ".rspec" with:
"""
- --formatter documentation
+ --format documentation
"""
And a file named "spec/spec_helper.rb" with:
"""
- require "rspec/expectations"
Rspec.configure {|c| c.formatter = 'progress'}
"""
And a file named "spec/example_spec.rb" with:
@@ -33,3 +33,36 @@ Feature: explicit subject
"""
When I run "rspec nested_subject_spec.rb"
Then I should see "1 example, 0 failures"
+
+@wip
+ Scenario: access subject from before block
+ Given a file named "top_level_subject_spec.rb" with:
+ """
+ describe Array, "with some elements" do
+ subject { [] }
+ before { subject += [1,2,3] }
+ it "should have the prescribed elements" do
+ subject.should == [1,2,3]
+ end
+ end
+ """
+ When I run "spec top_level_subject_spec.rb"
+ Then I should see "1 example, 0 failures"
+
+ Scenario: subject using helper method
+ Given a file named "helper_subject_spec.rb" with:
+ """
+ require 'rspec/expectations'
+
+ describe Array do
+ def prepared_array; [1,2,3] end
+ subject { prepared_array }
+ describe "with some elements" do
+ it "should have the prescribed elements" do
+ subject.should == [1,2,3]
+ end
+ end
+ end
+ """
+ When I run "rspec helper_subject_spec.rb"
+ Then I should see "1 example, 0 failures"
@@ -1,4 +1,4 @@
-$LOAD_PATH << File.expand_path("../../../../rspec-expectations/lib", __FILE__)
+$LOAD_PATH.unshift File.expand_path("../../../../rspec-expectations/lib", __FILE__)
require 'rspec/expectations'
require 'aruba'
@@ -38,7 +38,11 @@ def consolidate_failures(failed)
def make_test_cmd(files_to_test)
files_to_test.empty? ? '' :
- "#{ruby} #{SPEC_PROGRAM} #{normalize(files_to_test).keys.flatten.join(' ')}"
+ "#{ruby} #{require_rubygems}#{SPEC_PROGRAM} #{normalize(files_to_test).keys.flatten.join(' ')}"
+ end
+
+ def require_rubygems
+ defined?(:Gem) ? "-rrubygems " : ""
end
def normalize(files_to_test)
View
@@ -1,15 +1,19 @@
require 'rspec/core/load_path'
require 'rspec/core/deprecation'
-require 'rspec/core/mocking/with_absolutely_nothing'
+
+require 'rspec/core/hooks'
+require 'rspec/core/subject'
+require 'rspec/core/let'
+require 'rspec/core/metadata'
+
require 'rspec/core/around_proxy'
require 'rspec/core/world'
require 'rspec/core/configuration'
-require 'rspec/core/command_line_options'
+require 'rspec/core/configuration_options'
require 'rspec/core/runner'
require 'rspec/core/example'
require 'rspec/core/kernel_extensions'
require 'rspec/core/shared_example_group'
-require 'rspec/core/example_group_subject'
require 'rspec/core/example_group'
require 'rspec/core/formatters'
require 'rspec/core/backward_compatibility'
@@ -29,7 +33,7 @@ def self.configuration
def self.configure
Rspec.deprecate('Rspec::Core.configure', 'Rspec.configure', '2.0.0')
- yield configuration if block_given?
+ yield Rspec.configuration if block_given?
end
def self.world
@@ -1,93 +0,0 @@
-require 'optparse'
-# http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/classes/OptionParser.html
-
-module Rspec
- module Core
-
- class CommandLineOptions
- DEFAULT_OPTIONS_FILE = 'spec/spec.opts'
-
- attr_reader :args, :options
-
- def self.parse(args)
- new(args).parse
- end
-
- def initialize(args)
- @args = args
- @options = {}
- end
-
- def parse
- options[:files_or_directories_to_run] = OptionParser.new do |opts|
- opts.banner = "Usage: rspec [options] [files or directories]"
-
- opts.on('-c', '--[no-]color', '--[no-]colour', 'Enable color in the output') do |o|
- options[:color_enabled] = o
- end
-
- opts.on('-f', '--formatter [FORMATTER]', 'Choose a formatter',
- ' [p]rogress (default - dots)',
- ' [d]ocumentation (group and example names)') do |o|
- options[:formatter] = o
- end
-
- opts.on('-l', '--line_number [LINE]', 'Specify the line number of a single example to run') do |o|
- options[:line_number] = o
- end
-
- opts.on('-e', '--example [PATTERN]', "Run examples whose full descriptions match this pattern",
- "(PATTERN is compiled into a Ruby regular expression)") do |o|
- options[:full_description] = /#{o}/
- end
-
- opts.on('-o', '--options [PATH]', 'Read configuration options from a file path. (Defaults to spec/spec.opts)') do |o|
- options[:options_file] = o || DEFAULT_OPTIONS_FILE
- end
-
- opts.on('-p', '--profile', 'Enable profiling of examples with output of the top 10 slowest examples') do |o|
- options[:profile_examples] = o
- end
-
- opts.on('-b', '--backtrace', 'Enable full backtrace') do |o|
- options[:full_backtrace] = true
- end
-
- opts.on('-d', '--debug', 'Enable debugging') do |o|
- options[:debug] = true
- end
-
- opts.on_tail('-h', '--help', "You're looking at it.") do
- puts opts
- exit
- end
- end.parse!(@args)
-
- self
- end
-
- def apply(config)
- # 1) option file, cli options, rspec core configure
- # TODO: Add options_file to configuration
- # TODO: Store command line options for reference
- options_file = options.delete(:options_file) || DEFAULT_OPTIONS_FILE
- merged_options = parse_spec_file_contents(options_file).merge!(options)
- options.replace merged_options
-
- options.each do |key, value|
- config.send("#{key}=", value)
- end
- end
-
- private
-
- def parse_spec_file_contents(options_file)
- return {} unless File.exist?(options_file)
- spec_file_contents = File.readlines(options_file).map {|l| l.split}.flatten
- self.class.new(spec_file_contents).parse.options
- end
-
- end
-
- end
-end
@@ -92,6 +92,10 @@ def full_backtrace=(bool)
@options[:backtrace_clean_patterns].clear
end
+ def libs=(libs)
+ libs.map {|lib| $LOAD_PATH.unshift lib}
+ end
+
def debug=(bool)
return unless bool
begin
@@ -184,19 +188,14 @@ def run_all_when_everything_filtered?
@run_all_when_everything_filtered
end
- # Where does output go? For now $stdout
def output
$stdout
end
- def puts(msg='')
+ def puts(msg="")
output.puts(msg)
end
- def parse_command_line_args(args)
- @command_line_options = Rspec::Core::CommandLineOptions.parse(args)
- end
-
def include(mod, options={})
@include_or_extend_modules << [:include, mod, options]
end
@@ -230,6 +229,10 @@ def configure_mock_framework
Rspec::Core::ExampleGroup.send(:include, Rspec::Core::MockFrameworkAdapter)
end
+ def require_files_to_run
+ files_to_run.map {|f| require f }
+ end
+
end
end
end
Oops, something went wrong. Retry.

0 comments on commit fe164f4

Please sign in to comment.