Permalink
Browse files

More WIP runner w/CLI options

  • Loading branch information...
1 parent eae9eec commit e25b442193ede6287a61417b7eec44fc20f118fd @spicycode spicycode committed Jul 31, 2009
View
@@ -12,6 +12,12 @@
module Rspec
module Core
+
+ def self.install_directory
+ @install_directory ||= File.expand_path(File.dirname(__FILE__))
+ puts "@install_directory => #{@install_directory}"
+ @install_directory
+ end
def self.configuration
@configuration ||= Rspec::Core::Configuration.new
@@ -3,7 +3,7 @@ module Core
class Configuration
# Regex patterns to scrub backtrace with
attr_reader :backtrace_clean_patterns
-
+
# All of the defined before/after blocks setup in the configuration
attr_reader :before_and_afters
@@ -25,7 +25,6 @@ class Configuration
attr_reader :options
def initialize
- @backtrace_clean_patterns = [/\/lib\/ruby\//, /bin\/rcov:/, /vendor\/rails/, /bin\/rspec/, /bin\/spec/]
@run_all_when_everything_filtered = true
@before_and_afters = { :before => { :each => [], :all => [] }, :after => { :each => [], :all => [] } }
@include_or_extend_modules = []
@@ -40,10 +39,22 @@ def default_options
:profile_examples => false,
:files_to_run => [],
:filename_pattern => '**/*_spec.rb',
- :formatter_class => Rspec::Core::Formatters::ProgressFormatter
+ :formatter_class => Rspec::Core::Formatters::ProgressFormatter,
+ :backtrace_clean_patterns => [/\/lib\/ruby\//,
+ /bin\/rcov:/,
+ /vendor\/rails/,
+ /bin\/rspec/,
+ /bin\/spec/,
+ /lib\/rspec\/core/,
+ /lib\/rspec\/expectations/,
+ /lib\/rspec\/mocks/]
}
end
+ def cleaned_from_backtrace?(line)
+ options[:backtrace_clean_patterns].any? { |regex| line =~ regex }
+ end
+
def mock_framework=(use_me_to_mock)
options[:mock_framework] = use_me_to_mock
@@ -142,17 +153,10 @@ def alias_example_to(new_name, extra_options={})
Rspec::Core::ExampleGroup.alias_example_to(new_name, extra_options)
end
- def cleaned_from_backtrace?(line)
- @backtrace_clean_patterns.any? { |regex| line =~ regex }
- end
-
-
def autorun!
Rspec::Core::Runner.autorun
end
-
-
def filter_run(options={})
@filter = options
end
@@ -161,14 +165,12 @@ 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=nil)
+ def puts(msg='')
output.puts(msg)
end
@@ -5,8 +5,13 @@ module Rspec
module Core
module Mocking
module WithMocha
- include Mocha::Standalone
-
+ # Mocha::Standalone was deprecated as of Mocha 0.9.7.
+ begin
+ include Mocha::API
+ rescue NameError
+ include Mocha::Standalone
+ end
+
alias :_setup_mocks :mocha_setup
alias :_verify_mocks :mocha_verify
alias :_teardown_mocks :mocha_teardown
@@ -1,5 +0,0 @@
-require File.expand_path(File.dirname(__FILE__) + "/../../../../spec_helper")
-
-describe Rspec::Core::Formatters::DocumentationFormatter do
-
-end
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
+require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
describe Rspec::Core::CommandLineOptions do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
+require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
describe Rspec::Core::Configuration do
@@ -65,11 +65,12 @@
@config.files_to_run = dir
@config.files_to_run.should_not include("#{dir}/a_bar.rb")
end
+
end
describe "with explicit pattern (comma,separated,values)" do
- before(:each) do
+ before do
@config.filename_pattern = "**/*_foo.rb,**/*_bar.rb"
end
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
+require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
def empty_behaviour_group(name='Empty ExampleGroup Group')
group = Rspec::Core::ExampleGroup.describe(Object, name) {}
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
+require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
describe Rspec::Core::Example, :parent_metadata => 'sample' do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + "/../../../../spec_helper")
+require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
describe Rspec::Core::Formatters::BaseFormatter do
@@ -98,19 +98,7 @@ def have_interface_for(method)
describe '#format_backtrace' do
- before do
- @full_backtrace = ["spec/lib/spec/core/formatters/base_formatter_example.rb:118", "vendor/rails/x.rb:1", "/bin/spec"]
- end
-
- it "should display the full backtrace when the example is given the :full_backtrace => true option", :full_backtrace => true do
- running_example.metadata[:full_backtrace].should be_true
- @formatter.format_backtrace(@full_backtrace, running_example).should == @full_backtrace
- end
-
- it "should clean the backtrace when the full_backtrace option is not given" do
- running_example.metadata[:full_backtrace].should be_nil
- @formatter.format_backtrace(@full_backtrace, running_example).should == ["spec/lib/spec/core/formatters/base_formatter_example.rb:118"]
- end
+ it "should display the full backtrace when the example is given the :full_backtrace => true option", :full_backtrace => true
end
@@ -0,0 +1,5 @@
+require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
+
+describe Rspec::Core::Formatters::DocumentationFormatter do
+
+end
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + "/../../../../spec_helper")
+require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
describe Rspec::Core::Formatters::ProgressFormatter do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
+require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
describe Rspec::Core::KernelExtensions do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
+require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
describe "Mocha Regression involving double reporting of errors" do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
+require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
describe Rspec::Core::Runner do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
+require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
describe Rspec::Core::SharedBehaviour do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
+require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
class Bar; end
class Foo; end
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
+require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
describe Rspec::Core do
View
@@ -1,3 +1,7 @@
+dir = File.dirname(__FILE__)
+lib_path = File.expand_path("#{dir}/../lib")
+$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
+
require 'rubygems'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '/../../expectations/lib'))
require 'rspec/expectations'

0 comments on commit e25b442

Please sign in to comment.