diff options
Diffstat (limited to 'vendor/plugins/rspec/spec')
142 files changed, 4642 insertions, 9618 deletions
diff --git a/vendor/plugins/rspec/spec/autotest/discover_spec.rb b/vendor/plugins/rspec/spec/autotest/discover_spec.rb index da5cb1445..fc8d483af 100644 --- a/vendor/plugins/rspec/spec/autotest/discover_spec.rb +++ b/vendor/plugins/rspec/spec/autotest/discover_spec.rb @@ -1,19 +1,8 @@ -require File.dirname(__FILE__) + "/../autotest_helper" +require 'spec/autotest/autotest_helper' -module DiscoveryHelper - def load_discovery - require File.dirname(__FILE__) + "/../../lib/autotest/discover" +describe Autotest::Rspec, "discovery" do + it "adds the rspec autotest plugin" do + Autotest.should_receive(:add_discovery) + load File.expand_path(File.dirname(__FILE__) + "/../../lib/autotest/discover.rb") end -end - - -class Autotest - describe Rspec, "discovery" do - include DiscoveryHelper - - it "should add the rspec autotest plugin" do - Autotest.should_receive(:add_discovery).and_yield - load_discovery - end - end -end +end diff --git a/vendor/plugins/rspec/spec/autotest/rspec_spec.rb b/vendor/plugins/rspec/spec/autotest/rspec_spec.rb index 3abe3fdd5..6dea29dd9 100644 --- a/vendor/plugins/rspec/spec/autotest/rspec_spec.rb +++ b/vendor/plugins/rspec/spec/autotest/rspec_spec.rb @@ -1,111 +1,9 @@ -require File.dirname(__FILE__) + "/../autotest_helper" +require 'spec/autotest/autotest_helper' -class Autotest - - module AutotestHelper - def rspec_output - <<-HERE -.............PPF - -1) -'false should be false' FAILED -expected: true, - got: false (using ==) -./spec/autotest/rspec_spec.rb:203: - -Finished in 0.158674 seconds - -16 examples, 1 failure, 2 pending - -Pending: -Autotest::Rspec handling failed results should return an array of failed examples and errors (TODO) -Autotest::Rspec tests/specs for a given file should find all the specs for a given file (TODO) -HERE - end - - - def common_setup - @proc = mock Proc - @kernel = mock Kernel - @kernel.stub!(:proc).and_return @proc - - File.stub!(:exists).and_return true - @windows_alt_separator = "\\" - @posix_separator = '/' - - @rspec_output = rspec_output - end - end - - describe Rspec, "rspec_commands" do - it "should contain the various commands, ordered by preference" do - Rspec.new.spec_commands.should == [ - File.expand_path("#{File.dirname(__FILE__)}/../../bin/spec"), - "#{Config::CONFIG['bindir']}/spec" - ] - end - end - - describe Rspec, "selection of rspec command" do - include AutotestHelper - +describe Autotest::Rspec do + describe "adding spec.opts --options" do before(:each) do - common_setup - @rspec_autotest = Rspec.new - end - - it "should try to find the spec command if it exists in ./bin and use it above everything else" do - File.stub!(:exists?).and_return true - - spec_path = File.expand_path("#{File.dirname(__FILE__)}/../../bin/spec") - File.should_receive(:exists?).with(spec_path).and_return true - @rspec_autotest.spec_command.should == spec_path - end - - it "should otherwise select the default spec command in gem_dir/bin/spec" do - @rspec_autotest.stub!(:spec_commands).and_return ["/foo/spec"] - Config::CONFIG.stub!(:[]).and_return "/foo" - File.should_receive(:exists?).with("/foo/spec").and_return(true) - - @rspec_autotest.spec_command.should == "/foo/spec" - end - - it "should raise an error if no spec command is found at all" do - File.stub!(:exists?).and_return false - - lambda { - @rspec_autotest.spec_command - }.should raise_error(RspecCommandError, "No spec command could be found!") - end - - end - - describe Rspec, "selection of rspec command (windows compatibility issues)" do - include AutotestHelper - - before(:each) do - common_setup - end - - it "should use the ALT_SEPARATOR if it is non-nil" do - @rspec_autotest = Rspec.new - spec_command = File.expand_path("#{File.dirname(__FILE__)}/../../bin/spec") - @rspec_autotest.stub!(:spec_commands).and_return [spec_command] - @rspec_autotest.spec_command(@windows_alt_separator).should == spec_command.gsub('/', @windows_alt_separator) - end - - it "should not use the ALT_SEPATOR if it is nil" do - @windows_alt_separator = nil - @rspec_autotest = Rspec.new - spec_command = File.expand_path("#{File.dirname(__FILE__)}/../../bin/spec") - @rspec_autotest.stub!(:spec_commands).and_return [spec_command] - @rspec_autotest.spec_command.should == spec_command - end - end - - describe Rspec, "adding spec.opts --options" do - before(:each) do - @rspec_autotest = Rspec.new + @rspec_autotest = Autotest::Rspec.new end it "should return the command line option to add spec.opts if the options file exists" do @@ -115,18 +13,18 @@ HERE it "should return an empty string if no spec.opts exists" do File.stub!(:exist?).and_return false - Rspec.new.add_options_if_present.should == "" + Autotest::Rspec.new.add_options_if_present.should == "" end end - - describe Rspec do + + describe "commands" do before(:each) do - @rspec_autotest = Rspec.new + @rspec_autotest = Autotest::Rspec.new @rspec_autotest.stub!(:ruby).and_return "ruby" @rspec_autotest.stub!(:add_options_if_present).and_return "-O spec/spec.opts" - + @ruby = @rspec_autotest.ruby - @spec_command = @rspec_autotest.spec_command + @spec_cmd = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec')) @options = @rspec_autotest.add_options_if_present @files_to_test = { :spec => ["file_one", "file_two"] @@ -136,52 +34,57 @@ HERE @files_to_test.stub!(:keys).and_return @files_to_test[:spec] @to_test = @files_to_test.keys.flatten.join ' ' end - - it "should make the apropriate test command" do - @rspec_autotest.make_test_cmd(@files_to_test).should == "#{@ruby} -S #{@spec_command} #{@options} #{@to_test}" + + it "should make the appropriate test command" do + @rspec_autotest.make_test_cmd(@files_to_test).should == "#{@ruby} #{@spec_cmd} --autospec #{@to_test} #{@options}" + end + + it "should return a blank command for no files" do + @rspec_autotest.make_test_cmd({}).should == '' end end + + describe "mappings" do - describe Rspec, "mappings" do - before(:each) do @lib_file = "lib/something.rb" @spec_file = "spec/something_spec.rb" - @rspec_autotest = Rspec.new + @rspec_autotest = Autotest::Rspec.new @rspec_autotest.hook :initialize end - + it "should find the spec file for a given lib file" do @rspec_autotest.should map_specs([@spec_file]).to(@lib_file) end - + it "should find the spec file if given a spec file" do @rspec_autotest.should map_specs([@spec_file]).to(@spec_file) end - - it "should only find the file if the file is being tracked (in @file)" do + + it "should ignore files in spec dir that aren't specs" do + @rspec_autotest.should map_specs([]).to("spec/spec_helper.rb") + end + + it "should ignore untracked files (in @file)" do @rspec_autotest.should map_specs([]).to("lib/untracked_file") end end - - describe Rspec, "consolidating failures" do - include AutotestHelper - + + describe "consolidating failures" do before(:each) do - common_setup - @rspec_autotest = Rspec.new - - @spec_file = "spec/autotest/rspec_spec.rb" + @rspec_autotest = Autotest::Rspec.new + + @spec_file = "spec/autotest/some_spec.rb" @rspec_autotest.instance_variable_set("@files", {@spec_file => Time.now}) @rspec_autotest.stub!(:find_files_to_test).and_return true end - + it "should return no failures if no failures were given in the output" do @rspec_autotest.consolidate_failures([[]]).should == {} end - + it "should return a hash with the spec filename => spec name for each failure or error" do - @rspec_autotest.stub!(:test_files_for).and_return "spec/autotest/rspec_spec.rb" + @rspec_autotest.stub!(:test_files_for).and_return "spec/autotest/some_spec.rb" failures = [ [ "false should be false", @@ -192,6 +95,17 @@ HERE @spec_file => ["false should be false"] } end - + + it "should not include the subject file" do + subject_file = "lib/autotest/some.rb" + @rspec_autotest.stub!(:test_files_for).and_return "spec/autotest/some_spec.rb" + failures = [ + [ + "false should be false", + "expected: true,\n got: false (using ==)\n#{subject_file}:143:\n#{@spec_file}:203:" + ] + ] + @rspec_autotest.consolidate_failures(failures).keys.should_not include(subject_file) + end end end diff --git a/vendor/plugins/rspec/spec/autotest_helper.rb b/vendor/plugins/rspec/spec/autotest_helper.rb deleted file mode 100644 index 1b6c6002b..000000000 --- a/vendor/plugins/rspec/spec/autotest_helper.rb +++ /dev/null @@ -1,6 +0,0 @@ -require "rubygems" -require 'autotest' -dir = File.dirname(__FILE__) -require "#{dir}/spec_helper" -require File.expand_path("#{dir}/../lib/autotest/rspec") -require "#{dir}/autotest_matchers" diff --git a/vendor/plugins/rspec/spec/autotest_matchers.rb b/vendor/plugins/rspec/spec/autotest_matchers.rb deleted file mode 100644 index 5e23452e2..000000000 --- a/vendor/plugins/rspec/spec/autotest_matchers.rb +++ /dev/null @@ -1,47 +0,0 @@ -module Spec - module Matchers - class AutotestMappingMatcher - def initialize(specs) - @specs = specs - end - - def to(file) - @file = file - self - end - - def matches?(autotest) - @autotest = prepare autotest - @actual = autotest.test_files_for(@file) - @actual == @specs - end - - def failure_message - "expected #{@autotest.class} to map #{@specs.inspect} to #{@file.inspect}\ngot #{@actual.inspect}" - end - - private - def prepare autotest - stub_found_files autotest - stub_find_order autotest - autotest - end - - def stub_found_files autotest - found_files = @specs.inject({}){|h,f| h[f] = Time.at(0)} - autotest.stub!(:find_files).and_return(found_files) - end - - def stub_find_order autotest - find_order = @specs.dup << @file - autotest.instance_eval { @find_order = find_order } - end - - end - - def map_specs(specs) - AutotestMappingMatcher.new(specs) - end - - end -end
\ No newline at end of file diff --git a/vendor/plugins/rspec/spec/rspec_suite.rb b/vendor/plugins/rspec/spec/rspec_suite.rb deleted file mode 100644 index abd016a6d..000000000 --- a/vendor/plugins/rspec/spec/rspec_suite.rb +++ /dev/null @@ -1,7 +0,0 @@ -if __FILE__ == $0 - dir = File.dirname(__FILE__) - Dir["#{dir}/**/*_spec.rb"].reverse.each do |file| -# puts "require '#{file}'" - require file - end -end diff --git a/vendor/plugins/rspec/spec/spec/example/configuration_spec.rb b/vendor/plugins/rspec/spec/spec/example/configuration_spec.rb deleted file mode 100644 index 5b4a6049e..000000000 --- a/vendor/plugins/rspec/spec/spec/example/configuration_spec.rb +++ /dev/null @@ -1,282 +0,0 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' - -module Spec - module Example - - describe Configuration do - before(:each) do - @config = Configuration.new - @example_group = mock("example_group") - end - - describe "#mock_with" do - - it "should default mock framework to rspec" do - @config.mock_framework.should =~ /\/plugins\/mock_frameworks\/rspec$/ - end - - it "should let you set rspec mocking explicitly" do - @config.mock_with(:rspec) - @config.mock_framework.should =~ /\/plugins\/mock_frameworks\/rspec$/ - end - - it "should let you set mocha" do - @config.mock_with(:mocha) - @config.mock_framework.should =~ /\/plugins\/mock_frameworks\/mocha$/ - end - - it "should let you set flexmock" do - @config.mock_with(:flexmock) - @config.mock_framework.should =~ /\/plugins\/mock_frameworks\/flexmock$/ - end - - it "should let you set rr" do - @config.mock_with(:rr) - @config.mock_framework.should =~ /\/plugins\/mock_frameworks\/rr$/ - end - - it "should let you set an arbitrary adapter module" do - adapter = Module.new - @config.mock_with(adapter) - @config.mock_framework.should == adapter - end - end - - describe "#include" do - - before do - @original_configuration = Spec::Runner.configuration - spec_configuration = @config - Spec::Runner.instance_eval {@configuration = spec_configuration} - @example_group_class = Class.new(ExampleGroup) do - class << self - def this_class_has_special_methods - end - end - end - ExampleGroupFactory.register(:foobar, @example_group_class) - end - - after do - original_configuration = @original_configuration - Spec::Runner.instance_eval {@configuration = original_configuration} - ExampleGroupFactory.reset - end - - it "should include the submitted module in ExampleGroup subclasses" do - mod = Module.new - @config.include mod - Class.new(@example_group_class).included_modules.should include(mod) - end - - it "should let you define modules to be included for a specific type" do - mod = Module.new - @config.include mod, :type => :foobar - Class.new(@example_group_class).included_modules.should include(mod) - end - - it "should not include modules in a type they are not intended for" do - mod = Module.new - @other_example_group_class = Class.new(ExampleGroup) - ExampleGroupFactory.register(:baz, @other_example_group_class) - - @config.include mod, :type => :foobar - - Class.new(@other_example_group_class).included_modules.should_not include(mod) - end - - end - - end - - describe Configuration do - - before(:each) do - @config = Configuration.new - @special_example_group = Class.new(ExampleGroup) - @special_child_example_group = Class.new(@special_example_group) - @nonspecial_example_group = Class.new(ExampleGroup) - ExampleGroupFactory.register(:special, @special_example_group) - ExampleGroupFactory.register(:special_child, @special_child_example_group) - ExampleGroupFactory.register(:non_special, @nonspecial_example_group) - @example_group = @special_child_example_group.describe "Special Example Group" - @unselected_example_group = Class.new(@nonspecial_example_group).describe "Non Special Example Group" - end - - after(:each) do - ExampleGroupFactory.reset - end - - describe "#prepend_before" do - it "prepends the before block on all instances of the passed in type" do - order = [] - @config.prepend_before(:all) do - order << :prepend__before_all - end - @config.prepend_before(:all, :type => :special) do - order << :special_prepend__before_all - end - @config.prepend_before(:all, :type => :special_child) do - order << :special_child_prepend__before_all - end - @config.prepend_before(:each) do - order << :prepend__before_each - end - @config.prepend_before(:each, :type => :special) do - order << :special_prepend__before_each - end - @config.prepend_before(:each, :type => :special_child) do - order << :special_child_prepend__before_each - end - @config.prepend_before(:all, :type => :non_special) do - order << :special_prepend__before_all - end - @config.prepend_before(:each, :type => :non_special) do - order << :special_prepend__before_each - end - @example_group.it "calls prepend_before" do - end - - @example_group.run - order.should == [ - :prepend__before_all, - :special_prepend__before_all, - :special_child_prepend__before_all, - :prepend__before_each, - :special_prepend__before_each, - :special_child_prepend__before_each - ] - end - end - - describe "#append_before" do - - it "calls append_before on the type" do - order = [] - @config.append_before(:all) do - order << :append_before_all - end - @config.append_before(:all, :type => :special) do - order << :special_append_before_all - end - @config.append_before(:all, :type => :special_child) do - order << :special_child_append_before_all - end - @config.append_before(:each) do - order << :append_before_each - end - @config.append_before(:each, :type => :special) do - order << :special_append_before_each - end - @config.append_before(:each, :type => :special_child) do - order << :special_child_append_before_each - end - @config.append_before(:all, :type => :non_special) do - order << :special_append_before_all - end - @config.append_before(:each, :type => :non_special) do - order << :special_append_before_each - end - @example_group.it "calls append_before" do - end - - @example_group.run - order.should == [ - :append_before_all, - :special_append_before_all, - :special_child_append_before_all, - :append_before_each, - :special_append_before_each, - :special_child_append_before_each - ] - end - end - - describe "#prepend_after" do - - it "prepends the after block on all instances of the passed in type" do - order = [] - @config.prepend_after(:all) do - order << :prepend__after_all - end - @config.prepend_after(:all, :type => :special) do - order << :special_prepend__after_all - end - @config.prepend_after(:all, :type => :special) do - order << :special_child_prepend__after_all - end - @config.prepend_after(:each) do - order << :prepend__after_each - end - @config.prepend_after(:each, :type => :special) do - order << :special_prepend__after_each - end - @config.prepend_after(:each, :type => :special) do - order << :special_child_prepend__after_each - end - @config.prepend_after(:all, :type => :non_special) do - order << :special_prepend__after_all - end - @config.prepend_after(:each, :type => :non_special) do - order << :special_prepend__after_each - end - @example_group.it "calls prepend_after" do - end - - @example_group.run - order.should == [ - :special_child_prepend__after_each, - :special_prepend__after_each, - :prepend__after_each, - :special_child_prepend__after_all, - :special_prepend__after_all, - :prepend__after_all - ] - end - end - - describe "#append_after" do - - it "calls append_after on the type" do - order = [] - @config.append_after(:all) do - order << :append__after_all - end - @config.append_after(:all, :type => :special) do - order << :special_append__after_all - end - @config.append_after(:all, :type => :special_child) do - order << :special_child_append__after_all - end - @config.append_after(:each) do - order << :append__after_each - end - @config.append_after(:each, :type => :special) do - order << :special_append__after_each - end - @config.append_after(:each, :type => :special_child) do - order << :special_child_append__after_each - end - @config.append_after(:all, :type => :non_special) do - order << :non_special_append_after_all - end - @config.append_after(:each, :type => :non_special) do - order << :non_special_append_after_each - end - @example_group.it "calls append_after" do - end - - @example_group.run - order.should == [ - :special_child_append__after_each, - :special_append__after_each, - :append__after_each, - :special_child_append__after_all, - :special_append__after_all, - :append__after_all - ] - end - end - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/example/example_group/described_module_spec.rb b/vendor/plugins/rspec/spec/spec/example/example_group/described_module_spec.rb deleted file mode 100644 index 55b02f53f..000000000 --- a/vendor/plugins/rspec/spec/spec/example/example_group/described_module_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require File.dirname(__FILE__) + "/../../../spec_helper" - -module Spec - module Example - module AModule; end - class AClass; end - - describe "With", AModule do - it "should have the described_type as 'AModule'" do - self.class.described_module.should == AModule - end - end - - describe "With", AClass do - it "should have the described_module as nil" do - self.class.described_module.should be_nil - end - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/example/example_group/warning_messages_spec.rb b/vendor/plugins/rspec/spec/spec/example/example_group/warning_messages_spec.rb deleted file mode 100644 index 79ac3722a..000000000 --- a/vendor/plugins/rspec/spec/spec/example/example_group/warning_messages_spec.rb +++ /dev/null @@ -1,76 +0,0 @@ -require File.dirname(__FILE__) + "/../../../spec_helper" - -module Spec - module Example - module AModuleAutomaticallyIncluded - def call_method - @method_called = true - return "a string" - end - - def method_called? - @method_called ? true : false - end - end - - describe "Including modules in an example group" do - describe AModuleAutomaticallyIncluded do - before :each do - Kernel.stub!(:warn) - end - - it "should return the correct values" do - self.method_called?.should be_false - self.call_method.should eql("a string") - self.method_called?.should be_true - end - - it "should respond_to? the methods from the module" do - self.should respond_to(:method_called?) - self.should respond_to(:call_method) - end - - it "should not respond_to? methods which do not come from the module (or are in Spec::ExampleGroup)" do - self.should_not respond_to(:adsfadfadadf_a_method_which_does_not_exist) - end - - it "should respond_to? a method in Spec::ExampleGroup" do - self.should respond_to(:describe) - end - - it "should issue a warning with Kernel.warn" do - Kernel.should_receive(:warn) - self.call_method - end - - it "should issue a warning when the example calls the method which is automatically included" do - Kernel.should_receive(:warn).with("Modules will no longer be automatically included in RSpec version 1.1.4. Called from #{__FILE__}:#{__LINE__+1}") - self.method_called? - end - - it "should issue a warning with the correct file and line numbers" do - Kernel.should_receive(:warn).with("Modules will no longer be automatically included in RSpec version 1.1.4. Called from #{__FILE__}:#{__LINE__+1}") - self.method_called? - end - end - - describe AModuleAutomaticallyIncluded, "which is also manually included" do - include AModuleAutomaticallyIncluded - - before :each do - Kernel.stub!(:warn) - end - - it "should respond to the methods since it is included" do - self.should respond_to(:method_called?) - self.should respond_to(:call_method) - end - - it "should not issue a warning, since the module is manually included" do - Kernel.should_not_receive(:warn) - self.method_called? - end - end - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/example/example_group_class_definition_spec.rb b/vendor/plugins/rspec/spec/spec/example/example_group_class_definition_spec.rb index 0b00e1397..96bd21110 100644 --- a/vendor/plugins/rspec/spec/spec/example/example_group_class_definition_spec.rb +++ b/vendor/plugins/rspec/spec/spec/example/example_group_class_definition_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper' +require 'spec_helper' module Spec module Example @@ -7,36 +7,39 @@ module Spec attr_accessor :examples_ran end - @@klass_variable_set = true - CONSTANT = :foobar + @@class_variable = :class_variable + CONSTANT = :constant - before do - @instance_variable = :hello + before(:each) do + @instance_variable = :instance_variable end - - it "should run" do + + after(:all) do self.class.examples_ran = true end - it "should have access to instance variables" do - @instance_variable.should == :hello + def a_method + 22 end - it "should have access to class variables" do - @@klass_variable_set.should == true + it "can access instance variables defined before(:each)" do + @instance_variable.should == :instance_variable end - it "should have access to constants" do - CONSTANT.should == :foobar + it "can access class variables (Ruby 1.8 only)" do + with_ruby 1.8 do + @@class_variable.should == :class_variable + end end - it "should have access to methods defined in the Example Group" do - a_method.should == 22 + it "can access constants" do + CONSTANT.should == :constant end - def a_method - 22 + it "can access methods defined in the Example Group" do + a_method.should == 22 end + end describe ExampleGroupSubclass do diff --git a/vendor/plugins/rspec/spec/spec/example/example_group_factory_spec.rb b/vendor/plugins/rspec/spec/spec/example/example_group_factory_spec.rb index da461cdfc..0819d3a3e 100644 --- a/vendor/plugins/rspec/spec/spec/example/example_group_factory_spec.rb +++ b/vendor/plugins/rspec/spec/spec/example/example_group_factory_spec.rb @@ -1,46 +1,42 @@ -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +require 'spec_helper' module Spec module Example describe ExampleGroupFactory do describe "#get" do attr_reader :example_group - before do - @example_group = Class.new(ExampleGroup) - ExampleGroupFactory.register(:registered_type, @example_group) + before(:each) do + @example_group_class = Class.new(ExampleGroupDouble) + ExampleGroupFactory.register(:registered_type, @example_group_class) end - after do + after(:each) do ExampleGroupFactory.reset end - it "should #get the default ExampleGroup type when passed nil" do - ExampleGroupFactory.get(nil).should == ExampleGroup - end - - it "should #get the default ExampleGroup for unregistered non-nil values" do - ExampleGroupFactory.get(:does_not_exist).should == ExampleGroup + it "should return the default ExampleGroup type for nil" do + ExampleGroupFactory[nil].should == ExampleGroup end - it "should #get custom type for :registered_type" do - ExampleGroupFactory.get(:registered_type).should == @example_group + it "should return the default ExampleGroup for an unregistered non-nil value" do + ExampleGroupFactory[:does_not_exist].should == ExampleGroup end - it "should #get the actual type when that is passed in" do - ExampleGroupFactory.get(@example_group).should == @example_group + it "should return custom type if registered" do + ExampleGroupFactory[:registered_type].should == @example_group_class end it "should get the custom type after setting the default" do - @example_group2 = Class.new(ExampleGroup) - ExampleGroupFactory.default(@example_group2) - ExampleGroupFactory.get(:registered_type).should == @example_group + @alternate_example_group_class = Class.new(ExampleGroupDouble) + ExampleGroupFactory.default(@alternate_example_group_class) + ExampleGroupFactory[:registered_type].should == @example_group_class end end describe "#create_example_group" do attr_reader :parent_example_group before do - @parent_example_group = Class.new(ExampleGroup) do + @parent_example_group = Class.new(ExampleGroupDouble) do def initialize(*args, &block) ; end @@ -57,15 +53,28 @@ module Spec example_group.superclass.should == Spec::Example::ExampleGroup end - describe "when :type => :default" do - it "should create a Spec::Example::Example" do - example_group = Spec::Example::ExampleGroupFactory.create_example_group( - "example_group", :type => :default - ) {} - example_group.superclass.should == Spec::Example::ExampleGroup - end + it "should raise when no description is given" do + lambda { + Spec::Example::ExampleGroupFactory.create_example_group do; end + }.should raise_error(ArgumentError) + end + + it "should raise when no block is given" do + lambda { Spec::Example::ExampleGroupFactory.create_example_group "foo" }.should raise_error(ArgumentError) + end - it "should create a Spec::Example::Example" do + it "should run registered ExampleGroups" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group "The ExampleGroup" do end + Spec::Runner.options.example_groups.should include(example_group) + end + + it "should not run unregistered ExampleGroups" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group "The ExampleGroup" do Spec::Runner.options.remove_example_group self; end + Spec::Runner.options.example_groups.should_not include(example_group) + end + + describe "with :type => :default" do + it "should create a Spec::Example::ExampleGroup" do example_group = Spec::Example::ExampleGroupFactory.create_example_group( "example_group", :type => :default ) {} @@ -73,8 +82,8 @@ module Spec end end - describe "when :type => :something_other_than_default" do - it "should create specified type" do + describe "with :type => :something_other_than_default" do + it "should create the specified type" do Spec::Example::ExampleGroupFactory.register(:something_other_than_default, parent_example_group) non_default_example_group = Spec::Example::ExampleGroupFactory.create_example_group( "example_group", :type => :something_other_than_default @@ -83,41 +92,59 @@ module Spec end end - it "should create a type indicated by :spec_path" do + it "should create a type indicated by :location" do Spec::Example::ExampleGroupFactory.register(:something_other_than_default, parent_example_group) custom_example_group = Spec::Example::ExampleGroupFactory.create_example_group( - "example_group", :spec_path => "./spec/something_other_than_default/some_spec.rb" + "example_group", :location => "./spec/something_other_than_default/some_spec.rb" ) {} custom_example_group.superclass.should == parent_example_group end - it "should create a type indicated by :spec_path (with spec_path generated by caller on windows)" do + it "should create a type indicated by :location (with location generated by caller on windows)" do Spec::Example::ExampleGroupFactory.register(:something_other_than_default, parent_example_group) custom_example_group = Spec::Example::ExampleGroupFactory.create_example_group( "example_group", - :spec_path => "./spec\\something_other_than_default\\some_spec.rb" + :location => "./spec\\something_other_than_default\\some_spec.rb" ) {} custom_example_group.superclass.should == parent_example_group end - describe "when :shared => true" do - attr_reader :shared_example_group - before do - @shared_example_group = Spec::Example::ExampleGroupFactory.create_example_group( - "name", :spec_path => '/blah/spec/models/blah.rb', :type => :controller, :shared => true + it "should create a type indicated by location for a path-like key" do + Spec::Example::ExampleGroupFactory.register('path/to/custom/', parent_example_group) + custom_example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "example_group", :location => "./spec/path/to/custom/some_spec.rb" + ) {} + custom_example_group.superclass.should == parent_example_group + end + + it "should use the longest key that matches when creating a type indicated by location" do + longer = Class.new parent_example_group + Spec::Example::ExampleGroupFactory.register(:longer, longer) + long = Class.new parent_example_group + Spec::Example::ExampleGroupFactory.register(:long, long) + custom_example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "example_group", :location => "./spec/longer/some_spec.rb" + ) {} + custom_example_group.superclass.should == longer + end + + describe "with :shared => true" do + def shared_example_group + @shared_example_group ||= Spec::Example::ExampleGroupFactory.create_example_group( + "name", :location => '/blah/spec/models/blah.rb', :type => :controller, :shared => true ) {} end - it "should create and register a Spec::Example::Example" do + it "should create and register a Spec::Example::SharedExampleGroup" do shared_example_group.should be_an_instance_of(Spec::Example::SharedExampleGroup) - SharedExampleGroup.shared_example_groups.should include(shared_example_group) + SharedExampleGroup.should include(shared_example_group) end end - it "should favor the :type over the :spec_path" do + it "should favor the :type over the :location" do Spec::Example::ExampleGroupFactory.register(:something_other_than_default, parent_example_group) custom_example_group = Spec::Example::ExampleGroupFactory.create_example_group( - "name", :spec_path => '/blah/spec/models/blah.rb', :type => :something_other_than_default + "name", :location => '/blah/spec/models/blah.rb', :type => :something_other_than_default ) {} custom_example_group.superclass.should == parent_example_group end @@ -125,20 +152,29 @@ module Spec it "should register ExampleGroup by default" do example_group = Spec::Example::ExampleGroupFactory.create_example_group("The ExampleGroup") do end - rspec_options.example_groups.should include(example_group) + Spec::Runner.options.example_groups.should include(example_group) end it "should enable unregistering of ExampleGroups" do example_group = Spec::Example::ExampleGroupFactory.create_example_group("The ExampleGroup") do - unregister + Spec::Runner.options.remove_example_group self end - rspec_options.example_groups.should_not include(example_group) + Spec::Runner.options.example_groups.should_not include(example_group) end after(:each) do Spec::Example::ExampleGroupFactory.reset end end + + describe "#create_shared_example_group" do + it "registers a new shared example group" do + shared_example_group = Spec::Example::ExampleGroupFactory.create_shared_example_group("something shared") {} + shared_example_group.should be_an_instance_of(Spec::Example::SharedExampleGroup) + SharedExampleGroup.should include(shared_example_group) + end + end + end end end diff --git a/vendor/plugins/rspec/spec/spec/example/example_group_methods_spec.rb b/vendor/plugins/rspec/spec/spec/example/example_group_methods_spec.rb index 55c746ece..c9f10b8c1 100644 --- a/vendor/plugins/rspec/spec/spec/example/example_group_methods_spec.rb +++ b/vendor/plugins/rspec/spec/spec/example/example_group_methods_spec.rb @@ -1,523 +1,758 @@ -require File.dirname(__FILE__) + '/../../spec_helper' +require 'spec_helper' module Spec module Example describe 'ExampleGroupMethods' do - it_should_behave_like "sandboxed rspec_options" - attr_reader :example_group, :result, :reporter - before(:each) do - options.formatters << mock("formatter", :null_object => true) - options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true) - @reporter = FakeReporter.new(@options) - options.reporter = reporter - @example_group = Class.new(ExampleGroup) do - describe("ExampleGroup") - it "does nothing" + with_sandboxed_options do + attr_reader :example_group, :result, :reporter + before(:each) do + # See http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/525-arity-changed-on-partial-mocks#ticket-525-2 + method_with_three_args = lambda { |arg1, arg2, arg3| } + options.formatters << mock("formatter", :null_object => true, :example_pending => method_with_three_args) + options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true) + @reporter = FakeReporter.new(@options) + options.reporter = reporter + @example_group = Class.new(ExampleGroupDouble) do + describe("ExampleGroup") + it "does nothing" + end end - class << example_group - public :include + + after(:each) do + ExampleGroupDouble.reset end - @result = nil - end - after(:each) do - ExampleGroup.reset - end - - ["describe","context"].each do |method| - describe "#{method}" do - describe "when creating an ExampleGroup" do - attr_reader :child_example_group - before do - @child_example_group = @example_group.send method, "Another ExampleGroup" do - it "should pass" do - true.should be_true + ["describe","context"].each do |method| + describe "##{method}" do + describe "when creating an ExampleGroup" do + before(:each) do + @parent_example_group = Class.new(ExampleGroupDouble) do + example "first example" do; end + end + @child_example_group = @parent_example_group.__send__ method, "Child" do + example "second example" do; end end end - end - it "should create a subclass of the ExampleGroup when passed a block" do - child_example_group.superclass.should == @example_group - @options.example_groups.should include(child_example_group) + it "should create a subclass of the ExampleGroup when passed a block" do + @child_example_group.superclass.should == @parent_example_group + options.example_groups.should include(@child_example_group) + end + + it "should not inherit examples" do + @child_example_group.should have(1).examples + end + + it "records the spec path" do + @child_example_group.location.should =~ /#{__FILE__}:#{__LINE__ - 15}/ + end + end + + describe "when creating an example group with no description" do + it "raises an ArgumentError" do + lambda do + Class.new(ExampleGroupDouble).describe + end.should raise_error(Spec::Example::NoDescriptionError, /No description supplied for example group declared on #{__FILE__}:#{__LINE__ - 1}/) + end end - it "should not inherit examples" do - child_example_group.examples.length.should == 1 + describe "when creating a SharedExampleGroup" do + before(:each) do + @shared_example_group = @example_group.__send__ method, "A Shared ExampleGroup", :shared => true do; end + end + + after(:each) do + SharedExampleGroup.instance_eval{@shared_example_groups}.delete @shared_example_group + end + + it "should create a SharedExampleGroup" do + @shared_example_group.should_not be_nil + SharedExampleGroup.find("A Shared ExampleGroup").should == @shared_example_group + end end + end + end + + [:example, :specify, :it].each do |method| + describe "##{method.to_s}" do + it "should add an example" do + lambda { + @example_group.__send__(method, "") + }.should change { @example_group.examples.length }.by(1) + end + + describe "with no location supplied" do + describe "creates an ExampleProxy" do + before(:all) do + @example_group = Class.new(ExampleGroupDouble).describe("bar") + @example_proxy = @example_group.__send__(method, "foo", {:this => :that}) {} + @location = "#{__FILE__}:#{__LINE__ - 1}" + end - describe "when creating a SharedExampleGroup" do - attr_reader :name, :shared_example_group - before do - @name = "A Shared ExampleGroup" - @shared_example_group = @example_group.send method, name, :shared => true do - it "should pass" do - true.should be_true + specify "with a description" do + @example_proxy.description.should == "foo" + end + + specify "with options" do + @example_proxy.options.should == {:this => :that} end - end - end - after do - SharedExampleGroup.shared_example_groups.delete_if do |registered_shared_example_group| - registered_shared_example_group == shared_example_group + specify "with a default backtrace (DEPRECATED)" do + Spec.stub!(:deprecate) + @example_proxy.backtrace.should =~ /#{@location}/ + end + + specify "with a default location" do + @example_proxy.location.should =~ /#{@location}/ + end end end + + describe "with a location supplied" do + describe "creates an ExampleProxy" do + before(:all) do + @example_group = Class.new(ExampleGroupDouble).describe("bar") + @example_proxy = @example_group.__send__(method, "foo", {:this => :that}, "the location") {} + end - it "should create a SharedExampleGroup" do - SharedExampleGroup.find_shared_example_group(name).should == shared_example_group + specify "with the supplied location as #backtrace (DEPRECATED)" do + Spec.stub!(:deprecate) + @example_proxy.backtrace.should == "the location" + end + + specify "with the supplied location as #location" do + @example_proxy.location.should == "the location" + end + end end + + end - end - end - - describe "#it" do - it "should should create an example instance" do - lambda { - @example_group.it("") - }.should change { @example_group.examples.length }.by(1) - end - end + + [:xexample, :xit, :xspecify].each do |method| + describe "##{method.to_s}" do + before(:each) do + Kernel.stub!(:warn) + end - describe "#xit and #xspecify" do - before(:each) do - Kernel.stub!(:warn) + it "should NOT create an example" do + lambda { + @example_group.__send__(method,"") + }.should_not change(@example_group.examples, :length) + end + + it "should warn that the example is disabled" do + Kernel.should_receive(:warn).with("Example disabled: foo") + @example_group.__send__(method,"foo") + end + end end + + describe "#examples" do + it "should have Examples" do + example_group = Class.new(ExampleGroupDouble) do + it "should exist" do; end + end + example_group.examples.length.should == 1 + example_group.examples.first.description.should == "should exist" + end - it "should NOT create an example instance" do - lambda { - @example_group.xit("") - }.should_not change(@example_group.examples, :length) + it "should not include methods that begin with test (only when TU interop is loaded)" do + example_group = Class.new(ExampleGroupDouble) do + def test_any_args(*args) + true.should be_true + end + def test_something + 1.should == 1 + end + def test + raise "This is not a real test" + end + def testify + raise "This is not a real test" + end + def should_something + # forces the run + end + end + + example_group.examples.length.should == 1 + example_group.run(options).should be_true + end - lambda { - @example_group.xspecify("") - }.should_not change(@example_group.examples, :length) - end + it "should include methods that begin with should and has an arity of 0 in suite" do + example_group = Class.new(ExampleGroupDouble) do + def shouldCamelCase + true.should be_true + end + def should_any_args(*args) + true.should be_true + end + def should_something + 1.should == 1 + end + def should_not_something + 1.should_not == 2 + end + def should + raise "This is not a real example" + end + def should_not + raise "This is not a real example" + end + end + example_group.should have(4).examples + descriptions = example_group.examples.collect {|e| e.description} + descriptions.should include( + "shouldCamelCase", + "should_any_args", + "should_something", + "should_not_something") + descriptions.should_not include( + "should", + "should_not" + ) + end + + it "should not include methods that begin with test_ and has an arity > 0 in suite" do + example_group = Class.new(ExampleGroupDouble) do + def test_invalid(foo) + 1.should == 1 + end + def testInvalidCamelCase(foo) + 1.should == 1 + end + end + example_group.should have(:no).examples + end - it "should warn that it is disabled" do - Kernel.should_receive(:warn).with("Example disabled: foo").twice - @example_group.xit("foo") - @example_group.xspecify("foo") - end - end + it "should not include methods that begin with should_ and has an arity > 0 in suite" do + example_group = Class.new(ExampleGroupDouble) do + def should_invalid(foo) + 1.should == 2 + end + def shouldInvalidCamelCase(foo) + 1.should == 3 + end + def should_not_invalid(foo) + 1.should == 4 + end + def should_valid + 1.should == 1 + end + end + example_group.should have(1).examples + example_group.run(options).should be_true + end - describe "#examples" do - it "should have Examples" do - example_group = Class.new(ExampleGroup) do - describe('example') - it "should pass" do - 1.should == 1 + it "should run should_methods" do + example_group = Class.new(ExampleGroupDouble) do + def should_valid + 1.should == 2 + end end + example_group.should have(1).examples + example_group.run(options).should be_false end - example_group.examples.length.should == 1 - example_group.examples.first.description.should == "should pass" end - it "should not include methods that begin with test (only when TU interop is loaded)" do - example_group = Class.new(ExampleGroup) do - describe('example') - def test_any_args(*args) - true.should be_true + describe "#set_description" do + attr_reader :example_group + before do + class << example_group + public :set_description end - def test_something - 1.should == 1 + end + + describe "given a String" do + before(:each) do + example_group.set_description("abc") end - def test - raise "This is not a real test" + + specify ".description should return the String passed into .set_description" do + example_group.description.should == "abc" end - def testify - raise "This is not a real test" + + specify ".described_type should provide nil as its type" do + example_group.described_type.should be_nil end end - example_group.examples.length.should == 0 - example_group.run.should be_true - end - it "should include methods that begin with should and has an arity of 0 in suite" do - example_group = Class.new(ExampleGroup) do - describe('example') - def shouldCamelCase - true.should be_true + describe "given a Class" do + before(:each) do + example_group.set_description(ExampleGroup) end - def should_any_args(*args) - true.should be_true + + specify ".description should return a String representation of that type (fully qualified) as its name" do + example_group.description.should == "Spec::Example::ExampleGroup" end - def should_something - 1.should == 1 + + specify ".described_type should return the passed in type" do + example_group.described_type.should == Spec::Example::ExampleGroup end - def should_not_something - 1.should_not == 2 + end + + describe "given a String and a Class" do + before(:each) do + example_group.set_description("behaving", ExampleGroup) end - def should - raise "This is not a real example" + + specify ".description should return String then space then Type" do + example_group.description.should == "behaving Spec::Example::ExampleGroup" end - def should_not - raise "This is not a real example" + + specify ".described_type should return the passed in type" do + example_group.described_type.should == Spec::Example::ExampleGroup end end - example_group = example_group.dup - example_group.examples.length.should == 4 - descriptions = example_group.examples.collect {|example| example.description}.sort - descriptions.should include("shouldCamelCase") - descriptions.should include("should_any_args") - descriptions.should include("should_something") - descriptions.should include("should_not_something") - end - it "should not include methods that begin with test_ and has an arity > 0 in suite" do - example_group = Class.new(ExampleGroup) do - describe('example') - def test_invalid(foo) - 1.should == 1 + describe "given a Class and a String (starting with an alpha char)" do + before(:each) do + example_group.set_description(ExampleGroup, "behaving") end - def testInvalidCamelCase(foo) - 1.should == 1 + + specify ".description should return the Type then space then String" do + example_group.description.should == "Spec::Example::ExampleGroup behaving" end end - example_group.examples.length.should == 0 - end - it "should not include methods that begin with should_ and has an arity > 0 in suite" do - example_group = Class.new(ExampleGroup) do - describe('example') - def should_invalid(foo) - 1.should == 2 + describe "given a Class and a String (starting with a '.')" do + before(:each) do + example_group.set_description(ExampleGroup, ".behaving") end - def shouldInvalidCamelCase(foo) - 1.should == 3 + + specify ".description should return the Type then String" do + example_group.description.should == "Spec::Example::ExampleGroup.behaving" end - def should_not_invalid(foo) - 1.should == 4 + end + + describe "#set_description(Class, String starting with #)" do + before(:each) do + example_group.set_description(ExampleGroup, "#behaving") end - def should_valid - 1.should == 1 + + specify "should return the Class then String" do + example_group.description.should == "Spec::Example::ExampleGroup#behaving" end end - example_group.examples.length.should == 1 - example_group.run.should be_true - end - it "should run should_methods" do - example_group = Class.new(ExampleGroup) do - def should_valid - 1.should == 2 + describe "#set_description(Class, String containing .)" do + before(:each) do + example_group.set_description(ExampleGroup, "calling a.b") end - end - example_group.examples.length.should == 1 - example_group.run.should be_false - end - end - describe "#set_description" do - attr_reader :example_group - before do - class << example_group - public :set_description + specify ".description should return the Type then space then String" do + example_group.description.should == "Spec::Example::ExampleGroup calling a.b" + end end - end - describe "#set_description(String)" do - before(:each) do - example_group.set_description("abc") - end + describe "#set_description(Class, String containing #)" do + before(:each) do + example_group.set_description(ExampleGroup, "is #1") + end - specify ".description should return the String passed into .set_description" do - example_group.description.should == "abc" + specify ".description should return the Type then space then String" do + example_group.description.should == "Spec::Example::ExampleGroup is #1" + end end - specify ".described_type should provide nil as its type" do - example_group.described_type.should be_nil - end - end + describe "#set_description(String, Type, String)" do + before(:each) do + example_group.set_description("A", Hash, "with one entry") + end - describe "#set_description(Type)" do - before(:each) do - example_group.set_description(ExampleGroup) + specify ".description should return the first String then space then Type then second String" do + example_group.description.should == "A Hash with one entry" + end end - specify ".description should return a String representation of that type (fully qualified) as its name" do - example_group.description.should == "Spec::Example::ExampleGroup" - end + describe "#set_description(Hash representing options)" do + before(:each) do + example_group.set_description(:a => "b", :location => "blah") + end + + it ".location should expand the passed in :location option passed into the constructor" do + example_group.location.should == File.expand_path("blah") + end + + it ".options should return all the options passed in" do + example_group.options.should == {:a => "b", :location => "blah"} + end - specify ".described_type should return the passed in type" do - example_group.described_type.should == Spec::Example::ExampleGroup end end - describe "#set_description(String, Type)" do - before(:each) do - example_group.set_description("behaving", ExampleGroup) + describe "#description" do + it "should return the same description instance for each call" do + example_group.description.should eql(example_group.description) end - specify ".description should return String then space then Type" do - example_group.description.should == "behaving Spec::Example::ExampleGroup" + it "should not add a space when description begins with #" do + child_example_group = Class.new(example_group) do + describe("#foobar", "Does something") + end + child_example_group.description.should == "ExampleGroup#foobar Does something" end - specify ".described_type should return the passed in type" do - example_group.described_type.should == Spec::Example::ExampleGroup + it "should not add a space when description begins with ." do + child_example_group = Class.new(example_group) do + describe(".foobar", "Does something") + end + child_example_group.description.should == "ExampleGroup.foobar Does something" + end + + it "should return the class name if nil" do + example_group.set_description(nil) + example_group.description.should =~ /Class:/ + end + + it "should return the class name if nil" do + example_group.set_description("") + example_group.description.should =~ /Class:/ + end + + it "is cached" do + example_group.set_description("describe me") + example_group.description.should be(example_group.description) end end - describe "#set_description(Type, String not starting with a space)" do - before(:each) do - example_group.set_description(ExampleGroup, "behaving") + describe "#description_parts" do + it "should return an Array of the current class description args" do + example_group.description_parts.should == [example_group.description] end - specify ".description should return the Type then space then String" do - example_group.description.should == "Spec::Example::ExampleGroup behaving" + it "should return an Array of the description args from each class in the hierarchy" do + parent_example_group = Class.new(ExampleGroupDouble) do + describe("Parent") + end + + child_example_group = Class.new(parent_example_group) + child_example_group.describe("Child", ExampleGroup) + child_example_group.description.should_not be_empty + + grand_child_example_group = Class.new(child_example_group) + grand_child_example_group.describe("GrandChild", ExampleGroup) + grand_child_example_group.description.should_not be_empty + + grand_child_example_group.description_parts.should == [ + "Parent", + "Child", + Spec::Example::ExampleGroup, + "GrandChild", + Spec::Example::ExampleGroup + ] + end + + it "caches the description parts" do + example_group.description_parts.should equal(example_group.description_parts) end end - describe "#set_description(Type, String starting with .)" do - before(:each) do - example_group.set_description(ExampleGroup, ".behaving") + describe "#described_type" do + it "should return passed in type" do + child_example_group = Class.new(example_group) do + describe Object + end + child_example_group.described_type.should == Object end - specify ".description should return the Type then String" do - example_group.description.should == "Spec::Example::ExampleGroup.behaving" + it "should return #described_type of superclass when no passed in type" do + parent_example_group = Class.new(ExampleGroupDouble) do + describe Object, "#foobar" + end + child_example_group = Class.new(parent_example_group) do + describe "not a type" + end + child_example_group.described_type.should == Object + end + + it "is cached per example group" do + klass = Class.new + group = Class.new(ExampleGroupDouble) do + describe(klass) + end + group.should_receive(:description_parts).once.and_return([klass]) + group.described_type + group.described_type end end - describe "#set_description(Type, String containing .)" do - before(:each) do - example_group.set_description(ExampleGroup, "calling a.b") - end + describe "#include" do + it "should have accessible class methods from included module" do + mod_method_called = false + mod = Module.new do + class_methods = Module.new do + define_method :mod_method do + mod_method_called = true + end + end + + self.class.class_eval do + define_method(:included) do |receiver| + receiver.extend class_methods + end + end + end + + @example_group.__send__ :include, mod - specify ".description should return the Type then space then String" do - example_group.description.should == "Spec::Example::ExampleGroup calling a.b" + @example_group.mod_method + mod_method_called.should be_true end end - describe "#set_description(Type, String starting with .)" do - before(:each) do - example_group.set_description(ExampleGroup, ".behaving") + describe "#number_of_examples" do + it "should count number of examples" do + proc do + @example_group.it("one") {} + @example_group.it("two") {} + @example_group.it("three") {} + @example_group.it("four") {} + end.should change {@example_group.number_of_examples}.by(4) end + end - specify "should return the Type then String" do - example_group.description.should == "Spec::Example::ExampleGroup.behaving" + describe "#class_eval" do + it "should allow constants to be defined" do + example_group = Class.new(ExampleGroupDouble) do + FOO = 1 + it "should reference FOO" do + FOO.should == 1 + end + end + success = example_group.run(options) + success.should be_true + Object.const_defined?(:FOO).should == false end end - describe "#set_description(Type, String containing .)" do - before(:each) do - example_group.set_description(ExampleGroup, "is #1") + describe '#register' do + after(:each) do + Spec::Runner.options.remove_example_group example_group end - - specify ".description should return the Type then space then String" do - example_group.description.should == "Spec::Example::ExampleGroup is #1" + it "should add ExampleGroup to set of ExampleGroups to be run" do + Spec::Runner.options.add_example_group example_group + options.example_groups.should include(example_group) end end - describe "#set_description(String, Type, String)" do + describe '#remove_example_group' do before(:each) do - example_group.set_description("A", Hash, "with one entry") + Spec::Runner.options.add_example_group example_group end - - specify ".description should return the first String then space then Type then second String" do - example_group.description.should == "A Hash with one entry" + it "should remove ExampleGroup from set of ExampleGroups to be run" do + Spec::Runner.options.remove_example_group example_group + options.example_groups.should_not include(example_group) end end - - describe "#set_description(Hash representing options)" do - before(:each) do - example_group.set_description(:a => "b", :spec_path => "blah") + + describe "#run" do + describe "given an example group with at least one example" do + it "should call add_example_group" do + example_group = Class.new(ExampleGroupDouble) do + example("anything") {} + end + reporter.should_receive(:add_example_group) + example_group.run(options) + end end - it ".spec_path should expand the passed in :spec_path option passed into the constructor" do - example_group.spec_path.should == File.expand_path("blah") + describe "given an example group with no examples" do + it "should NOT call add_example_group" do + example_group = Class.new(ExampleGroupDouble) do end + reporter.should_not_receive(:add_example_group) + example_group.run(options) + end end + end - it ".description_options should return all the options passed in" do - example_group.description_options.should == {:a => "b", :spec_path => "blah"} - end + describe "#matcher_class=" do + it "should call new and matches? on the class used for matching examples" do + example_group = Class.new(ExampleGroupDouble) do + it "should do something" do end + def self.specified_examples + ["something"] + end + def self.to_s + "TestMatcher" + end + end - end - end + matcher = mock("matcher") + matcher.should_receive(:matches?).with(["something"]).any_number_of_times + + matcher_class = Class.new + matcher_class.should_receive(:new).with("TestMatcher", "should do something").and_return(matcher) - describe "#description" do - it "should return the same description instance for each call" do - example_group.description.should eql(example_group.description) - end + begin + ExampleGroupMethods.matcher_class = matcher_class - it "should not add a space when description_text begins with #" do - child_example_group = Class.new(example_group) do - describe("#foobar", "Does something") + example_group.run(options) + ensure + ExampleGroupMethods.matcher_class = ExampleMatcher + end end - child_example_group.description.should == "ExampleGroup#foobar Does something" end - it "should not add a space when description_text begins with ." do - child_example_group = Class.new(example_group) do - describe(".foobar", "Does something") + describe "#options" do + it "should expose the options hash" do + group = describe("group", :this => 'hash') {} + group.options[:this].should == 'hash' end - child_example_group.description.should == "ExampleGroup.foobar Does something" - end - - it "should return the class name if nil" do - example_group.set_description(nil) - example_group.description.should =~ /Class:/ - end - - it "should return the class name if nil" do - example_group.set_description("") - example_group.description.should =~ /Class:/ end - end - describe "#description_parts" do - it "should return an Array of the current class description args" do - example_group.description_parts.should == [example_group.description] - end + describe "#before" do + it "stores before(:each) blocks" do + example_group = Class.new(ExampleGroupDouble) {} + block = lambda {} + example_group.before(:each, &block) + example_group.before_each_parts.should include(block) + end - it "should return an Array of the description args from each class in the hierarchy" do - child_example_group = Class.new(example_group) - child_example_group.describe("Child", ExampleGroup) - child_example_group.description.should_not be_empty - - grand_child_example_group = Class.new(child_example_group) - grand_child_example_group.describe("GrandChild", ExampleGroup) - grand_child_example_group.description.should_not be_empty - - grand_child_example_group.description_parts.should == [ - "ExampleGroup", - "Child", - Spec::Example::ExampleGroup, - "GrandChild", - Spec::Example::ExampleGroup - ] - end - end + it "stores before(:all) blocks" do + example_group = Class.new(ExampleGroupDouble) {} + block = lambda {} + example_group.before(:all, &block) + example_group.before_all_parts.should include(block) + end - describe "#described_type" do - it "should return passed in type" do - child_example_group = Class.new(example_group) do - describe Object + it "stores before(:suite) blocks" do + example_group = Class.new(ExampleGroupDouble) {} + parts = [] + ExampleGroupMethods.stub!(:before_suite_parts).and_return(parts) + block = lambda {} + example_group.before(:suite, &block) + example_group.before_suite_parts.should include(block) end - child_example_group.described_type.should == Object end - it "should return #described_type of superclass when no passed in type" do - parent_example_group = Class.new(ExampleGroup) do - describe Object, "#foobar" + + describe "#after" do + it "stores after(:each) blocks" do + example_group = Class.new(ExampleGroupDouble) {} + block = lambda {} + example_group.after(:each, &block) + example_group.after_each_parts.should include(block) end - child_example_group = Class.new(parent_example_group) do - describe "not a type" + + it "stores after(:all) blocks" do + example_group = Class.new(ExampleGroupDouble) {} + block = lambda {} + example_group.after(:all, &block) + example_group.after_all_parts.should include(block) end - child_example_group.described_type.should == Object - end - end - describe "#remove_after" do - it "should unregister a given after(:each) block" do - after_all_ran = false - @example_group.it("example") {} - proc = Proc.new { after_all_ran = true } - ExampleGroup.after(:each, &proc) - @example_group.run - after_all_ran.should be_true - - after_all_ran = false - ExampleGroup.remove_after(:each, &proc) - @example_group.run - after_all_ran.should be_false + it "stores after(:suite) blocks" do + example_group = Class.new(ExampleGroupDouble) {} + parts = [] + ExampleGroupMethods.stub!(:after_suite_parts).and_return(parts) + block = lambda {} + example_group.after(:suite, &block) + example_group.after_suite_parts.should include(block) + end end - end - - describe "#include" do - it "should have accessible class methods from included module" do - mod1_method_called = false - mod1 = Module.new do - extend Spec::MetaClass - class_methods = Module.new do - define_method :mod1_method do - mod1_method_called = true - end - end - metaclass.class_eval do - define_method(:included) do |receiver| - receiver.extend class_methods + describe "#run_before_all" do + it "does not create an instance if before_all_parts are empty" do + example_group = Class.new(ExampleGroupDouble) { example("one example") {} } + example_group.should_not_receive(:new) + example_group.__send__ :run_before_all, nil + end + end + + describe "#run_after_all" do + it "does not create an instance if after_all_parts are empty" do + example_group = Class.new(ExampleGroupDouble) { example("one example") {} } + example_group.should_not_receive(:new) + example_group.__send__ :run_after_all, true, {}, nil + end + end + + describe "#examples_to_run" do + it "runs only the example identified by a line number" do + example_group = Class.new(ExampleGroupDouble).describe("this") do + it { 3.should == 3 } + it "has another example which raises" do + raise "this shouldn't have run" end end + options.examples << :ignore + options.line_number = __LINE__ - 6 + options.files << __FILE__ + example_group.run(options).should be_true end - mod2_method_called = false - mod2 = Module.new do - extend Spec::MetaClass - class_methods = Module.new do - define_method :mod2_method do - mod2_method_called = true - end - end + it "runs the example identified by a line number even if it's not the example line number" do + example_group = Class.new(ExampleGroupDouble).describe("this") do + + it { raise "foo" } - metaclass.class_eval do - define_method(:included) do |receiver| - receiver.extend class_methods - end end + options.examples << :ignore + options.line_number = __LINE__ - 3 + options.files << __FILE__ + example_group.run(options).should be_false end - @example_group.include mod1, mod2 - - @example_group.mod1_method - @example_group.mod2_method - mod1_method_called.should be_true - mod2_method_called.should be_true - end - end + it "runs all the examples in the group " do + first_example_ran = false + second_example_ran = false + example_group = Class.new(ExampleGroupDouble).describe("this") do - describe "#number_of_examples" do - it "should count number of specs" do - proc do - @example_group.it("one") {} - @example_group.it("two") {} - @example_group.it("three") {} - @example_group.it("four") {} - end.should change {@example_group.number_of_examples}.by(4) - end - end + it { first_example_ran = true } + it { second_example_ran = true } - describe "#class_eval" do - it "should allow constants to be defined" do - example_group = Class.new(ExampleGroup) do - describe('example') - FOO = 1 - it "should reference FOO" do - FOO.should == 1 end + options.line_number = __LINE__ - 6 + options.files << __FILE__ + options.examples << :ignore + example_group.run(options) + first_example_ran.should be_true + second_example_ran.should be_true + end + + it "doesn't run any examples in another group" do + example_ran = false + example_group_1 = Class.new(ExampleGroupDouble).describe("this") do + it "ignore" do + example_ran = true + end + end + example_group_2 = Class.new(ExampleGroupDouble).describe("that") do + end + options.examples << :ignore + options.line_number = __LINE__ - 3 + options.files << __FILE__ + example_group_1.run(options) + example_group_2.run(options) + example_ran.should be_false end - example_group.run - Object.const_defined?(:FOO).should == false end - end - describe '#register' do - it "should add ExampleGroup to set of ExampleGroups to be run" do - options.example_groups.delete(example_group) - options.example_groups.should_not include(example_group) + describe "#define" do + let(:counter) do + Class.new do + def initialize + @count = 0 + end + def count + @count += 1 + end + end.new + end + it "generates an instance method" do + counter.count.should == 1 + end - example_group.register {} - options.example_groups.should include(example_group) - end - end - - describe '#unregister' do - before do - options.example_groups.should include(example_group) - end - - it "should remove ExampleGroup from set of ExampleGroups to be run" do - example_group.unregister - options.example_groups.should_not include(example_group) - end - end - - describe "#registration_backtrace" do - it "returns the backtrace of where the ExampleGroup was registered" do - example_group = Class.new(ExampleGroup) - example_group.registration_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-1}") + it "caches the value" do + counter.count.should == 1 + counter.count.should == 2 + end end end end end -end
\ No newline at end of file +end diff --git a/vendor/plugins/rspec/spec/spec/example/example_group_spec.rb b/vendor/plugins/rspec/spec/spec/example/example_group_spec.rb index 36e1cdf0d..086c166ca 100644 --- a/vendor/plugins/rspec/spec/spec/example/example_group_spec.rb +++ b/vendor/plugins/rspec/spec/spec/example/example_group_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper' +require 'spec_helper' module Spec module Example @@ -7,9 +7,7 @@ module Spec module Foo module Bar - def self.loaded? - true - end + def self.loaded?; true; end end end include Foo @@ -18,11 +16,23 @@ module Spec Bar.should be_loaded end - @@foo = 1 + @@class_variable = "a class variable" - it "should allow class variables to be defined" do - @@foo.should == 1 + it "can access class variables in examples in Ruby 1.8" do + with_ruby 1.8 do + @@class_variable.should == "a class variable" + end + end + + it "can NOT access class variables in examples in Ruby 1.9" do + with_ruby 1.9 do + lambda do + @@class_variable.should == "a class variable" + end.should raise_error(NameError) + end end + + end class ExampleClassVariablePollutionSpec < ExampleGroup @@ -30,7 +40,7 @@ module Spec it "should not retain class variables from other Example classes" do proc do - @@foo + @@class_variable end.should raise_error end end @@ -60,663 +70,573 @@ module Spec describe ExampleGroup, "#run with failure in example", :shared => true do it "should add an example failure to the TestResult" do - example_group.run.should be_false + example_group.run(options).should be_false end end describe ExampleGroup, "#run" do - it_should_behave_like "sandboxed rspec_options" - attr_reader :example_group, :formatter, :reporter - before :each do - @formatter = mock("formatter", :null_object => true) - options.formatters << formatter - options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true) - @reporter = FakeReporter.new(options) - options.reporter = reporter - @example_group = Class.new(ExampleGroup) do - describe("example") - it "does nothing" do - end - end - class << example_group - public :include - end - end - - after :each do - ExampleGroup.reset - end - - it "should not run when there are no examples" do - example_group = Class.new(ExampleGroup) do - describe("Foobar") - end - example_group.examples.should be_empty - - reporter = mock("Reporter") - reporter.should_not_receive(:add_example_group) - example_group.run - end - - describe "when before_each fails" do - before(:each) do - $example_ran = $after_each_ran = false - @example_group = describe("Foobar") do - before(:each) {raise} - it "should not be run" do - $example_ran = true - end - after(:each) do - $after_each_ran = true + with_sandboxed_options do + attr_reader :example_group, :formatter, :reporter + before :each do + method_with_three_args = lambda { |arg1, arg2, arg3| } + @formatter = mock("formatter", :null_object => true, :example_pending => method_with_three_args) + options.formatters << formatter + options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true) + @reporter = FakeReporter.new(options) + options.reporter = reporter + @example_group = Class.new(ExampleGroupDouble) do + describe("example") + it "does nothing" do end end + class << example_group + public :include + end end - it "should not run example block" do - example_group.run - $example_ran.should be_false - end - - it "should run after_each" do - example_group.run - $after_each_ran.should be_true + after :each do + ExampleGroup.reset end - it "should report failure location when in before_each" do - reporter.should_receive(:example_finished) do |example_group, error| - error.message.should eql("in before_each") + it "should not run when there are no examples" do + example_group = Class.new(ExampleGroupDouble) do + describe("Foobar") end - example_group.run - end - end - - describe ExampleGroup, "#run on dry run" do - before do - @options.dry_run = true - end + example_group.examples.should be_empty - it "should not run before(:all) or after(:all)" do - before_all_ran = false - after_all_ran = false - ExampleGroup.before(:all) { before_all_ran = true } - ExampleGroup.after(:all) { after_all_ran = true } - example_group.it("should") {} - example_group.run - before_all_ran.should be_false - after_all_ran.should be_false + reporter = mock("Reporter") + reporter.should_not_receive(:add_example_group) + example_group.run(options) end - it "should not run example" do - example_ran = false - example_group.it("should") {example_ran = true} - example_group.run - example_ran.should be_false + it "should report the start of an example run" do + reporter.should_receive(:example_started) do |example| + example.should equal(example_group.examples[0]) + end + example_group.run(options) end - end - describe ExampleGroup, "#run with specified examples" do - attr_reader :examples_that_were_run - before do - @examples_that_were_run = [] + it "should report the end of an example run" do + reporter.should_receive(:example_finished) do |example, execution_error| + example.should equal(example_group.examples[0]) + execution_error.should be_nil + end + example_group.run(options) end - - describe "when specified_examples matches entire ExampleGroup" do - before do - examples_that_were_run = @examples_that_were_run - @example_group = Class.new(ExampleGroup) do - describe("the ExampleGroup") - it("should be run") do - examples_that_were_run << 'should be run' + + describe "when before_each fails" do + before(:each) do + $example_ran = $after_each_ran = false + @example_group = describe("Foobar") do + before(:each) {raise} + it "should not be run" do + $example_ran = true end - - it("should also be run") do - examples_that_were_run << 'should also be run' + after(:each) do + $after_each_ran = true end end - options.examples = ["the ExampleGroup"] end - it "should not run the Examples in the ExampleGroup" do - example_group.run - examples_that_were_run.should == ['should be run', 'should also be run'] + it "should not run example block" do + example_group.run(options) + $example_ran.should be_false end - end - - describe ExampleGroup, "#run when specified_examples matches only Example description" do - before do - examples_that_were_run = @examples_that_were_run - @example_group = Class.new(ExampleGroup) do - describe("example") - it("should be run") do - examples_that_were_run << 'should be run' - end - end - options.examples = ["should be run"] + + it "should run after_each" do + example_group.run(options) + $after_each_ran.should be_true end - it "should not run the example" do - example_group.run - examples_that_were_run.should == ['should be run'] - end - end - - describe ExampleGroup, "#run when specified_examples does not match an Example description" do - before do - examples_that_were_run = @examples_that_were_run - @example_group = Class.new(ExampleGroup) do - describe("example") - it("should be something else") do - examples_that_were_run << 'should be something else' - end + it "should report failure location when in before_each" do + reporter.should_receive(:example_finished) do |example_group, error| + error.message.should eql("in before_each") end - options.examples = ["does not match anything"] - end - - it "should not run the example" do - example_group.run - examples_that_were_run.should == [] + example_group.run(options) end end - describe ExampleGroup, "#run when specified_examples matches an Example description" do + describe ExampleGroup, "#run on dry run" do before do - examples_that_were_run = @examples_that_were_run - @example_group = Class.new(ExampleGroup) do - describe("example") - it("should be run") do - examples_that_were_run << 'should be run' - end - it("should not be run") do - examples_that_were_run << 'should not be run' - end - end - options.examples = ["should be run"] + @options.dry_run = true end - it "should run only the example, when there in only one" do - example_group.run - examples_that_were_run.should == ["should be run"] + it "should not run before(:all) or after(:all)" do + before_all_ran = false + after_all_ran = false + ExampleGroup.before(:all) { before_all_ran = true } + ExampleGroup.after(:all) { after_all_ran = true } + example_group.it("should") {} + example_group.run(options) + before_all_ran.should be_false + after_all_ran.should be_false end - it "should run only the one example" do - example_group.run - examples_that_were_run.should == ["should be run"] end + it "should not run example" do + example_ran = false + example_group.it("should") {example_ran = true} + example_group.run(options) + example_ran.should be_false + end end - end - describe ExampleGroup, "#run with success" do - before do - @special_example_group = Class.new(ExampleGroup) - ExampleGroupFactory.register(:special, @special_example_group) - @not_special_example_group = Class.new(ExampleGroup) - ExampleGroupFactory.register(:not_special, @not_special_example_group) - end + describe ExampleGroup, "#run with specified examples" do + attr_reader :examples_that_were_run + before do + @examples_that_were_run = [] + end - after do - ExampleGroupFactory.reset - end + describe "when specified_examples matches entire ExampleGroup" do + before do + examples_that_were_run = @examples_that_were_run + @example_group = Class.new(ExampleGroupDouble) do + describe("the ExampleGroup") + it("should be run") do + examples_that_were_run << 'should be run' + end - it "should send reporter add_example_group" do - example_group.run - reporter.example_groups.should == [example_group] - end + it("should also be run") do + examples_that_were_run << 'should also be run' + end + end + options.parse_example "the ExampleGroup" + end - it "should run example on run" do - example_ran = false - example_group.it("should") {example_ran = true} - example_group.run - example_ran.should be_true - end + it "should not run the Examples in the ExampleGroup" do + example_group.run(options) + examples_that_were_run.should == ['should be run', 'should also be run'] + end + end - it "should run before(:all) block only once" do - before_all_run_count_run_count = 0 - example_group.before(:all) {before_all_run_count_run_count += 1} - example_group.it("test") {true} - example_group.it("test2") {true} - example_group.run - before_all_run_count_run_count.should == 1 - end + describe ExampleGroup, "#run when specified_examples matches only Example description" do + before do + examples_that_were_run = @examples_that_were_run + @example_group = Class.new(ExampleGroupDouble) do + describe("example") + it("should be run") do + examples_that_were_run << 'should be run' + end + end + options.parse_example "should be run" + end - it "should run after(:all) block only once" do - after_all_run_count = 0 - example_group.after(:all) {after_all_run_count += 1} - example_group.it("test") {true} - example_group.it("test2") {true} - example_group.run - after_all_run_count.should == 1 - @reporter.rspec_verify - end + it "should not run the example" do + example_group.run(options) + examples_that_were_run.should == ['should be run'] + end + end - it "after(:all) should have access to all instance variables defined in before(:all)" do - context_instance_value_in = "Hello there" - context_instance_value_out = "" - example_group.before(:all) { @instance_var = context_instance_value_in } - example_group.after(:all) { context_instance_value_out = @instance_var } - example_group.it("test") {true} - example_group.run - context_instance_value_in.should == context_instance_value_out - end + describe ExampleGroup, "#run when specified_examples does not match an Example description" do + before do + examples_that_were_run = @examples_that_were_run + @example_group = Class.new(ExampleGroupDouble) do + describe("example") + it("should be something else") do + examples_that_were_run << 'should be something else' + end + end + options.parse_example "does not match anything" + end - it "should copy instance variables from before(:all)'s execution context into spec's execution context" do - context_instance_value_in = "Hello there" - context_instance_value_out = "" - example_group.before(:all) { @instance_var = context_instance_value_in } - example_group.it("test") {context_instance_value_out = @instance_var} - example_group.run - context_instance_value_in.should == context_instance_value_out - end + it "should not run the example" do + example_group.run(options) + examples_that_were_run.should == [] + end + end - it "should not add global before callbacks for untargetted example_group" do - fiddle = [] - - ExampleGroup.before(:all) { fiddle << "Example.before(:all)" } - ExampleGroup.prepend_before(:all) { fiddle << "Example.prepend_before(:all)" } - @special_example_group.before(:each) { fiddle << "Example.before(:each, :type => :special)" } - @special_example_group.prepend_before(:each) { fiddle << "Example.prepend_before(:each, :type => :special)" } - @special_example_group.before(:all) { fiddle << "Example.before(:all, :type => :special)" } - @special_example_group.prepend_before(:all) { fiddle << "Example.prepend_before(:all, :type => :special)" } - - example_group = Class.new(ExampleGroup) do - describe("I'm not special", :type => :not_special) - it "does nothing" - end - example_group.run - fiddle.should == [ - 'Example.prepend_before(:all)', - 'Example.before(:all)', - ] - end + describe ExampleGroup, "#run when specified_examples matches an Example description" do + before do + examples_that_were_run = @examples_that_were_run + @example_group = Class.new(ExampleGroupDouble) do + describe("example") + it("should be run") do + examples_that_were_run << 'should be run' + end + it("should not be run") do + examples_that_were_run << 'should not be run' + end + end + options.parse_example "should be run" + end - it "should add global before callbacks for targetted example_groups" do - fiddle = [] - - ExampleGroup.before(:all) { fiddle << "Example.before(:all)" } - ExampleGroup.prepend_before(:all) { fiddle << "Example.prepend_before(:all)" } - @special_example_group.before(:each) { fiddle << "special.before(:each, :type => :special)" } - @special_example_group.prepend_before(:each) { fiddle << "special.prepend_before(:each, :type => :special)" } - @special_example_group.before(:all) { fiddle << "special.before(:all, :type => :special)" } - @special_example_group.prepend_before(:all) { fiddle << "special.prepend_before(:all, :type => :special)" } - @special_example_group.append_before(:each) { fiddle << "special.append_before(:each, :type => :special)" } - - example_group = Class.new(@special_example_group).describe("I'm a special example_group") {} - example_group.it("test") {true} - example_group.run - fiddle.should == [ - 'Example.prepend_before(:all)', - 'Example.before(:all)', - 'special.prepend_before(:all, :type => :special)', - 'special.before(:all, :type => :special)', - 'special.prepend_before(:each, :type => :special)', - 'special.before(:each, :type => :special)', - 'special.append_before(:each, :type => :special)', - ] + it "should run only the example" do + example_group.run(options) + examples_that_were_run.should == ["should be run"] + end + end end - it "should order before callbacks from global to local" do - fiddle = [] - ExampleGroup.prepend_before(:all) { fiddle << "Example.prepend_before(:all)" } - ExampleGroup.before(:all) { fiddle << "Example.before(:all)" } - example_group.prepend_before(:all) { fiddle << "prepend_before(:all)" } - example_group.before(:all) { fiddle << "before(:all)" } - example_group.prepend_before(:each) { fiddle << "prepend_before(:each)" } - example_group.before(:each) { fiddle << "before(:each)" } - example_group.run - fiddle.should == [ - 'Example.prepend_before(:all)', - 'Example.before(:all)', - 'prepend_before(:all)', - 'before(:all)', - 'prepend_before(:each)', - 'before(:each)' - ] - end + describe ExampleGroup, "#run with success" do + before do + @special_example_group = Class.new(ExampleGroupDouble) + ExampleGroupFactory.register(:special, @special_example_group) + @not_special_example_group = Class.new(ExampleGroupDouble) + ExampleGroupFactory.register(:not_special, @not_special_example_group) + end - it "should order after callbacks from local to global" do - fiddle = [] - example_group.after(:each) { fiddle << "after(:each)" } - example_group.append_after(:each) { fiddle << "append_after(:each)" } - example_group.after(:all) { fiddle << "after(:all)" } - example_group.append_after(:all) { fiddle << "append_after(:all)" } - ExampleGroup.after(:all) { fiddle << "Example.after(:all)" } - ExampleGroup.append_after(:all) { fiddle << "Example.append_after(:all)" } - example_group.run - fiddle.should == [ - 'after(:each)', - 'append_after(:each)', - 'after(:all)', - 'append_after(:all)', - 'Example.after(:all)', - 'Example.append_after(:all)' - ] - end + after do + ExampleGroupFactory.reset + end - it "should have accessible instance methods from included module" do - mod1_method_called = false - mod1 = Module.new do - define_method :mod1_method do - mod1_method_called = true - end + it "should send reporter example_group_started" do + reporter.should_receive(:example_group_started) + example_group.run(options) end - mod2_method_called = false - mod2 = Module.new do - define_method :mod2_method do - mod2_method_called = true - end + it "should run example on run" do + example_ran = false + example_group.it("should") {example_ran = true} + example_group.run(options) + example_ran.should be_true end - example_group.include mod1, mod2 + it "should run before(:all) block only once" do + before_all_run_count_run_count = 0 + example_group.before(:all) {before_all_run_count_run_count += 1} + example_group.it("test") {true} + example_group.it("test2") {true} + example_group.run(options) + before_all_run_count_run_count.should == 1 + end - example_group.it("test") do - mod1_method - mod2_method + it "should run after(:all) block only once" do + after_all_run_count = 0 + example_group.after(:all) {after_all_run_count += 1} + example_group.it("test") {true} + example_group.it("test2") {true} + example_group.run(options) + after_all_run_count.should == 1 + @reporter.rspec_verify end - example_group.run - mod1_method_called.should be_true - mod2_method_called.should be_true - end - it "should include targetted modules included using configuration" do - mod1 = Module.new - mod2 = Module.new - mod3 = Module.new - Spec::Runner.configuration.include(mod1, mod2) - Spec::Runner.configuration.include(mod3, :type => :not_special) + it "after(:all) should have access to all instance variables defined in before(:all)" do + context_instance_value_in = "Hello there" + context_instance_value_out = "" + example_group.before(:all) { @instance_var = context_instance_value_in } + example_group.after(:all) { context_instance_value_out = @instance_var } + example_group.it("test") {true} + example_group.run(options) + context_instance_value_in.should == context_instance_value_out + end - example_group = Class.new(@special_example_group).describe("I'm special", :type => :special) do - it "does nothing" + it "should copy instance variables from before(:all)'s execution context into spec's execution context" do + context_instance_value_in = "Hello there" + context_instance_value_out = "" + example_group.before(:all) { @instance_var = context_instance_value_in } + example_group.it("test") {context_instance_value_out = @instance_var} + example_group.run(options) + context_instance_value_in.should == context_instance_value_out end - example_group.run - example_group.included_modules.should include(mod1) - example_group.included_modules.should include(mod2) - example_group.included_modules.should_not include(mod3) - end + it "should not add global before callbacks for untargetted example_group" do + fiddle = [] + + ExampleGroup.before(:all) { fiddle << "Example.before(:all)" } + ExampleGroup.prepend_before(:all) { fiddle << "Example.prepend_before(:all)" } + @special_example_group.before(:each) { fiddle << "Example.before(:each, :type => :special)" } + @special_example_group.prepend_before(:each) { fiddle << "Example.prepend_before(:each, :type => :special)" } + @special_example_group.before(:all) { fiddle << "Example.before(:all, :type => :special)" } + @special_example_group.prepend_before(:all) { fiddle << "Example.prepend_before(:all, :type => :special)" } - it "should include any predicate_matchers included using configuration" do - $included_predicate_matcher_found = false - Spec::Runner.configuration.predicate_matchers[:do_something] = :does_something? - example_group = Class.new(ExampleGroup) do - describe('example') - it "should respond to do_something" do - $included_predicate_matcher_found = respond_to?(:do_something) + example_group = Class.new(ExampleGroupDouble) do + describe("I'm not special", :type => :not_special) + it "does nothing" + end + example_group.run(options) + fiddle.should == [ + 'Example.prepend_before(:all)', + 'Example.before(:all)', + ] + end + + it "should add global before callbacks for targetted example_groups" do + fiddle = [] + + ExampleGroup.before(:all) { fiddle << "Example.before(:all)" } + ExampleGroup.prepend_before(:all) { fiddle << "Example.prepend_before(:all)" } + @special_example_group.before(:each) { fiddle << "special.before(:each, :type => :special)" } + @special_example_group.prepend_before(:each) { fiddle << "special.prepend_before(:each, :type => :special)" } + @special_example_group.before(:all) { fiddle << "special.before(:all, :type => :special)" } + @special_example_group.prepend_before(:all) { fiddle << "special.prepend_before(:all, :type => :special)" } + @special_example_group.append_before(:each) { fiddle << "special.append_before(:each, :type => :special)" } + + example_group = Class.new(@special_example_group).describe("I'm a special example_group") {} + example_group.it("test") {true} + example_group.run(options) + fiddle.should == [ + 'Example.prepend_before(:all)', + 'Example.before(:all)', + 'special.prepend_before(:all, :type => :special)', + 'special.before(:all, :type => :special)', + 'special.prepend_before(:each, :type => :special)', + 'special.before(:each, :type => :special)', + 'special.append_before(:each, :type => :special)', + ] + end + + it "should order before callbacks from global to local" do + fiddle = [] + ExampleGroup.prepend_before(:all) { fiddle << "Example.prepend_before(:all)" } + ExampleGroup.before(:all) { fiddle << "Example.before(:all)" } + example_group.prepend_before(:all) { fiddle << "prepend_before(:all)" } + example_group.before(:all) { fiddle << "before(:all)" } + example_group.prepend_before(:each) { fiddle << "prepend_before(:each)" } + example_group.before(:each) { fiddle << "before(:each)" } + example_group.run(options) + fiddle.should == [ + 'Example.prepend_before(:all)', + 'Example.before(:all)', + 'prepend_before(:all)', + 'before(:all)', + 'prepend_before(:each)', + 'before(:each)' + ] + end + + it "should order after callbacks from local to global" do + fiddle = [] + example_group.after(:each) { fiddle << "after(:each)" } + example_group.append_after(:each) { fiddle << "append_after(:each)" } + example_group.after(:all) { fiddle << "after(:all)" } + example_group.append_after(:all) { fiddle << "append_after(:all)" } + ExampleGroup.after(:all) { fiddle << "Example.after(:all)" } + ExampleGroup.append_after(:all) { fiddle << "Example.append_after(:all)" } + example_group.run(options) + fiddle.should == [ + 'after(:each)', + 'append_after(:each)', + 'after(:all)', + 'append_after(:all)', + 'Example.after(:all)', + 'Example.append_after(:all)' + ] + end + + it "should have accessible instance methods from included module" do + mod1_method_called = false + mod1 = Module.new do + define_method :mod1_method do + mod1_method_called = true + end end - end - example_group.run - $included_predicate_matcher_found.should be(true) - end - it "should use a mock framework set up in config" do - mod = Module.new do - class << self - def included(mod) - $included_module = mod + mod2_method_called = false + mod2 = Module.new do + define_method :mod2_method do + mod2_method_called = true end end - def teardown_mocks_for_rspec - $torn_down = true + example_group.include mod1, mod2 + + example_group.it("test") do + mod1_method + mod2_method end + example_group.run(options) + mod1_method_called.should be_true + mod2_method_called.should be_true end - begin - $included_module = nil - $torn_down = true - Spec::Runner.configuration.mock_with mod + it "should include targetted modules included using configuration" do + mod1 = Module.new + mod2 = Module.new + mod3 = Module.new + Spec::Runner.configuration.include(mod1, mod2) + Spec::Runner.configuration.include(mod3, :type => :not_special) - example_group = Class.new(ExampleGroup) do - describe('example') + example_group = Class.new(@special_example_group).describe("I'm special", :type => :special) do it "does nothing" end - example_group.run + example_group.run(options) - $included_module.should_not be_nil - $torn_down.should == true - ensure - Spec::Runner.configuration.mock_with :rspec + example_group.included_modules.should include(mod1) + example_group.included_modules.should include(mod2) + example_group.included_modules.should_not include(mod3) end + end - end - describe ExampleGroup, "#run with pending example that has a failing assertion" do - before do - example_group.it("should be pending") do - pending("Example fails") {false.should be_true} + describe ExampleGroup, "#run with pending example that has a failing assertion" do + before do + example_group.it("should be pending") do + pending("Example fails") {false.should be_true} + end end - end - it "should send example_pending to formatter" do - @formatter.should_receive(:example_pending).with("example", "should be pending", "Example fails") - example_group.run + it "should send example_pending to formatter" do + @formatter.should_receive(:example_pending).with("example", "should be pending", "Example fails") + example_group.run(options) + end end - end - describe ExampleGroup, "#run with pending example that does not have a failing assertion" do - it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" + describe ExampleGroup, "#run with pending example that does not have a failing assertion" do + it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" - before do - example_group.it("should be pending") do - pending("Example passes") {true.should be_true} + before do + example_group.it("should be pending") do + pending("Example passes") {true.should be_true} + end end - end - it "should send example_pending to formatter" do - @formatter.should_receive(:example_pending).with("example", "should be pending", "Example passes") - example_group.run + it "should send example_pending to formatter" do + @formatter.should_receive(:example_pending).with("example", "should be pending", "Example passes") + example_group.run(options) + end end - end - describe ExampleGroup, "#run when before(:all) fails" do - it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" + describe ExampleGroup, "#run when before(:all) fails" do + it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" - before do - ExampleGroup.before(:all) { raise NonStandardError, "before(:all) failure" } - end - - it "should not run any example" do - spec_ran = false - example_group.it("test") {spec_ran = true} - example_group.run - spec_ran.should be_false - end + before do + ExampleGroup.before(:all) { raise NonStandardError, "before(:all) failure" } + end - it "should run ExampleGroup after(:all)" do - after_all_ran = false - ExampleGroup.after(:all) { after_all_ran = true } - example_group.run - after_all_ran.should be_true - end + it "should not run any example" do + spec_ran = false + example_group.it("test") {spec_ran = true} + example_group.run(options) + spec_ran.should be_false + end - it "should run example_group after(:all)" do - after_all_ran = false - example_group.after(:all) { after_all_ran = true } - example_group.run - after_all_ran.should be_true - end + it "should run ExampleGroup after(:all)" do + after_all_ran = false + ExampleGroup.after(:all) { after_all_ran = true } + example_group.run(options) + after_all_ran.should be_true + end - it "should supply before(:all) as description" do - @reporter.should_receive(:failure) do |example, error| - example.description.should eql("before(:all)") - error.message.should eql("before(:all) failure") + it "should run example_group after(:all)" do + after_all_ran = false + example_group.after(:all) { after_all_ran = true } + example_group.run(options) + after_all_ran.should be_true end - example_group.it("test") {true} - example_group.run + it "should supply before(:all) as description" do + @reporter.should_receive(:example_failed) do |example, error| + example.description.should eql("before(:all)") + error.message.should eql("before(:all) failure") + end + + example_group.it("test") {true} + example_group.run(options) + end end - end - describe ExampleGroup, "#run when before(:each) fails" do - it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" + describe ExampleGroup, "#run when before(:each) fails" do + it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" - before do - ExampleGroup.before(:each) { raise NonStandardError } - end + before do + ExampleGroup.before(:each) { raise NonStandardError } + end - it "should run after(:all)" do - after_all_ran = false - ExampleGroup.after(:all) { after_all_ran = true } - example_group.run - after_all_ran.should be_true + it "should run after(:all)" do + after_all_ran = false + ExampleGroup.after(:all) { after_all_ran = true } + example_group.run(options) + after_all_ran.should be_true + end end - end - describe ExampleGroup, "#run when any example fails" do - it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" + describe ExampleGroup, "#run when any example fails" do + it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" - before do - example_group.it("should") { raise NonStandardError } - end + before do + example_group.it("should") { raise NonStandardError } + end - it "should run after(:all)" do - after_all_ran = false - ExampleGroup.after(:all) { after_all_ran = true } - example_group.run - after_all_ran.should be_true + it "should run after(:all)" do + after_all_ran = false + ExampleGroup.after(:all) { after_all_ran = true } + example_group.run(options) + after_all_ran.should be_true + end end - end - describe ExampleGroup, "#run when first after(:each) block fails" do - it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" + describe ExampleGroup, "#run when first after(:each) block fails" do + it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" - before do - class << example_group - attr_accessor :first_after_ran, :second_after_ran - end - example_group.first_after_ran = false - example_group.second_after_ran = false + before do + class << example_group + attr_accessor :first_after_ran, :second_after_ran + end + example_group.first_after_ran = false + example_group.second_after_ran = false - example_group.after(:each) do - self.class.second_after_ran = true - end - example_group.after(:each) do - self.class.first_after_ran = true - raise "first" + example_group.after(:each) do + self.class.second_after_ran = true + end + example_group.after(:each) do + self.class.first_after_ran = true + raise "first" + end end - end - it "should run second after(:each) block" do - reporter.should_receive(:example_finished) do |example, error| - example.should equal(example) - error.message.should eql("first") + it "should run second after(:each) block" do + reporter.should_receive(:example_finished) do |example, error| + example.should equal(example) + error.message.should eql("first") + end + example_group.run(options) + example_group.first_after_ran.should be_true + example_group.second_after_ran.should be_true end - example_group.run - example_group.first_after_ran.should be_true - example_group.second_after_ran.should be_true end - end - describe ExampleGroup, "#run when first before(:each) block fails" do - it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" + describe ExampleGroup, "#run when first before(:each) block fails" do + it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" - before do - class << example_group - attr_accessor :first_before_ran, :second_before_ran - end - example_group.first_before_ran = false - example_group.second_before_ran = false + before do + class << example_group + attr_accessor :first_before_ran, :second_before_ran + end + example_group.first_before_ran = false + example_group.second_before_ran = false - example_group.before(:each) do - self.class.first_before_ran = true - raise "first" - end - example_group.before(:each) do - self.class.second_before_ran = true + example_group.before(:each) do + self.class.first_before_ran = true + raise "first" + end + example_group.before(:each) do + self.class.second_before_ran = true + end end - end - it "should not run second before(:each)" do - reporter.should_receive(:example_finished) do |name, error| - error.message.should eql("first") + it "should not run second before(:each)" do + reporter.should_receive(:example_finished) do |name, error| + error.message.should eql("first") + end + example_group.run(options) + example_group.first_before_ran.should be_true + example_group.second_before_ran.should be_false end - example_group.run - example_group.first_before_ran.should be_true - example_group.second_before_ran.should be_false end - end - describe ExampleGroup, "#run when failure in after(:all)" do - it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" + describe ExampleGroup, "#run when failure in after(:all)" do + it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" - before do - ExampleGroup.after(:all) { raise NonStandardError, "in after(:all)" } - end + before do + ExampleGroup.after(:all) { raise NonStandardError, "in after(:all)" } + end - it "should return false" do - example_group.run.should be_false + it "should return false" do + example_group.run(options).should be_false + end end end end - class ExampleSubclass < ExampleGroup - end - describe ExampleGroup, "subclasses" do - after do - ExampleGroupFactory.reset - end - it "should have access to the described_type" do - example_group = Class.new(ExampleSubclass) do - describe(Array) - end - example_group.send(:described_type).should == Array + example_group = Class.new(ExampleGroupDouble).describe(Array) + example_group.__send__(:described_type).should == Array end it "should concat descriptions when nested" do - example_group = Class.new(ExampleSubclass) do - describe(Array) - $nested_group = describe("when empty") do - end - end - $nested_group.description.to_s.should == "Array when empty" - end - end - - describe Enumerable do - before(:each) do - Kernel.stub!(:warn) - end - - def each(&block) - ["4", "2", "1"].each(&block) - end - - it "should be included in examples because it is a module" do - map{|e| e.to_i}.should == [4,2,1] - end - end - - describe "An", Enumerable, "as a second argument" do - before(:each) do - Kernel.stub!(:warn) - end - - def each(&block) - ["4", "2", "1"].each(&block) - end - - it "should be included in examples because it is a module" do - map{|e| e.to_i}.should == [4,2,1] - end - end - - describe Enumerable do - describe "as the parent of nested example groups" do - before(:each) do - Kernel.stub!(:warn) - end - - it "should be included in examples because it is a module" do - pending("need to make sure nested groups know the described type") do - map{|e| e.to_i}.should == [4,2,1] - end - end - end - end - - describe String do - it "should not be included in examples because it is not a module" do - lambda{self.map}.should raise_error(NoMethodError, /undefined method `map' for/) + example_group = Class.new(ExampleGroupDouble).describe(Array) + nested_group = example_group.describe("when empty") do; end + nested_group.description.to_s.should == "Array when empty" end end end diff --git a/vendor/plugins/rspec/spec/spec/example/example_matcher_spec.rb b/vendor/plugins/rspec/spec/spec/example/example_matcher_spec.rb index ea0dfe019..1a7e5da25 100644 --- a/vendor/plugins/rspec/spec/spec/example/example_matcher_spec.rb +++ b/vendor/plugins/rspec/spec/spec/example/example_matcher_spec.rb @@ -1,71 +1,54 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Example - module ExampleMatcherSpecHelper - class MatchDescription - def initialize(description) - @description = description - end - - def matches?(matcher) - matcher.matches?(@description) - end - - def failure_message - "expected matcher.matches?(#{@description.inspect}) to return true, got false" - end - - def negative_failure_message - "expected matcher.matches?(#{@description.inspect}) to return false, got true" + describe ExampleMatcher, "#matches?" do + def match_examples(examples) + simple_matcher do |actual, matcher| + matcher.failure_message = "expected matcher.matches?(#{description.inspect}) to return true, got false" + matcher.negative_failure_message = "expected matcher.matches?(#{description.inspect}) to return false, got true" + actual.matches?(examples) end end - def match_description(description) - MatchDescription.new(description) - end - end - - describe ExampleMatcher, "#matches?" do - include ExampleMatcherSpecHelper it "should match correct example_group and example" do matcher = ExampleMatcher.new("example_group", "example") - matcher.should match_description("example_group example") + matcher.should match_examples(["example_group example"]) end it "should not match wrong example" do matcher = ExampleMatcher.new("example_group", "other example") - matcher.should_not match_description("example_group example") + matcher.should_not match_examples(["example_group example"]) end it "should not match wrong example_group" do matcher = ExampleMatcher.new("other example_group", "example") - matcher.should_not match_description("example_group example") + matcher.should_not match_examples(["example_group example"]) end it "should match example only" do matcher = ExampleMatcher.new("example_group", "example") - matcher.should match_description("example") + matcher.should match_examples(["example"]) end it "should match example_group only" do matcher = ExampleMatcher.new("example_group", "example") - matcher.should match_description("example_group") + matcher.should match_examples(["example_group"]) end it "should match example_group ending with before(:all)" do matcher = ExampleMatcher.new("example_group", "example") - matcher.should match_description("example_group before(:all)") + matcher.should match_examples(["example_group before(:all)"]) end it "should escape regexp chars" do matcher = ExampleMatcher.new("(con|text)", "[example]") - matcher.should_not match_description("con p") + matcher.should_not match_examples(["con p"]) end it "should match when example_group is modularized" do matcher = ExampleMatcher.new("MyModule::MyClass", "example") - matcher.should match_description("MyClass example") + matcher.should match_examples(["MyClass example"]) end end @@ -92,5 +75,12 @@ module Spec matcher.matches?(["no match1", "no match2"]).should == false end end + + describe ExampleMatcher, "called with nil example" do + it "does not puke" do + matcher = ExampleMatcher.new("Foo::Bar", nil) + matcher.matches?(["anything"]).should == false + end + end end end diff --git a/vendor/plugins/rspec/spec/spec/example/example_methods_spec.rb b/vendor/plugins/rspec/spec/spec/example/example_methods_spec.rb index dd33c57f0..9a6810952 100644 --- a/vendor/plugins/rspec/spec/spec/example/example_methods_spec.rb +++ b/vendor/plugins/rspec/spec/spec/example/example_methods_spec.rb @@ -1,126 +1,162 @@ -require File.dirname(__FILE__) + '/../../spec_helper' +require 'spec_helper' + +class Thing + attr_reader :arg + def initialize(arg=nil) + @arg = arg || :default + end + def ==(other) + @arg == other.arg + end + def eql?(other) + @arg == other.arg + end +end module Spec module Example - module ModuleThatIsReopened - end - - module ExampleMethods - include ModuleThatIsReopened - end + describe ExampleMethods do + module ModuleThatIsReopened; end - module ModuleThatIsReopened - def module_that_is_reopened_method + module Spec::Example::ExampleMethods + include ModuleThatIsReopened end - end - describe ExampleMethods do + module ModuleThatIsReopened + def module_that_is_reopened_method; end + end + describe "with an included module that is reopened" do - it "should have repoened methods" do + it "should have reopened methods" do method(:module_that_is_reopened_method).should_not be_nil end end - describe "lifecycle" do - before do - @original_rspec_options = $rspec_options + describe "#should" do + before(:each) do + @example_group = Class.new(ExampleGroupDouble) @options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new) - $rspec_options = @options - @options.formatters << mock("formatter", :null_object => true) - @options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true) - @reporter = FakeReporter.new(@options) - @options.reporter = @reporter - - ExampleMethods.before_all_parts.should == [] - ExampleMethods.before_each_parts.should == [] - ExampleMethods.after_each_parts.should == [] - ExampleMethods.after_all_parts.should == [] - def ExampleMethods.count - @count ||= 0 - @count = @count + 1 - @count - end end - - after do - $rspec_options = @original_rspec_options - ExampleMethods.instance_variable_set("@before_all_parts", []) - ExampleMethods.instance_variable_set("@before_each_parts", []) - ExampleMethods.instance_variable_set("@after_each_parts", []) - ExampleMethods.instance_variable_set("@after_all_parts", []) - end - - it "should pass before and after callbacks to all ExampleGroup subclasses" do - ExampleMethods.before(:suite) do - ExampleMethods.count.should == 1 - end - - ExampleMethods.before(:all) do - ExampleMethods.count.should == 2 - end - - ExampleMethods.before(:each) do - ExampleMethods.count.should == 3 + + context "in an ExampleGroup with an implicit subject" do + it "delegates matcher to the implied subject" do + @example_group.describe(::Thing) + @example_group.example { should == ::Thing.new(:default) } + @example_group.example { should eql(::Thing.new(:default)) } + @example_group.run(@options).should be_true end - - ExampleMethods.after(:each) do - ExampleMethods.count.should == 4 - end - - ExampleMethods.after(:all) do - ExampleMethods.count.should == 5 - end - - ExampleMethods.after(:suite) do - ExampleMethods.count.should == 6 + end + + context "in an ExampleGroup using an explicit subject" do + it "delegates matcher to the declared subject" do + @example_group.describe(::Thing) + @example_group.subject { ::Thing.new(:other) } + @example_group.example { should == ::Thing.new(:other) } + @example_group.example { should eql(::Thing.new(:other)) } + @example_group.run(@options).should be_true end - - @example_group = Class.new(ExampleGroup) do - it "should use ExampleMethods callbacks" do + end + + context "in an ExampleGroup using 'self' as an explicit subject" do + it "delegates matcher to the ExampleGroup" do + @example_group.describe(::Thing) + @example_group.subject { self } + @example_group.example { should == self } + @example_group.example { should eql(self) } + @example_group.example do + self.instance_eval("def method_ok?; true end") + should be_method_ok end + @example_group.run(@options).should be_true end - @options.run_examples - ExampleMethods.count.should == 7 end + end - describe "run_with_description_capturing" do - before(:each) do - @example_group = Class.new(ExampleGroup) do end - @example = @example_group.new("foo", &(lambda { 2.should == 2 })) - @example.run_with_description_capturing - end + describe "#should_not" do + before(:each) do + @example_group = Class.new(ExampleGroupDouble) + @options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new) + end - it "should provide the generated description" do - @example.instance_eval { @_matcher_description }.should == "should == 2" + context "in an ExampleGroup with an implicit subject" do + it "delegates matcher to the implied subject" do + @example_group.describe(::Thing) + @example_group.example { should_not == ::Thing.new(:other) } + @example_group.example { should_not eql(::Thing.new(:other)) } + @example_group.run(@options).should be_true end - - it "should clear the global generated_description" do - Spec::Matchers.generated_description.should == nil + end + + context "in an ExampleGroup using an explicit subject" do + it "delegates matcher to the declared subject" do + @example_group.describe(::Thing) + @example_group.subject { ::Thing.new(:other) } + @example_group.example { should_not == ::Thing.new(:default) } + @example_group.example { should_not eql(::Thing.new(:default)) } + @example_group.run(@options).should be_true end end - end - - describe "#implementation_backtrace" do - it "returns the backtrace of where the implementation was defined" do - example_group = Class.new(ExampleGroup) do - it "should use ExampleMethods callbacks" do + + context "in an ExampleGroup using 'self' as an explicit subject" do + it "delegates matcher to the ExampleGroup" do + @example_group.describe(::Thing) + @example_group.subject { self } + @example_group.example { should_not == ::Thing.new(:default) } + @example_group.example { should_not eql(::Thing.new(:default)) } + @example_group.example do + self.instance_eval("def method_ok?; false end") + should_not be_method_ok end + @example_group.run(@options).should be_true end - example = example_group.examples.first - example.implementation_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-4}") end end + end - describe "#__full_description" do - it "should return the full description of the ExampleGroup and Example" do - example_group = Class.new(ExampleGroup).describe("An ExampleGroup") do - it "should do something" do - end - end - example = example_group.examples.first - example.__full_description.should == "An ExampleGroup should do something" - end + describe "#options" do + it "should expose the options hash" do + example = ExampleGroupDouble.new ExampleProxy.new("name", :this => 'that') do; end + example.options[:this].should == 'that' + end + end + + describe "#set_instance_variables_from_hash" do + it "preserves the options" do + example = ExampleGroupDouble.new ExampleProxy.new("name", :this => 'that') do; end + example.set_instance_variables_from_hash({:@_options => {}}) + example.options[:this].should == 'that' + end + end + + describe "#description" do + it "returns the supplied description" do + example = ExampleGroupDouble.new ExampleProxy.new("name") do; end + example.description.should == "name" + end + it "returns the generated description if there is no description supplied" do + example = ExampleGroupDouble.new ExampleProxy.new do; end + Spec::Matchers.stub!(:generated_description).and_return('this message') + example.description.should == "this message" + end + it "warns if there is no supplied or generated description" do + example = ExampleGroupDouble.new ExampleProxy.new(nil, {}, "this backtrace") do; end + Spec::Matchers.stub!(:generated_description).and_return(nil) + Spec.should_receive(:warn).with("No description supplied for example declared on this backtrace") + example.description + end + end + + describe "#expect" do + it "aliases #should with #to on the proc" do + a = 3 + expect { a += 1 }.to change{a}.from(3).to(4) + end + + it "aliases #should_not with #to_not on the proc" do + a = 3 + expect { nil }.to_not change{a} end end + end -end
\ No newline at end of file +end diff --git a/vendor/plugins/rspec/spec/spec/example/example_runner_spec.rb b/vendor/plugins/rspec/spec/spec/example/example_runner_spec.rb deleted file mode 100644 index 1b5abdf0f..000000000 --- a/vendor/plugins/rspec/spec/spec/example/example_runner_spec.rb +++ /dev/null @@ -1,194 +0,0 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' - -module Spec - module Example - # describe "Spec::Example::ExampleRunner", "#run", :shared => true do - # before(:each) do - # @options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new) - # @reporter = ::Spec::Runner::Reporter.new(@options) - # @options.reporter = @reporter - # @example_group_class = Class.new(ExampleGroup) do - # plugin_mock_framework - # describe("Some Examples") - # end - # end - # - # def create_runner(example_definition) - # example = @example_group_class.new(example_definition) - # runner = ExampleGroup.new(@options, example) - # runner.stub!(:verify_mocks) - # runner.stub!(:teardown_mocks) - # runner - # end - # end - # - # describe ExampleRunner, "#run with blank passing example" do - # it_should_behave_like "Spec::Example::ExampleRunner#run" - # - # before do - # @e = @example_group_class.it("example") {} - # @runner = create_runner(@e) - # end - # - # it "should send reporter example_started" do - # @reporter.should_receive(:example_started).with(equal(@e)) - # @runner.run - # end - # - # it "should report its name for dry run" do - # @options.dry_run = true - # @reporter.should_receive(:example_finished).with(equal(@e), nil) - # @runner.run - # end - # - # it "should report success" do - # @reporter.should_receive(:example_finished).with(equal(@e), nil) - # @runner.run - # end - # end - # - # describe ExampleRunner, "#run with a failing example" do - # predicate_matchers[:is_a] = [:is_a?] - # it_should_behave_like "Spec::Example::ExampleRunner#run" - # - # before do - # @e = @example_group_class.it("example") do - # (2+2).should == 5 - # end - # @runner = create_runner(@e) - # end - # - # it "should report failure due to failure" do - # @reporter.should_receive(:example_finished).with( - # equal(@e), - # is_a(Spec::Expectations::ExpectationNotMetError) - # ) - # @runner.run - # end - # end - # - # describe ExampleRunner, "#run with a erroring example" do - # it_should_behave_like "Spec::Example::ExampleRunner#run" - # - # before do - # @error = error = NonStandardError.new("in body") - # @example_definition = @example_group_class.it("example") do - # raise(error) - # end - # @runner = create_runner(@example_definition) - # end - # - # it "should report failure due to error" do - # @reporter.should_receive(:example_finished).with( - # equal(@example_definition), - # @error - # ) - # @runner.run - # end - # - # it "should run after_each block" do - # @example_group_class.after(:each) do - # raise("in after_each") - # end - # @reporter.should_receive(:example_finished) do |example_definition, error| - # example_definition.should equal(@example_definition) - # error.message.should eql("in body") - # end - # @runner.run - # end - # end - # - # describe ExampleRunner, "#run where after_each fails" do - # it_should_behave_like "Spec::Example::ExampleRunner#run" - # - # before do - # @example_ran = example_ran = false - # @example_definition = @example_group_class.it("should not run") do - # example_ran = true - # end - # @runner = create_runner(@example_definition) - # @example_group_class.after(:each) { raise(NonStandardError.new("in after_each")) } - # end - # - # it "should report failure location when in after_each" do - # @reporter.should_receive(:example_finished) do |example_definition, error| - # example_definition.should equal(@example_definition) - # error.message.should eql("in after_each") - # end - # @runner.run - # end - # end - # - # describe ExampleRunner, "#run with use cases" do - # predicate_matchers[:is_a] = [:is_a?] - # it_should_behave_like "Spec::Example::ExampleRunner#run" - # - # it "should report NO NAME when told to use generated description with --dry-run" do - # @options.dry_run = true - # example_definition = @example_group_class.it() do - # 5.should == 5 - # end - # runner = create_runner(example_definition) - # - # @reporter.should_receive(:example_finished) do |example_definition, error| - # example_definition.description.should == "NO NAME (Because of --dry-run)" - # end - # runner.run - # end - # - # it "should report given name if present with --dry-run" do - # @options.dry_run = true - # example_definition = @example_group_class.it("example name") do - # 5.should == 5 - # end - # runner = create_runner(example_definition) - # - # @reporter.should_receive(:example_finished) do |example_definition, error| - # example_definition.description.should == "example name" - # end - # runner.run - # end - # - # it "should report NO NAME when told to use generated description with no expectations" do - # example_definition = @example_group_class.it() {} - # runner = create_runner(example_definition) - # @reporter.should_receive(:example_finished) do |example, error| - # example.description.should == "NO NAME (Because there were no expectations)" - # end - # runner.run - # end - # - # it "should report NO NAME when told to use generated description and matcher fails" do - # example_definition = @example_group_class.it() do - # 5.should "" # Has no matches? method.. - # end - # runner = create_runner(example_definition) - # - # @reporter.should_receive(:example_finished) do |example, error| - # example_definition.description.should == "NO NAME (Because of Error raised in matcher)" - # end - # runner.run - # end - # - # it "should report generated description when told to and it is available" do - # example_definition = @example_group_class.it() { - # 5.should == 5 - # } - # runner = create_runner(example_definition) - # - # @reporter.should_receive(:example_finished) do |example_definition, error| - # example_definition.description.should == "should == 5" - # end - # runner.run - # end - # - # it "should unregister description_generated callback (lest a memory leak should build up)" do - # example_definition = @example_group_class.it("something") - # runner = create_runner(example_definition) - # - # Spec::Matchers.should_receive(:example_finished) - # runner.run - # end - # end - end -end diff --git a/vendor/plugins/rspec/spec/spec/example/example_spec.rb b/vendor/plugins/rspec/spec/spec/example/example_spec.rb deleted file mode 100644 index c8125b447..000000000 --- a/vendor/plugins/rspec/spec/spec/example/example_spec.rb +++ /dev/null @@ -1,53 +0,0 @@ -require File.dirname(__FILE__) + '/../../spec_helper' - -module Spec - module Example - # describe Example do - # before(:each) do - # @example = Example.new "example" do - # foo - # end - # end - # - # it "should tell you its docstring" do - # @example.description.should == "example" - # end - # - # it "should execute its block in the context provided" do - # context = Class.new do - # def foo - # "foo" - # end - # end.new - # @example.run_in(context).should == "foo" - # end - # end - # - # describe Example, "#description" do - # it "should default to NO NAME when not passed anything when there are no matchers" do - # example = Example.new {} - # example.run_in(Object.new) - # example.description.should == "NO NAME" - # end - # - # it "should default to NO NAME description (Because of --dry-run) when passed nil and there are no matchers" do - # example = Example.new(nil) {} - # example.run_in(Object.new) - # example.description.should == "NO NAME" - # end - # - # it "should allow description to be overridden" do - # example = Example.new("Test description") - # example.description.should == "Test description" - # end - # - # it "should use description generated from matcher when there is no passed in description" do - # example = Example.new(nil) do - # 1.should == 1 - # end - # example.run_in(Object.new) - # example.description.should == "should == 1" - # end - # end - end -end diff --git a/vendor/plugins/rspec/spec/spec/example/nested_example_group_spec.rb b/vendor/plugins/rspec/spec/spec/example/nested_example_group_spec.rb index 559467d6d..83e4a9d7c 100644 --- a/vendor/plugins/rspec/spec/spec/example/nested_example_group_spec.rb +++ b/vendor/plugins/rspec/spec/spec/example/nested_example_group_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper' +require 'spec_helper' module Spec module Example @@ -58,12 +58,12 @@ module Spec describe "Nested Example Groups" do describe "description options", :other_options => "other options" do - it "should have a spec_path" do - self.class.description_options[:spec_path].should match(/#{__FILE__}/) + it "includes :location" do + self.class.options[:location].should match(/#{__FILE__}/) end - it "should pass other options" do - self.class.description_options[:other_options].should == "other options" + it "includes any other options" do + self.class.options[:other_options].should == "other options" end end end diff --git a/vendor/plugins/rspec/spec/spec/example/pending_module_spec.rb b/vendor/plugins/rspec/spec/spec/example/pending_module_spec.rb index c3ab0126b..275abc7d6 100644 --- a/vendor/plugins/rspec/spec/spec/example/pending_module_spec.rb +++ b/vendor/plugins/rspec/spec/spec/example/pending_module_spec.rb @@ -2,29 +2,56 @@ module Spec module Example describe Pending do - it 'should raise an ExamplePendingError if no block is supplied' do - lambda { - include Pending - pending "TODO" - }.should raise_error(ExamplePendingError, /TODO/) + context "when no block is supplied" do + it "raises an ExamplePendingError if no block is supplied" do + lambda { + pending "TODO" + }.should raise_error(ExamplePendingError, /TODO/) + end end - it 'should raise an ExamplePendingError if a supplied block fails as expected' do - lambda { - include Pending - pending "TODO" do - raise "oops" - end - }.should raise_error(ExamplePendingError, /TODO/) + context "when the supplied block fails" do + it "raises an ExamplePendingError if a supplied block fails as expected" do + lambda { + pending "TODO" do + raise "oops" + end + }.should raise_error(ExamplePendingError, /TODO/) + end end - it 'should raise a PendingExampleFixedError if a supplied block starts working' do - lambda { - include Pending - pending "TODO" do - # success! - end - }.should raise_error(PendingExampleFixedError, /TODO/) + context "when the supplied block fails with a mock" do + it "raises an ExamplePendingError if a supplied block fails as expected with a mock" do + lambda { + pending "TODO" do + m = mock("thing") + m.should_receive(:foo) + m.rspec_verify + end + }.should raise_error(ExamplePendingError, /TODO/) + end + end + + context "when the supplied block passes" do + it "raises a PendingExampleFixedError" do + lambda { + pending "TODO" do + # success! + end + }.should raise_error(PendingExampleFixedError, /TODO/) + end + end + end + + describe ExamplePendingError do + it "should have the message provided" do + ExamplePendingError.new("a message").message.should == "a message" + end + end + + describe NotYetImplementedError do + it "should have the message 'Not Yet Implemented'" do + NotYetImplementedError.new.message.should == "Not Yet Implemented" end end end diff --git a/vendor/plugins/rspec/spec/spec/example/predicate_matcher_spec.rb b/vendor/plugins/rspec/spec/spec/example/predicate_matcher_spec.rb index 7c4638b4b..a01858502 100644 --- a/vendor/plugins/rspec/spec/spec/example/predicate_matcher_spec.rb +++ b/vendor/plugins/rspec/spec/spec/example/predicate_matcher_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper' +require 'spec_helper' module Spec module Example @@ -9,12 +9,32 @@ module Spec end describe "predicate_matcher[method_on_object] = matcher_method" do - predicate_matchers[:swim] = :can_swim? + before(:each) do + Spec.stub!(:deprecate) + end + + it "is deprecated" do + Spec.should_receive(:deprecate) + group = ExampleGroupDouble.describe("foo") do + predicate_matchers[:swim] = :can_swim? + end + group.run(Spec::Runner::Options.new(StringIO.new, StringIO.new)) + end + it "should match matcher_method if method_on_object returns true" do - swim(100).matches?(Fish.new).should be_true + group = ExampleGroupDouble.describe(Fish) do + predicate_matchers[:swim] = :can_swim? + it { should swim(100) } + end + group.run(Spec::Runner::Options.new(StringIO.new, StringIO.new)) end + it "should not match matcher_method if method_on_object returns false" do - swim(10000).matches?(Fish.new).should be_false + group = ExampleGroupDouble.describe(Fish) do + predicate_matchers[:swim] = :can_swim? + it { should_not swim(1000) } + end + group.run(Spec::Runner::Options.new(StringIO.new, StringIO.new)) end end end diff --git a/vendor/plugins/rspec/spec/spec/example/shared_example_group_spec.rb b/vendor/plugins/rspec/spec/spec/example/shared_example_group_spec.rb index 803536ab5..bbebbf15c 100644 --- a/vendor/plugins/rspec/spec/spec/example/shared_example_group_spec.rb +++ b/vendor/plugins/rspec/spec/spec/example/shared_example_group_spec.rb @@ -1,264 +1,256 @@ -require File.dirname(__FILE__) + '/../../spec_helper' +require 'spec_helper' module Spec module Example describe ExampleGroup, "with :shared => true" do - it_should_behave_like "sandboxed rspec_options" - attr_reader :formatter, :example_group - before(:each) do - @formatter = Spec::Mocks::Mock.new("formatter", :null_object => true) - options.formatters << formatter - @example_group = Class.new(ExampleGroup).describe("example_group") - class << example_group - public :include + with_sandboxed_options do + attr_reader :formatter, :example_group + before(:each) do + @formatter = Spec::Mocks::Mock.new("formatter", :null_object => true) + options.formatters << formatter + @example_group = Class.new(ExampleGroupDouble).describe("example_group") + class << example_group + public :include + end end - end - - after(:each) do - @formatter.rspec_verify - @example_group = nil - $shared_example_groups.clear unless $shared_example_groups.nil? - end - - def make_shared_example_group(name, opts=nil, &block) - example_group = SharedExampleGroup.new(name, :shared => true, &block) - SharedExampleGroup.add_shared_example_group(example_group) - example_group - end - - def non_shared_example_group() - @non_shared_example_group ||= Class.new(ExampleGroup).describe("example_group") - end - - it "should accept an optional options hash" do - lambda { Class.new(ExampleGroup).describe("context") }.should_not raise_error(Exception) - lambda { Class.new(ExampleGroup).describe("context", :shared => true) }.should_not raise_error(Exception) - end - it "should return all shared example_groups" do - b1 = make_shared_example_group("b1", :shared => true) {} - b2 = make_shared_example_group("b2", :shared => true) {} + after(:each) do + @formatter.rspec_verify + @example_group = nil + Spec::Example::SharedExampleGroup.clear + end + + describe "#register" do + it "creates a new shared example group with the submitted args" do + block = lambda {|a|} + group = SharedExampleGroup.new("shared group") do end + Spec::Example::SharedExampleGroup.should_receive(:new).with("share me", &block).and_return(group) + Spec::Example::SharedExampleGroup.register("share me", &block) + end - b1.should_not be(nil) - b2.should_not be(nil) + it "registers the shared example group" do + lambda do + Spec::Example::SharedExampleGroup.register "share me" do end + end.should change {Spec::Example::SharedExampleGroup.count}.by(1) + end + end - SharedExampleGroup.find_shared_example_group("b1").should equal(b1) - SharedExampleGroup.find_shared_example_group("b2").should equal(b2) - end + it "complains when adding a second shared example_group with the same description" do + describe "shared example_group", :shared => true do + end + lambda do + describe "shared example_group", :shared => true do + end + end.should raise_error(ArgumentError) + end + + it "does NOT add the same group twice" do + lambda do + 2.times do + describe "shared example_group which gets loaded twice", :shared => true do + end + end + end.should change {Spec::Example::SharedExampleGroup.count}.by(1) + end - it "should register as shared example_group" do - example_group = make_shared_example_group("example_group") {} - SharedExampleGroup.shared_example_groups.should include(example_group) - end + it "does NOT complain when adding the same shared example_group again (i.e. file gets reloaded)" do + lambda do + 2.times do + describe "shared example_group which gets loaded twice", :shared => true do + end + end + end.should_not raise_error(ArgumentError) + end - it "should not be shared when not configured as shared" do - example_group = non_shared_example_group - SharedExampleGroup.shared_example_groups.should_not include(example_group) - end + it "does NOT complain when adding the same shared example_group in same file with different absolute path" do + SharedExampleGroup.register( + "shared example_group", + :shared => true, + :location => "/my/spec/a/../shared.rb" + ) + SharedExampleGroup.register( + "shared example_group", + :shared => true, + :location => "/my/spec/b/../shared.rb" + ) + end - it "should complain when adding a second shared example_group with the same description" do - describe "shared example_group", :shared => true do + it "complains when adding a different shared example_group with the same name in a different file with the same basename" do + SharedExampleGroup.register( + "shared example_group", + :shared => true, + :location => "/my/spec/a/shared.rb" + ) + lambda do + SharedExampleGroup.register( + "shared example_group", + :shared => true, + :location => "/my/spec/b/shared.rb" + ) + end.should raise_error(ArgumentError, /already exists/) end - lambda do - describe "shared example_group", :shared => true do + + it "adds examples to current example_group using it_should_behave_like" do + shared_example_group = SharedExampleGroup.register("shared example_group") do + it("shared example") {} + it("shared example 2") {} end - end.should raise_error(ArgumentError) - end - it "should NOT complain when adding the same shared example_group instance again" do - shared_example_group = Class.new(ExampleGroup).describe("shared example_group", :shared => true) - SharedExampleGroup.add_shared_example_group(shared_example_group) - SharedExampleGroup.add_shared_example_group(shared_example_group) - end + example_group.it("example") {} + example_group.number_of_examples.should == 1 + example_group.it_should_behave_like("shared example_group") + example_group.number_of_examples.should == 3 + end - it "should NOT complain when adding the same shared example_group again (i.e. file gets reloaded)" do - lambda do - 2.times do - describe "shared example_group which gets loaded twice", :shared => true do - end + it "adds examples to from two shared groups" do + shared_example_group_1 = SharedExampleGroup.register("shared example_group 1") do + it("shared example 1") {} end - end.should_not raise_error(ArgumentError) - end - - it "should NOT complain when adding the same shared example_group in same file with different absolute path" do - shared_example_group_1 = Class.new(ExampleGroup).describe( - "shared example_group", - :shared => true, - :spec_path => "/my/spec/a/../shared.rb" - ) - shared_example_group_2 = Class.new(ExampleGroup).describe( - "shared example_group", - :shared => true, - :spec_path => "/my/spec/b/../shared.rb" - ) - - SharedExampleGroup.add_shared_example_group(shared_example_group_1) - SharedExampleGroup.add_shared_example_group(shared_example_group_2) - end - it "should complain when adding a different shared example_group with the same name in a different file with the same basename" do - shared_example_group_1 = Class.new(ExampleGroup).describe( - "shared example_group", - :shared => true, - :spec_path => "/my/spec/a/shared.rb" - ) - shared_example_group_2 = Class.new(ExampleGroup).describe( - "shared example_group", - :shared => true, - :spec_path => "/my/spec/b/shared.rb" - ) - - SharedExampleGroup.add_shared_example_group(shared_example_group_1) - lambda do - SharedExampleGroup.add_shared_example_group(shared_example_group_2) - end.should raise_error(ArgumentError, /already exists/) - end + shared_example_group_1 = SharedExampleGroup.register("shared example_group 2") do + it("shared example 2") {} + end - it "should add examples to current example_group using it_should_behave_like" do - shared_example_group = make_shared_example_group("shared example_group") do - it("shared example") {} - it("shared example 2") {} + example_group.it("example") {} + example_group.number_of_examples.should == 1 + example_group.it_should_behave_like("shared example_group 1", "shared example_group 2") + example_group.number_of_examples.should == 3 end - example_group.it("example") {} - example_group.number_of_examples.should == 1 - example_group.it_should_behave_like("shared example_group") - example_group.number_of_examples.should == 3 - end - - it "should add examples to current example_group using include" do - shared_example_group = describe "all things", :shared => true do - it "should do stuff" do end - end + it "adds examples to current example_group using include" do + shared_example_group = describe "all things", :shared => true do + it "should do stuff" do end + end - example_group = describe "one thing" do - include shared_example_group - end + example_group = describe "one thing" do + include shared_example_group + end - example_group.number_of_examples.should == 1 - end - - it "should add examples to current example_group using it_should_behave_like with a module" do - AllThings = describe "all things", :shared => true do - it "should do stuff" do end + example_group.number_of_examples.should == 1 end + + it "adds examples to current example_group using it_should_behave_like with a module" do + ::AllThings = describe "all things", :shared => true do + it "should do stuff" do end + end - example_group = describe "one thing" do - it_should_behave_like AllThings - end + example_group = describe "one thing" do + it_should_behave_like ::AllThings + end - example_group.number_of_examples.should == 1 - end - - it "should run shared examples" do - shared_example_ran = false - shared_example_group = make_shared_example_group("shared example_group") do - it("shared example") { shared_example_ran = true } + example_group.number_of_examples.should == 1 end - example_ran = false + it "runs shared examples" do + shared_example_ran = false + shared_example_group = SharedExampleGroup.register("shared example_group") do + it("shared example") { shared_example_ran = true } + end - example_group.it_should_behave_like("shared example_group") - example_group.it("example") {example_ran = true} - example_group.run - example_ran.should be_true - shared_example_ran.should be_true - end + example_ran = false - it "should run setup and teardown from shared example_group" do - shared_setup_ran = false - shared_teardown_ran = false - shared_example_group = make_shared_example_group("shared example_group") do - before { shared_setup_ran = true } - after { shared_teardown_ran = true } - it("shared example") { shared_example_ran = true } + example_group.it_should_behave_like("shared example_group") + example_group.it("example") {example_ran = true} + example_group.run(options) + example_ran.should be_true + shared_example_ran.should be_true end - example_ran = false + it "runs before(:each) and after(:each) from shared example_group" do + shared_setup_ran = false + shared_teardown_ran = false + shared_example_group = SharedExampleGroup.register("shared example_group") do + before(:each) { shared_setup_ran = true } + after(:each) { shared_teardown_ran = true } + it("shared example") { shared_example_ran = true } + end - example_group.it_should_behave_like("shared example_group") - example_group.it("example") {example_ran = true} - example_group.run - example_ran.should be_true - shared_setup_ran.should be_true - shared_teardown_ran.should be_true - end + example_ran = false - it "should run before(:all) and after(:all) only once from shared example_group" do - shared_before_all_run_count = 0 - shared_after_all_run_count = 0 - shared_example_group = make_shared_example_group("shared example_group") do - before(:all) { shared_before_all_run_count += 1} - after(:all) { shared_after_all_run_count += 1} - it("shared example") { shared_example_ran = true } + example_group.it_should_behave_like("shared example_group") + example_group.it("example") {example_ran = true} + example_group.run(options) + example_ran.should be_true + shared_setup_ran.should be_true + shared_teardown_ran.should be_true end - example_ran = false - - example_group.it_should_behave_like("shared example_group") - example_group.it("example") {example_ran = true} - example_group.run - example_ran.should be_true - shared_before_all_run_count.should == 1 - shared_after_all_run_count.should == 1 - end + it "should run before(:all) and after(:all) only once from shared example_group" do + shared_before_all_run_count = 0 + shared_after_all_run_count = 0 + shared_example_group = SharedExampleGroup.register("shared example_group") do + before(:all) { shared_before_all_run_count += 1} + after(:all) { shared_after_all_run_count += 1} + it("shared example") { shared_example_ran = true } + end - it "should include modules, included into shared example_group, into current example_group" do - @formatter.should_receive(:add_example_group).with(any_args) + example_ran = false - shared_example_group = make_shared_example_group("shared example_group") do - it("shared example") { shared_example_ran = true } + example_group.it_should_behave_like("shared example_group") + example_group.it("example") {example_ran = true} + example_group.run(options) + example_ran.should be_true + shared_before_all_run_count.should == 1 + shared_after_all_run_count.should == 1 end - mod1_method_called = false - mod1 = Module.new do - define_method :mod1_method do - mod1_method_called = true + it "should include modules, included into shared example_group, into current example_group" do + @formatter.should_receive(:add_example_group).with(any_args) + + shared_example_group = SharedExampleGroup.register("shared example_group") do + it("shared example") { shared_example_ran = true } end - end - mod2_method_called = false - mod2 = Module.new do - define_method :mod2_method do - mod2_method_called = true + mod1_method_called = false + mod1 = Module.new do + define_method :mod1_method do + mod1_method_called = true + end + end + + mod2_method_called = false + mod2 = Module.new do + define_method :mod2_method do + mod2_method_called = true + end end - end - shared_example_group.include mod2 + shared_example_group.__send__ :include, mod2 - example_group.it_should_behave_like("shared example_group") - example_group.include mod1 + example_group.it_should_behave_like("shared example_group") + example_group.include mod1 - example_group.it("test") do - mod1_method - mod2_method + example_group.it("test") do + mod1_method + mod2_method + end + example_group.run(options) + mod1_method_called.should be_true + mod2_method_called.should be_true end - example_group.run - mod1_method_called.should be_true - mod2_method_called.should be_true - end - it "should make methods defined in the shared example_group available in consuming example_group" do - shared_example_group = make_shared_example_group("shared example_group xyz") do - def a_shared_helper_method - "this got defined in a shared example_group" + it "should make methods defined in the shared example_group available in consuming example_group" do + shared_example_group = SharedExampleGroup.register("shared example_group xyz") do + def a_shared_helper_method + "this got defined in a shared example_group" + end end + example_group.it_should_behave_like("shared example_group xyz") + success = false + example_group.it("should access a_shared_helper_method") do + a_shared_helper_method + success = true + end + example_group.run(options) + success.should be_true end - example_group.it_should_behave_like("shared example_group xyz") - success = false - example_group.it("should access a_shared_helper_method") do - a_shared_helper_method - success = true - end - example_group.run - success.should be_true - end - it "should raise when named shared example_group can not be found" do - lambda { - example_group.it_should_behave_like("non-existent shared example group") - violated - }.should raise_error("Shared Example Group 'non-existent shared example group' can not be found") + it "should raise when named shared example_group can not be found" do + lambda { + example_group.it_should_behave_like("non-existent shared example group") + violated + }.should raise_error("Shared Example Group 'non-existent shared example group' can not be found") + end end end end diff --git a/vendor/plugins/rspec/spec/spec/example/subclassing_example_group_spec.rb b/vendor/plugins/rspec/spec/spec/example/subclassing_example_group_spec.rb index 888f2ceb3..969014a73 100644 --- a/vendor/plugins/rspec/spec/spec/example/subclassing_example_group_spec.rb +++ b/vendor/plugins/rspec/spec/spec/example/subclassing_example_group_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper' +require 'spec_helper' module Spec module Example diff --git a/vendor/plugins/rspec/spec/spec/expectations/differs/default_spec.rb b/vendor/plugins/rspec/spec/spec/expectations/differs/default_spec.rb index ba76cbd47..3bc3c45ab 100644 --- a/vendor/plugins/rspec/spec/spec/expectations/differs/default_spec.rb +++ b/vendor/plugins/rspec/spec/spec/expectations/differs/default_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../spec_helper.rb' +require 'spec_helper' module Spec module Fixtures @@ -73,6 +73,73 @@ EOD diff = @differ.diff_as_object(expected,actual) diff.should == expected_diff end + + it "should output a friendly message if comparing simple hashes" do + expected = { "foo" => "bar" } + actual = { "foo" => "baz" } + + expected_diff = <<'EOD' + +Expected the key "foo" to be "bar", but was "baz" + +EOD + + + diff = @differ.diff_as_hash(actual, expected) + diff.should == expected_diff + end + + + it "should output a friendly message if comparing simple hashes that contain different keys" do + expected = { "bar" => "foo" } + actual = { "foo" => "baz" } + + expected_diff = <<'EOD' + +Expected hash contains keys that target hash does not: ["bar"] +Target hash contains keys that expected hash does not: ["foo"] +Expected the key "bar" to be "foo", but was nil + +EOD + + + diff = @differ.diff_as_hash(actual, expected) + diff.should == expected_diff + end + + it "should output diff message if the hash is complex (containing Array or Hash)" do + expected = { "foo" => "bar", "fizz" => [1, 2, 3] } + actual = { "foo" => "baz", "fizz" => [1, 2] } + + # UGH - 1.8.7 seems to order hash keys differently than the others + if RUBY_VERSION =~ /^1.8.7/ + expected_diff = <<'EOD' + +Expected the key "fizz" to be [1, 2, 3], but was [1, 2] +Expected the key "foo" to be "bar", but was "baz" + + +@@ -1,2 +1,2 @@ +-{"fizz"=>[1, 2, 3], "foo"=>"bar"} ++{"fizz"=>[1, 2], "foo"=>"baz"} +EOD + else + expected_diff = <<'EOD' + +Expected the key "fizz" to be [1, 2, 3], but was [1, 2] +Expected the key "foo" to be "bar", but was "baz" + + +@@ -1,2 +1,2 @@ +-{"foo"=>"bar", "fizz"=>[1, 2, 3]} ++{"foo"=>"baz", "fizz"=>[1, 2]} +EOD + end + + diff = @differ.diff_as_hash(actual, expected) + diff.should == expected_diff + end + it "should output unified diff message of two objects" do expected = Spec::Fixtures::Animal.new "bob", "giraffe" diff --git a/vendor/plugins/rspec/spec/spec/expectations/extensions/object_spec.rb b/vendor/plugins/rspec/spec/spec/expectations/extensions/object_spec.rb deleted file mode 100644 index 0d9335bdb..000000000 --- a/vendor/plugins/rspec/spec/spec/expectations/extensions/object_spec.rb +++ /dev/null @@ -1,107 +0,0 @@ -require File.dirname(__FILE__) + '/../../../spec_helper.rb' - -describe Object, "#should" do - before(:each) do - @target = "target" - @matcher = mock("matcher") - @matcher.stub!(:matches?).and_return(true) - @matcher.stub!(:failure_message) - end - - it "should accept and interact with a matcher" do - @matcher.should_receive(:matches?).with(@target).and_return(true) - @target.should @matcher - end - - it "should ask for a failure_message when matches? returns false" do - @matcher.should_receive(:matches?).with(@target).and_return(false) - @matcher.should_receive(:failure_message).and_return("the failure message") - lambda { - @target.should @matcher - }.should fail_with("the failure message") - end - - it "should raise error if it receives false directly" do - lambda { - @target.should false - }.should raise_error(Spec::Expectations::InvalidMatcherError) - end - - it "should raise error if it receives false (evaluated)" do - lambda { - @target.should eql?("foo") - }.should raise_error(Spec::Expectations::InvalidMatcherError) - end - - it "should raise error if it receives true" do - lambda { - @target.should true - }.should raise_error(Spec::Expectations::InvalidMatcherError) - end - - it "should raise error if it receives nil" do - lambda { - @target.should nil - }.should raise_error(Spec::Expectations::InvalidMatcherError) - end - - it "should raise error if it receives no argument and it is not used as a left side of an operator" do - pending "Is it even possible to catch this?" - lambda { - @target.should - }.should raise_error(Spec::Expectations::InvalidMatcherError) - end -end - -describe Object, "#should_not" do - before(:each) do - @target = "target" - @matcher = mock("matcher") - end - - it "should accept and interact with a matcher" do - @matcher.should_receive(:matches?).with(@target).and_return(false) - @matcher.stub!(:negative_failure_message) - - @target.should_not @matcher - end - - it "should ask for a negative_failure_message when matches? returns true" do - @matcher.should_receive(:matches?).with(@target).and_return(true) - @matcher.should_receive(:negative_failure_message).and_return("the negative failure message") - lambda { - @target.should_not @matcher - }.should fail_with("the negative failure message") - end - - it "should raise error if it receives false directly" do - lambda { - @target.should_not false - }.should raise_error(Spec::Expectations::InvalidMatcherError) - end - - it "should raise error if it receives false (evaluated)" do - lambda { - @target.should_not eql?("foo") - }.should raise_error(Spec::Expectations::InvalidMatcherError) - end - - it "should raise error if it receives true" do - lambda { - @target.should_not true - }.should raise_error(Spec::Expectations::InvalidMatcherError) - end - - it "should raise error if it receives nil" do - lambda { - @target.should_not nil - }.should raise_error(Spec::Expectations::InvalidMatcherError) - end - - it "should raise error if it receives no argument and it is not used as a left side of an operator" do - pending "Is it even possible to catch this?" - lambda { - @target.should_not - }.should raise_error(Spec::Expectations::InvalidMatcherError) - end -end diff --git a/vendor/plugins/rspec/spec/spec/expectations/fail_with_spec.rb b/vendor/plugins/rspec/spec/spec/expectations/fail_with_spec.rb index 4c369ce3a..639b7f950 100644 --- a/vendor/plugins/rspec/spec/spec/expectations/fail_with_spec.rb +++ b/vendor/plugins/rspec/spec/spec/expectations/fail_with_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' describe Spec::Expectations, "#fail_with with no diff" do before(:each) do @@ -12,17 +12,24 @@ describe Spec::Expectations, "#fail_with with no diff" do }.should fail_with("the message") end - it "should handle an Array" do - lambda { - Spec::Expectations.fail_with ["the message","expected","actual"] - }.should fail_with("the message") - end - after(:each) do Spec::Expectations.differ = @old_differ end end +describe Spec::Expectations, "#fail_with with Array" do + before(:each) do + Spec.stub!(:warn) + end + + it "is deprecated" do + Spec.should_receive(:warn) + lambda { + Spec::Expectations.fail_with ["message", "expected", "actual"] + }.should raise_error + end +end + describe Spec::Expectations, "#fail_with with diff" do before(:each) do @old_differ = Spec::Expectations.differ @@ -40,31 +47,49 @@ describe Spec::Expectations, "#fail_with with diff" do @differ.should_receive(:diff_as_string).and_return("diff") lambda { Spec::Expectations.fail_with "the message", "expected", "actual" - }.should fail_with("the message\nDiff:diff") + }.should fail_with("the message\n\n Diff:diff") end it "should call differ if expected/actual are not strings" do @differ.should_receive(:diff_as_object).and_return("diff") lambda { Spec::Expectations.fail_with "the message", :expected, :actual - }.should fail_with("the message\nDiff:diff") + }.should fail_with("the message\n\n Diff:diff") + end + + it "should call differ if expected/actual are both hashes" do + @differ.should_receive(:diff_as_hash).and_return("diff") + lambda { + Spec::Expectations.fail_with "the message", {:a => :b}, {:a => 'b'} + }.should fail_with("the message\n\n Diff:diff") end it "should not call differ if expected or actual are procs" do @differ.should_not_receive(:diff_as_string) @differ.should_not_receive(:diff_as_object) + @differ.should_not_receive(:diff_as_hash) lambda { Spec::Expectations.fail_with "the message", lambda {}, lambda {} }.should fail_with("the message") end - - it "should call differ if expected/actual are presented in an Array with message" do - @differ.should_receive(:diff_as_string).with("actual","expected").and_return("diff") + + after(:each) do + Spec::Expectations.differ = @old_differ + end +end + +describe Spec::Expectations, "#fail_with with a nil message" do + before(:each) do + @old_differ = Spec::Expectations.differ + Spec::Expectations.differ = nil + end + + it "should handle just a message" do lambda { - Spec::Expectations.fail_with(["the message", "expected", "actual"]) - }.should fail_with(/the message\nDiff:diff/) + Spec::Expectations.fail_with nil + }.should raise_error(ArgumentError, /Failure message is nil\. Does your matcher define the appropriate failure_message_for_\* method to return a string\?/) end - + after(:each) do Spec::Expectations.differ = @old_differ end diff --git a/vendor/plugins/rspec/spec/spec/extensions/main_spec.rb b/vendor/plugins/rspec/spec/spec/extensions/main_spec.rb deleted file mode 100644 index aabb616e9..000000000 --- a/vendor/plugins/rspec/spec/spec/extensions/main_spec.rb +++ /dev/null @@ -1,76 +0,0 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' - -module Spec - module Extensions - describe Main do - it_should_behave_like "sandboxed rspec_options" - before(:each) do - @main = Class.new do; include Main; end - end - - after(:each) do - $rspec_story_steps = @original_rspec_story_steps - end - - it "should create an Options object" do - @main.send(:rspec_options).should be_instance_of(Spec::Runner::Options) - @main.send(:rspec_options).should === $rspec_options - end - - specify {@main.should respond_to(:describe)} - specify {@main.should respond_to(:context)} - - it "should raise when no block given to describe" do - lambda { @main.describe "foo" }.should raise_error(ArgumentError) - end - - it "should raise when no description given to describe" do - lambda { @main.describe do; end }.should raise_error(ArgumentError) - end - - it "should registered ExampleGroups by default" do - example_group = @main.describe("The ExampleGroup") do end - rspec_options.example_groups.should include(example_group) - end - - it "should not run unregistered ExampleGroups" do - example_group = @main.describe("The ExampleGroup") do - unregister - end - - rspec_options.example_groups.should_not include(example_group) - end - - it "should create a shared ExampleGroup with share_examples_for" do - group = @main.share_examples_for "all things" do end - group.should be_an_instance_of(Spec::Example::SharedExampleGroup) - end - - describe "#share_as" do - before(:each) do - $share_as_examples_example_module_number ||= 1 - $share_as_examples_example_module_number += 1 - t = Time.new.to_i - @group_name = "Group#{$share_as_examples_example_module_number}" - end - - it "should create a shared ExampleGroup" do - group = @main.share_as @group_name do end - group.should be_an_instance_of(Spec::Example::SharedExampleGroup) - end - - it "should create a constant that points to a Module" do - group = @main.share_as @group_name do end - Object.const_get(@group_name).should equal(group) - end - - it "should bark if you pass it something not-constantizable" do - lambda do - @group = @main.share_as "Non Constant" do end - end.should raise_error(NameError, /The first argument to share_as must be a legal name for a constant/) - end - - end - end - end -end
\ No newline at end of file diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_that_fails.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_that_fails.rb index d6f5564bf..b2c484109 100644 --- a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_that_fails.rb +++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_that_fails.rb @@ -1,7 +1,7 @@ rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib" $:.unshift rspec_lib unless $:.include?(rspec_lib) -require 'test/unit' -require 'spec' +require 'spec/autorun' +require 'spec/test/unit' describe "example group with failures" do it "should fail" do diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_that_passes.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_that_passes.rb index ccd2488bc..4203af3a5 100644 --- a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_that_passes.rb +++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_that_passes.rb @@ -1,7 +1,7 @@ rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib" $:.unshift rspec_lib unless $:.include?(rspec_lib) -require 'test/unit' -require 'spec' +require 'spec/autorun' +require 'spec/test/unit' describe "example group with passing examples" do it "should pass" do diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_with_errors.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_with_errors.rb index 71427dbaa..a18ce72f7 100644 --- a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_with_errors.rb +++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_with_errors.rb @@ -1,7 +1,7 @@ rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib" $:.unshift rspec_lib unless $:.include?(rspec_lib) -require 'test/unit' -require 'spec' +require 'spec/autorun' +require 'spec/test/unit' describe "example group with errors" do it "should raise errors" do diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_that_fails.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_that_fails.rb index 3fb6515a8..0a977cb15 100644 --- a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_that_fails.rb +++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_that_fails.rb @@ -1,7 +1,7 @@ rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib" $:.unshift rspec_lib unless $:.include?(rspec_lib) -require 'test/unit' -require 'spec' +require 'spec/autorun' +require 'spec/test/unit' class TestCaseThatFails < Test::Unit::TestCase def test_that_fails diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_that_passes.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_that_passes.rb index 69239c0b5..078a5f778 100644 --- a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_that_passes.rb +++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_that_passes.rb @@ -1,7 +1,7 @@ rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib" $:.unshift rspec_lib unless $:.include?(rspec_lib) -require 'test/unit' -require 'spec' +require 'spec/autorun' +require 'spec/test/unit' class TestCaseThatPasses < Test::Unit::TestCase def test_that_passes diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_with_errors.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_with_errors.rb index 35dcb6b2e..dc5f52e47 100644 --- a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_with_errors.rb +++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_with_errors.rb @@ -1,7 +1,7 @@ rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib" $:.unshift rspec_lib unless $:.include?(rspec_lib) -require 'test/unit' -require 'spec' +require 'spec/autorun' +require 'spec/test/unit' class TestCaseWithErrors < Test::Unit::TestCase def test_with_error diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb index 0c2167a99..5182b8203 100644 --- a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb +++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb @@ -1,7 +1,7 @@ rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib" $:.unshift rspec_lib unless $:.include?(rspec_lib) -require "test/unit" -require "spec" +require 'spec/autorun' +require 'spec/test/unit' module Test module Unit diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/spec_spec.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/spec_spec.rb index 8a1e1300c..83ff52264 100644 --- a/vendor/plugins/rspec/spec/spec/interop/test/unit/spec_spec.rb +++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/spec_spec.rb @@ -1,45 +1,48 @@ -require File.dirname(__FILE__) + '/test_unit_spec_helper' +require 'spec/interop/test/unit/test_unit_spec_helper' describe "ExampleGroup with test/unit/interop" do include TestUnitSpecHelper - - before(:each) do - @dir = File.dirname(__FILE__) + "/resources" - end - + describe "with passing examples" do it "should output 0 failures" do - output = ruby("#{@dir}/spec_that_passes.rb") + output = ruby("#{resources}/spec_that_passes.rb") output.should include("1 example, 0 failures") end it "should return an exit code of 0" do - ruby("#{@dir}/spec_that_passes.rb") + ruby("#{resources}/spec_that_passes.rb") $?.should == 0 end end describe "with failing examples" do it "should output 1 failure" do - output = ruby("#{@dir}/spec_that_fails.rb") + output = ruby("#{resources}/spec_that_fails.rb") output.should include("1 example, 1 failure") end it "should return an exit code of 256" do - ruby("#{@dir}/spec_that_fails.rb") + ruby("#{resources}/spec_that_fails.rb") $?.should == 256 end end describe "with example that raises an error" do it "should output 1 failure" do - output = ruby("#{@dir}/spec_with_errors.rb") + output = ruby("#{resources}/spec_with_errors.rb") output.should include("1 example, 1 failure") end it "should return an exit code of 256" do - ruby("#{@dir}/spec_with_errors.rb") + ruby("#{resources}/spec_with_errors.rb") $?.should == 256 end end + + describe "options hash" do + it "should be exposed" do + output = ruby("#{resources}/spec_with_options_hash.rb") + output.should include("1 example, 0 failures") + end + end end
\ No newline at end of file diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/test_unit_spec_helper.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/test_unit_spec_helper.rb index 04d5d2713..1f6c223eb 100644 --- a/vendor/plugins/rspec/spec/spec/interop/test/unit/test_unit_spec_helper.rb +++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/test_unit_spec_helper.rb @@ -1,8 +1,12 @@ -require File.dirname(__FILE__) + '/../../../../spec_helper' -require File.dirname(__FILE__) + '/../../../../ruby_forker' +require 'spec_helper' +require 'ruby_forker' module TestUnitSpecHelper include RubyForker + + def resources + File.dirname(__FILE__) + "/resources" + end def run_script(file_name) output = ruby(file_name) diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/testcase_spec.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/testcase_spec.rb index f40111a58..c1b252609 100644 --- a/vendor/plugins/rspec/spec/spec/interop/test/unit/testcase_spec.rb +++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/testcase_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_unit_spec_helper' +require 'spec/interop/test/unit/test_unit_spec_helper' describe "Test::Unit::TestCase" do include TestUnitSpecHelper @@ -42,4 +42,9 @@ describe "Test::Unit::TestCase" do $?.should == 256 end end -end
\ No newline at end of file + + it "should find all Test::Unit test methods" do + output = ruby("#{@dir}/test_case_with_various_names.rb") + output.should include("4 examples, 0 failures") + end +end diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/testsuite_adapter_spec.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/testsuite_adapter_spec.rb index 722126bc9..59743039a 100644 --- a/vendor/plugins/rspec/spec/spec/interop/test/unit/testsuite_adapter_spec.rb +++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/testsuite_adapter_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_unit_spec_helper' +require 'spec/interop/test/unit/test_unit_spec_helper' describe "TestSuiteAdapter" do include TestUnitSpecHelper diff --git a/vendor/plugins/rspec/spec/spec/matchers/be_close_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/be_close_spec.rb index d8452d408..cc0e5bd44 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/be_close_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/be_close_spec.rb @@ -1,38 +1,49 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Matchers - describe BeClose do - it "should match when value == target" do - BeClose.new(5.0, 0.5).matches?(5.0).should be_true + describe "[actual.should] be_close(expected, delta)" do + it "matches when actual == expected" do + be_close(5.0, 0.5).matches?(5.0).should be_true end - it "should match when value < (target + delta)" do - BeClose.new(5.0, 0.5).matches?(5.49).should be_true + it "matches when actual < (expected + delta)" do + be_close(5.0, 0.5).matches?(5.49).should be_true end - it "should match when value > (target - delta)" do - BeClose.new(5.0, 0.5).matches?(4.51).should be_true + it "matches when actual > (expected - delta)" do + be_close(5.0, 0.5).matches?(4.51).should be_true end - it "should not match when value == (target - delta)" do - BeClose.new(5.0, 0.5).matches?(4.5).should be_false + it "does not match when actual == (expected - delta)" do + be_close(5.0, 0.5).matches?(4.5).should be_false end - it "should not match when value < (target - delta)" do - BeClose.new(5.0, 0.5).matches?(4.49).should be_false + it "does not match when actual < (expected - delta)" do + be_close(5.0, 0.5).matches?(4.49).should be_false end - it "should not match when value == (target + delta)" do - BeClose.new(5.0, 0.5).matches?(5.5).should be_false + it "does not match when actual == (expected + delta)" do + be_close(5.0, 0.5).matches?(5.5).should be_false end - it "should not match when value > (target + delta)" do - BeClose.new(5.0, 0.5).matches?(5.51).should be_false + it "does not match when actual > (expected + delta)" do + be_close(5.0, 0.5).matches?(5.51).should be_false end - it "should provide a useful failure message" do + it "provides a failure message for should" do #given - matcher = BeClose.new(5.0, 0.5) + matcher = be_close(5.0, 0.5) #when matcher.matches?(5.51) #then - matcher.failure_message.should == "expected 5.0 +/- (< 0.5), got 5.51" + matcher.failure_message_for_should.should == "expected 5.0 +/- (< 0.5), got 5.51" end - it "should describe itself" do - BeClose.new(5.0, 0.5).description.should == "be close to 5.0 (within +- 0.5)" + + it "provides a failure message for should tno" do + #given + matcher = be_close(5.0, 0.5) + #when + matcher.matches?(5.49) + #then + matcher.failure_message_for_should_not.should == "expected 5.0 +/- (< 0.5), got 5.49" + end + it "provides a description" do + matcher = be_close(5.0, 0.5) + matcher.matches?(5.1) + matcher.description.should == "be close to 5.0 (within +- 0.5)" end end end diff --git a/vendor/plugins/rspec/spec/spec/matchers/be_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/be_spec.rb index ba2a0f165..db6258abf 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/be_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/be_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' describe "should be_predicate" do it "should pass when actual returns true for :predicate?" do @@ -7,7 +7,7 @@ describe "should be_predicate" do end it "should pass when actual returns true for :predicates? (present tense)" do - actual = stub("actual", :exists? => true) + actual = stub("actual", :exists? => true, :exist? => true) actual.should be_exist end @@ -18,10 +18,33 @@ describe "should be_predicate" do }.should fail_with("expected happy? to return true, got false") end + it "should fail when actual returns false for :predicate?" do + actual = stub("actual", :happy? => nil) + lambda { + actual.should be_happy + }.should fail_with("expected happy? to return true, got nil") + end + it "should fail when actual does not respond to :predicate?" do lambda { Object.new.should be_happy - }.should raise_error(NameError) + }.should raise_error(NameError, /happy\?/) + end + + it "should fail on error other than NameError" do + actual = stub("actual") + actual.should_receive(:foo?).and_raise("aaaah") + lambda { + actual.should be_foo + }.should raise_error(/aaaah/) + end + + it "should fail on error other than NameError (with the present tense predicate)" do + actual = Object.new + actual.should_receive(:foos?).and_raise("aaaah") + lambda { + actual.should be_foo + }.should raise_error(/aaaah/) end end @@ -31,6 +54,11 @@ describe "should_not be_predicate" do actual.should_not be_happy end + it "should pass when actual returns nil for :sym?" do + actual = stub("actual", :happy? => nil) + actual.should_not be_happy + end + it "should fail when actual returns true for :sym?" do actual = stub("actual", :happy? => true) lambda { @@ -195,7 +223,15 @@ describe "should be ===" do end it "should fail when === operator returns false" do - lambda { Hash.should be === "not a hash" }.should fail_with(%[expected === "not a hash", got Hash]) + lambda { Hash.should be === "not a hash" }.should fail_with(%[expected === not a hash, got Hash]) + end +end + +describe "should_not with operators" do + it "should coach user to stop using operators with should_not" do + lambda { + 5.should_not be < 6 + }.should raise_error(/not only FAILED,\nit is a bit confusing./m) end end @@ -206,11 +242,11 @@ describe "should be" do end it "should fail if actual is false" do - lambda {false.should be}.should fail_with("expected if to be satisfied, got false") + lambda {false.should be}.should fail_with("expected true, got false") end it "should fail if actual is nil" do - lambda {nil.should be}.should fail_with("expected if to be satisfied, got nil") + lambda {nil.should be}.should fail_with("expected true, got nil") end end @@ -223,13 +259,18 @@ describe "should be(value)" do end end +describe "'should be' with operator" do + it "should include 'be' in the description" do + (be > 6).description.should =~ /be > 6/ + (be >= 6).description.should =~ /be >= 6/ + (be <= 6).description.should =~ /be <= 6/ + (be < 6).description.should =~ /be < 6/ + end +end + describe "arbitrary predicate with DelegateClass" do it "should access methods defined in the delegating class (LH[#48])" do - pending(%{ - Looks like DelegateClass is delegating #should to the - delegate. Not sure how to fix this one. Or if we even should." - }) require 'delegate' class ArrayDelegate < DelegateClass(Array) def initialize(array) @@ -246,3 +287,25 @@ describe "arbitrary predicate with DelegateClass" do delegate.should be_large end end + +describe "be_a, be_an" do + it "should pass when class matches" do + "foobar".should be_a(String) + [1,2,3].should be_an(Array) + end + + it "should fail when class does not match" do + "foobar".should_not be_a(Hash) + [1,2,3].should_not be_an(Integer) + end +end + +describe "be_an_instance_of" do + it "passes when direct class matches" do + 5.should be_an_instance_of(Fixnum) + end + + it "fails when class is higher up hierarchy" do + 5.should_not be_an_instance_of(Numeric) + end +end
\ No newline at end of file diff --git a/vendor/plugins/rspec/spec/spec/matchers/change_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/change_spec.rb index d95aa6da4..e70daf37d 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/change_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/change_spec.rb @@ -1,6 +1,6 @@ #Based on patch from Wilson Bilkovich -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' class SomethingExpected attr_accessor :some_value end @@ -12,13 +12,17 @@ describe "should change(actual, message)" do end it "should pass when actual is modified by the block" do - lambda {@instance.some_value = 6}.should change(@instance, :some_value) + expect {@instance.some_value = 6}.to change(@instance, :some_value) end it "should fail when actual is not modified by the block" do - lambda do - lambda {}.should change(@instance, :some_value) - end.should fail_with("some_value should have changed, but is still 5") + expect do + expect {}.to change(@instance, :some_value) + end.to fail_with("some_value should have changed, but is still 5") + end + + it "provides a #description" do + change(@instance, :some_value).description.should == "change #some_value" end end @@ -29,13 +33,13 @@ describe "should_not change(actual, message)" do end it "should pass when actual is not modified by the block" do - lambda { }.should_not change(@instance, :some_value) + expect { }.to_not change(@instance, :some_value) end it "should fail when actual is not modified by the block" do - lambda do - lambda {@instance.some_value = 6}.should_not change(@instance, :some_value) - end.should fail_with("some_value should not have changed, but did change from 5 to 6") + expect do + expect {@instance.some_value = 6}.to_not change(@instance, :some_value) + end.to fail_with("some_value should not have changed, but did change from 5 to 6") end end @@ -46,20 +50,23 @@ describe "should change { block }" do end it "should pass when actual is modified by the block" do - lambda {@instance.some_value = 6}.should change { @instance.some_value } + expect {@instance.some_value = 6}.to change { @instance.some_value } end it "should fail when actual is not modified by the block" do - lambda do - lambda {}.should change{ @instance.some_value } - end.should fail_with("result should have changed, but is still 5") + expect do + expect {}.to change{ @instance.some_value } + end.to fail_with("result should have changed, but is still 5") + end + + it "should warn if passed a block using do/end instead of {}" do + expect do + expect {}.to change do; end + end.to raise_error(Spec::Matchers::MatcherError, /block passed to should or should_not/) end - it "should warn if passed a block using do/end" do - lambda do - lambda {}.should change do - end - end.should raise_error(Spec::Matchers::MatcherError, /block passed to should or should_not/) + it "provides a #description" do + change { @instance.some_value }.description.should == "change #result" end end @@ -70,20 +77,19 @@ describe "should_not change { block }" do end it "should pass when actual is modified by the block" do - lambda {}.should_not change{ @instance.some_value } + expect {}.to_not change{ @instance.some_value } end it "should fail when actual is not modified by the block" do - lambda do - lambda {@instance.some_value = 6}.should_not change { @instance.some_value } - end.should fail_with("result should not have changed, but did change from 5 to 6") + expect do + expect {@instance.some_value = 6}.to_not change { @instance.some_value } + end.to fail_with("result should not have changed, but did change from 5 to 6") end - it "should warn if passed a block using do/end" do - lambda do - lambda {}.should_not change do - end - end.should raise_error(Spec::Matchers::MatcherError, /block passed to should or should_not/) + it "should warn if passed a block using do/end instead of {}" do + expect do + expect {}.to_not change do; end + end.to raise_error(Spec::Matchers::MatcherError, /block passed to should or should_not/) end end @@ -94,19 +100,19 @@ describe "should change(actual, message).by(expected)" do end it "should pass when attribute is changed by expected amount" do - lambda { @instance.some_value += 1 }.should change(@instance, :some_value).by(1) + expect { @instance.some_value += 1 }.to change(@instance, :some_value).by(1) end it "should fail when the attribute is changed by unexpected amount" do - lambda do - lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by(1) - end.should fail_with("some_value should have been changed by 1, but was changed by 2") + expect do + expect { @instance.some_value += 2 }.to change(@instance, :some_value).by(1) + end.to fail_with("some_value should have been changed by 1, but was changed by 2") end it "should fail when the attribute is changed by unexpected amount in the opposite direction" do - lambda do - lambda { @instance.some_value -= 1 }.should change(@instance, :some_value).by(1) - end.should fail_with("some_value should have been changed by 1, but was changed by -1") + expect do + expect { @instance.some_value -= 1 }.to change(@instance, :some_value).by(1) + end.to fail_with("some_value should have been changed by 1, but was changed by -1") end end @@ -117,19 +123,19 @@ describe "should change{ block }.by(expected)" do end it "should pass when attribute is changed by expected amount" do - lambda { @instance.some_value += 1 }.should change{@instance.some_value}.by(1) + expect { @instance.some_value += 1 }.to change{@instance.some_value}.by(1) end it "should fail when the attribute is changed by unexpected amount" do - lambda do - lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by(1) - end.should fail_with("result should have been changed by 1, but was changed by 2") + expect do + expect { @instance.some_value += 2 }.to change{@instance.some_value}.by(1) + end.to fail_with("result should have been changed by 1, but was changed by 2") end it "should fail when the attribute is changed by unexpected amount in the opposite direction" do - lambda do - lambda { @instance.some_value -= 1 }.should change{@instance.some_value}.by(1) - end.should fail_with("result should have been changed by 1, but was changed by -1") + expect do + expect { @instance.some_value -= 1 }.to change{@instance.some_value}.by(1) + end.to fail_with("result should have been changed by 1, but was changed by -1") end end @@ -140,17 +146,17 @@ describe "should change(actual, message).by_at_least(expected)" do end it "should pass when attribute is changed by greater than the expected amount" do - lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_least(1) + expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_least(1) end it "should pass when attribute is changed by the expected amount" do - lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_least(2) + expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_least(2) end it "should fail when the attribute is changed by less than the expected amount" do - lambda do - lambda { @instance.some_value += 1 }.should change(@instance, :some_value).by_at_least(2) - end.should fail_with("some_value should have been changed by at least 2, but was changed by 1") + expect do + expect { @instance.some_value += 1 }.to change(@instance, :some_value).by_at_least(2) + end.to fail_with("some_value should have been changed by at least 2, but was changed by 1") end end @@ -162,17 +168,17 @@ describe "should change{ block }.by_at_least(expected)" do end it "should pass when attribute is changed by greater than expected amount" do - lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_least(1) + expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_least(1) end it "should pass when attribute is changed by the expected amount" do - lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_least(2) + expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_least(2) end it "should fail when the attribute is changed by less than the unexpected amount" do - lambda do - lambda { @instance.some_value += 1 }.should change{@instance.some_value}.by_at_least(2) - end.should fail_with("result should have been changed by at least 2, but was changed by 1") + expect do + expect { @instance.some_value += 1 }.to change{@instance.some_value}.by_at_least(2) + end.to fail_with("result should have been changed by at least 2, but was changed by 1") end end @@ -184,17 +190,17 @@ describe "should change(actual, message).by_at_most(expected)" do end it "should pass when attribute is changed by less than the expected amount" do - lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_most(3) + expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_most(3) end it "should pass when attribute is changed by the expected amount" do - lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_most(2) + expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_most(2) end it "should fail when the attribute is changed by greater than the expected amount" do - lambda do - lambda { @instance.some_value += 2 }.should change(@instance, :some_value).by_at_most(1) - end.should fail_with("some_value should have been changed by at most 1, but was changed by 2") + expect do + expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_most(1) + end.to fail_with("some_value should have been changed by at most 1, but was changed by 2") end end @@ -206,17 +212,17 @@ describe "should change{ block }.by_at_most(expected)" do end it "should pass when attribute is changed by less than expected amount" do - lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_most(3) + expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_most(3) end it "should pass when attribute is changed by the expected amount" do - lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_most(2) + expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_most(2) end it "should fail when the attribute is changed by greater than the unexpected amount" do - lambda do - lambda { @instance.some_value += 2 }.should change{@instance.some_value}.by_at_most(1) - end.should fail_with("result should have been changed by at most 1, but was changed by 2") + expect do + expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_most(1) + end.to fail_with("result should have been changed by at most 1, but was changed by 2") end end @@ -227,13 +233,13 @@ describe "should change(actual, message).from(old)" do end it "should pass when attribute is == to expected value before executing block" do - lambda { @instance.some_value = "astring" }.should change(@instance, :some_value).from("string") + expect { @instance.some_value = "astring" }.to change(@instance, :some_value).from("string") end it "should fail when attribute is not == to expected value before executing block" do - lambda do - lambda { @instance.some_value = "knot" }.should change(@instance, :some_value).from("cat") - end.should fail_with("some_value should have initially been \"cat\", but was \"string\"") + expect do + expect { @instance.some_value = "knot" }.to change(@instance, :some_value).from("cat") + end.to fail_with("some_value should have initially been \"cat\", but was \"string\"") end end @@ -244,13 +250,13 @@ describe "should change{ block }.from(old)" do end it "should pass when attribute is == to expected value before executing block" do - lambda { @instance.some_value = "astring" }.should change{@instance.some_value}.from("string") + expect { @instance.some_value = "astring" }.to change{@instance.some_value}.from("string") end it "should fail when attribute is not == to expected value before executing block" do - lambda do - lambda { @instance.some_value = "knot" }.should change{@instance.some_value}.from("cat") - end.should fail_with("result should have initially been \"cat\", but was \"string\"") + expect do + expect { @instance.some_value = "knot" }.to change{@instance.some_value}.from("cat") + end.to fail_with("result should have initially been \"cat\", but was \"string\"") end end @@ -261,13 +267,13 @@ describe "should change(actual, message).to(new)" do end it "should pass when attribute is == to expected value after executing block" do - lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).to("cat") + expect { @instance.some_value = "cat" }.to change(@instance, :some_value).to("cat") end it "should fail when attribute is not == to expected value after executing block" do - lambda do - lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).from("string").to("dog") - end.should fail_with("some_value should have been changed to \"dog\", but is now \"cat\"") + expect do + expect { @instance.some_value = "cat" }.to change(@instance, :some_value).from("string").to("dog") + end.to fail_with("some_value should have been changed to \"dog\", but is now \"cat\"") end end @@ -278,13 +284,13 @@ describe "should change{ block }.to(new)" do end it "should pass when attribute is == to expected value after executing block" do - lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.to("cat") + expect { @instance.some_value = "cat" }.to change{@instance.some_value}.to("cat") end it "should fail when attribute is not == to expected value after executing block" do - lambda do - lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.from("string").to("dog") - end.should fail_with("result should have been changed to \"dog\", but is now \"cat\"") + expect do + expect { @instance.some_value = "cat" }.to change{@instance.some_value}.from("string").to("dog") + end.to fail_with("result should have been changed to \"dog\", but is now \"cat\"") end end @@ -295,11 +301,23 @@ describe "should change(actual, message).from(old).to(new)" do end it "should pass when #to comes before #from" do - lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).to("cat").from("string") + expect { @instance.some_value = "cat" }.to change(@instance, :some_value).to("cat").from("string") end it "should pass when #from comes before #to" do - lambda { @instance.some_value = "cat" }.should change(@instance, :some_value).from("string").to("cat") + expect { @instance.some_value = "cat" }.to change(@instance, :some_value).from("string").to("cat") + end + + it "should show the correct messaging when #after and #to are different" do + expect do + expect { @instance.some_value = "cat" }.to change(@instance, :some_value).from("string").to("dog") + end.to fail_with("some_value should have been changed to \"dog\", but is now \"cat\"") + end + + it "should show the correct messaging when #before and #from are different" do + expect do + expect { @instance.some_value = "cat" }.to change(@instance, :some_value).from("not_string").to("cat") + end.to fail_with("some_value should have initially been \"not_string\", but was \"string\"") end end @@ -310,10 +328,22 @@ describe "should change{ block }.from(old).to(new)" do end it "should pass when #to comes before #from" do - lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.to("cat").from("string") + expect { @instance.some_value = "cat" }.to change{@instance.some_value}.to("cat").from("string") end it "should pass when #from comes before #to" do - lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.from("string").to("cat") + expect { @instance.some_value = "cat" }.to change{@instance.some_value}.from("string").to("cat") + end +end + +describe Spec::Matchers::Change do + it "should work when the receiver has implemented #send" do + @instance = SomethingExpected.new + @instance.some_value = "string" + def @instance.send(*args); raise "DOH! Library developers shouldn't use #send!" end + + expect { + expect { @instance.some_value = "cat" }.to change(@instance, :some_value) + }.to_not raise_error end end diff --git a/vendor/plugins/rspec/spec/spec/matchers/description_generation_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/description_generation_spec.rb index c494e2165..51b483c74 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/description_generation_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/description_generation_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' describe "Matchers should be able to generate their own descriptions" do after(:each) do @@ -50,18 +50,6 @@ describe "Matchers should be able to generate their own descriptions" do Spec::Matchers.generated_description.should == "should be between 0 and 10" end - it "should be_few_words predicate should be transformed to 'be few words'" do - 5.should be_kind_of(Fixnum) - Spec::Matchers.generated_description.should == "should be kind of Fixnum" - end - - it "should preserve a proper prefix for be predicate" do - 5.should be_a_kind_of(Fixnum) - Spec::Matchers.generated_description.should == "should be a kind of Fixnum" - 5.should be_an_instance_of(Fixnum) - Spec::Matchers.generated_description.should == "should be an instance of Fixnum" - end - it "should equal" do expected = "expected" expected.should equal(expected) @@ -107,6 +95,11 @@ describe "Matchers should be able to generate their own descriptions" do [1,2,3].should include(3) Spec::Matchers.generated_description.should == "should include 3" end + + it "array.should =~ [1,2,3]" do + [1,2,3].should =~ [1,2,3] + Spec::Matchers.generated_description.should == "should contain exactly 1, 2 and 3" + end it "should match" do "this string".should match(/this string/) @@ -151,3 +144,17 @@ describe "Matchers should be able to generate their own descriptions" do end.new end end + +describe "a Matcher with no description" do + def matcher + Class.new do + def matches?(ignore); true; end + def failure_message; ""; end + end.new + end + + it "should provide a helpful message when used in a string-less example block" do + 5.should matcher + Spec::Matchers.generated_description.should =~ /When you call.*description method/m + end +end diff --git a/vendor/plugins/rspec/spec/spec/matchers/eql_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/eql_spec.rb index 3f265d700..5cdf541eb 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/eql_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/eql_spec.rb @@ -1,27 +1,32 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Matchers - describe Eql do + describe "eql" do it "should match when actual.eql?(expected)" do - Eql.new(1).matches?(1).should be_true + 1.should eql(1) end + it "should not match when !actual.eql?(expected)" do - Eql.new(1).matches?(2).should be_false + 1.should_not eql(2) end + it "should describe itself" do - matcher = Eql.new(1) + matcher = eql(1) + matcher.matches?(1) matcher.description.should == "eql 1" end + it "should provide message, expected and actual on #failure_message" do - matcher = Eql.new("1") + matcher = eql("1") matcher.matches?(1) - matcher.failure_message.should == ["expected \"1\", got 1 (using .eql?)", "1", 1] + matcher.failure_message_for_should.should == "\nexpected \"1\"\n got 1\n\n(compared using eql?)\n" end + it "should provide message, expected and actual on #negative_failure_message" do - matcher = Eql.new(1) + matcher = eql(1) matcher.matches?(1) - matcher.negative_failure_message.should == ["expected 1 not to equal 1 (using .eql?)", 1, 1] + matcher.failure_message_for_should_not.should == "\nexpected 1 not to equal 1\n\n(compared using eql?)\n" end end end diff --git a/vendor/plugins/rspec/spec/spec/matchers/equal_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/equal_spec.rb index 7667bdc38..cb2fc1e51 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/equal_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/equal_spec.rb @@ -1,27 +1,56 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' - +require 'spec_helper' module Spec module Matchers - describe Equal do + describe "equal" do + + def inspect_object(o) + "#<#{o.class}:#{o.object_id}> => #{o.inspect}" + end + it "should match when actual.equal?(expected)" do - Equal.new(1).matches?(1).should be_true + 1.should equal(1) end + it "should not match when !actual.equal?(expected)" do - Equal.new("1").matches?("1").should be_false + 1.should_not equal("1") end + it "should describe itself" do - matcher = Equal.new(1) + matcher = equal(1) + matcher.matches?(1) matcher.description.should == "equal 1" end - it "should provide message, expected and actual on #failure_message" do - matcher = Equal.new("1") - matcher.matches?(1) - matcher.failure_message.should == ["expected \"1\", got 1 (using .equal?)", "1", 1] + + it "should provide message on #failure_message" do + expected, actual = "1", "1" + matcher = equal(expected) + matcher.matches?(actual) + + matcher.failure_message_for_should.should == <<-MESSAGE + +expected #{inspect_object(expected)} + got #{inspect_object(actual)} + +Compared using equal?, which compares object identity, +but expected and actual are not the same object. Use +'actual.should == expected' if you don't care about +object identity in this example. + +MESSAGE end - it "should provide message, expected and actual on #negative_failure_message" do - matcher = Equal.new(1) - matcher.matches?(1) - matcher.negative_failure_message.should == ["expected 1 not to equal 1 (using .equal?)", 1, 1] + + it "should provide message on #negative_failure_message" do + expected = actual = "1" + matcher = equal(expected) + matcher.matches?(actual) + matcher.failure_message_for_should_not.should == <<-MESSAGE + +expected not #{inspect_object(expected)} + got #{inspect_object(actual)} + +Compared using equal?, which compares object identity. + +MESSAGE end end end diff --git a/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb index 0a509726e..f95c86ff8 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb @@ -1,11 +1,11 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' class Substance def initialize exists, description @exists = exists @description = description end - def exist? + def exist?(arg=nil) @exists end def inspect @@ -23,7 +23,7 @@ class SubstanceTester end end -describe "should exist," do +describe "should exist" do before(:each) do @real = Substance.new true, 'something real' @@ -32,15 +32,23 @@ describe "should exist," do describe "within an example group" do - it "should pass if target exists" do + it "passes if target exists" do @real.should exist end - it "should fail if target does not exist" do + it "passes if target exists with args" do + @real.should exist('this arg') + end + + it "fails if target does not exist" do lambda { @imaginary.should exist }.should fail end - it "should pass if target doesn't exist" do + it "describes itself" do + exist.description.should == "exist" + end + + it "passes should_not exist if target doesn't exist" do lambda { @real.should_not exist }.should fail end end diff --git a/vendor/plugins/rspec/spec/spec/matchers/handler_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/handler_spec.rb deleted file mode 100644 index ad4fe6f85..000000000 --- a/vendor/plugins/rspec/spec/spec/matchers/handler_spec.rb +++ /dev/null @@ -1,129 +0,0 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' - -module ExampleExpectations - - class ArbitraryMatcher - def initialize(*args, &block) - if args.last.is_a? Hash - @expected = args.last[:expected] - end - if block_given? - @expected = block.call - end - @block = block - end - - def matches?(target) - @target = target - return @expected == target - end - - def with(new_value) - @expected = new_value - self - end - - def failure_message - "expected #{@expected}, got #{@target}" - end - - def negative_failure_message - "expected not #{@expected}, got #{@target}" - end - end - - class PositiveOnlyMatcher < ArbitraryMatcher - undef negative_failure_message rescue nil - end - - def arbitrary_matcher(*args, &block) - ArbitraryMatcher.new(*args, &block) - end - - def positive_only_matcher(*args, &block) - PositiveOnlyMatcher.new(*args, &block) - end - -end - -module Spec - module Expectations - describe ExpectationMatcherHandler, ".handle_matcher" do - it "should ask the matcher if it matches" do - matcher = mock("matcher") - actual = Object.new - matcher.should_receive(:matches?).with(actual).and_return(true) - ExpectationMatcherHandler.handle_matcher(actual, matcher) - end - - it "should explain when the matcher parameter is not a matcher" do - begin - nonmatcher = mock("nonmatcher") - actual = Object.new - ExpectationMatcherHandler.handle_matcher(actual, nonmatcher) - rescue Spec::Expectations::InvalidMatcherError => e - end - - e.message.should =~ /^Expected a matcher, got / - end - end - - describe NegativeExpectationMatcherHandler, ".handle_matcher" do - it "should explain when matcher does not support should_not" do - matcher = mock("matcher") - matcher.stub!(:matches?) - actual = Object.new - lambda { - NegativeExpectationMatcherHandler.handle_matcher(actual, matcher) - }.should fail_with(/Matcher does not support should_not.\n/) - end - - it "should ask the matcher if it matches" do - matcher = mock("matcher") - actual = Object.new - matcher.stub!(:negative_failure_message) - matcher.should_receive(:matches?).with(actual).and_return(false) - NegativeExpectationMatcherHandler.handle_matcher(actual, matcher) - end - - it "should explain when the matcher parameter is not a matcher" do - begin - nonmatcher = mock("nonmatcher") - actual = Object.new - NegativeExpectationMatcherHandler.handle_matcher(actual, nonmatcher) - rescue Spec::Expectations::InvalidMatcherError => e - end - - e.message.should =~ /^Expected a matcher, got / - end - end - - describe ExpectationMatcherHandler do - include ExampleExpectations - - it "should handle submitted args" do - 5.should arbitrary_matcher(:expected => 5) - 5.should arbitrary_matcher(:expected => "wrong").with(5) - lambda { 5.should arbitrary_matcher(:expected => 4) }.should fail_with("expected 4, got 5") - lambda { 5.should arbitrary_matcher(:expected => 5).with(4) }.should fail_with("expected 4, got 5") - 5.should_not arbitrary_matcher(:expected => 4) - 5.should_not arbitrary_matcher(:expected => 5).with(4) - lambda { 5.should_not arbitrary_matcher(:expected => 5) }.should fail_with("expected not 5, got 5") - lambda { 5.should_not arbitrary_matcher(:expected => 4).with(5) }.should fail_with("expected not 5, got 5") - end - - it "should handle the submitted block" do - 5.should arbitrary_matcher { 5 } - 5.should arbitrary_matcher(:expected => 4) { 5 } - 5.should arbitrary_matcher(:expected => 4).with(5) { 3 } - end - - it "should explain when matcher does not support should_not" do - lambda { - 5.should_not positive_only_matcher(:expected => 5) - }.should fail_with(/Matcher does not support should_not.\n/) - end - - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/matchers/has_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/has_spec.rb index 648ad8653..b6f259913 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/has_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/has_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' describe "should have_sym(*args)" do it "should pass if #has_sym?(*args) returns true" do @@ -11,6 +11,16 @@ describe "should have_sym(*args)" do }.should fail_with("expected #has_key?(:a) to return true, got false") end + it "should fail if #has_sym?(*args) returns nil" do + klass = Class.new do + def has_foo? + end + end + lambda { + klass.new.should have_foo + }.should fail_with("expected #has_foo?(nil) to return true, got false") + end + it "should fail if target does not respond to #has_sym?" do lambda { Object.new.should have_key(:a) @@ -31,6 +41,14 @@ describe "should_not have_sym(*args)" do {:a => "A"}.should_not have_key(:b) end + it "should pass if #has_sym?(*args) returns nil" do + klass = Class.new do + def has_foo? + end + end + klass.new.should_not have_foo + end + it "should fail if #has_sym?(*args) returns true" do lambda { {:a => "A"}.should_not have_key(:a) @@ -51,3 +69,13 @@ describe "should_not have_sym(*args)" do lambda { o.should_not have_sym(:foo) }.should raise_error("Funky exception") end end + +describe "has" do + it "should work when the target implements #send" do + o = {:a => "A"} + def o.send(*args); raise "DOH! Library developers shouldn't use #send!" end + lambda { + o.should have_key(:a) + }.should_not raise_error + end +end diff --git a/vendor/plugins/rspec/spec/spec/matchers/have_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/have_spec.rb index 27083c294..07c294976 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/have_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/have_spec.rb @@ -1,16 +1,31 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' -module HaveSpecHelper +share_as :HaveSpecHelper do def create_collection_owner_with(n) owner = Spec::Expectations::Helper::CollectionOwner.new - (1..n).each do |n| - owner.add_to_collection_with_length_method(n) - owner.add_to_collection_with_size_method(n) + (1..n).each do |number| + owner.add_to_collection_with_length_method(number) + owner.add_to_collection_with_size_method(number) end owner end + before(:each) do + if defined?(::ActiveSupport::Inflector) + @active_support_was_defined = true + else + @active_support_was_defined = false + module ::ActiveSupport + class Inflector + def self.pluralize(string) + string.to_s + 's' + end + end + end + end + end end + describe "should have(n).items" do include HaveSpecHelper @@ -47,12 +62,30 @@ describe "should have(n).items" do end end +describe 'should have(1).item when ActiveSupport::Inflector is defined' do + include HaveSpecHelper + + it 'should pluralize the collection name' do + owner = create_collection_owner_with(1) + owner.should have(1).item + end + + after(:each) do + unless @active_support_was_defined + Object.__send__ :remove_const, :ActiveSupport + end + end +end + describe 'should have(1).item when Inflector is defined' do include HaveSpecHelper - before do - unless Object.const_defined?(:Inflector) - class Inflector + before(:each) do + if defined?(Inflector) + @inflector_was_defined = true + else + @inflector_was_defined = false + class ::Inflector def self.pluralize(string) string.to_s + 's' end @@ -64,6 +97,12 @@ describe 'should have(1).item when Inflector is defined' do owner = create_collection_owner_with(1) owner.should have(1).item end + + after(:each) do + unless @inflector_was_defined + Object.__send__ :remove_const, :Inflector + end + end end describe "should have(n).items where result responds to items but returns something other than a collection" do @@ -177,7 +216,7 @@ describe "should have_at_least(n).items" do size_matcher.matches?(owner) #then - length_matcher.negative_failure_message.should == <<-EOF + length_matcher.failure_message_for_should_not.should == <<-EOF Isn't life confusing enough? Instead of having to figure out the meaning of this: should_not have_at_least(3).items_in_collection_with_length_method @@ -185,7 +224,7 @@ We recommend that you use this instead: should have_at_most(2).items_in_collection_with_length_method EOF - size_matcher.negative_failure_message.should == <<-EOF + size_matcher.failure_message_for_should_not.should == <<-EOF Isn't life confusing enough? Instead of having to figure out the meaning of this: should_not have_at_least(3).items_in_collection_with_size_method @@ -231,7 +270,7 @@ describe "should have_at_most(n).items" do size_matcher.matches?(owner) #then - length_matcher.negative_failure_message.should == <<-EOF + length_matcher.failure_message_for_should_not.should == <<-EOF Isn't life confusing enough? Instead of having to figure out the meaning of this: should_not have_at_most(3).items_in_collection_with_length_method @@ -239,7 +278,7 @@ We recommend that you use this instead: should have_at_least(4).items_in_collection_with_length_method EOF - size_matcher.negative_failure_message.should == <<-EOF + size_matcher.failure_message_for_should_not.should == <<-EOF Isn't life confusing enough? Instead of having to figure out the meaning of this: should_not have_at_most(3).items_in_collection_with_size_method @@ -289,3 +328,69 @@ describe "have(n).things on an object which is not a collection nor contains one lambda { Object.new.should have(2).things }.should raise_error(NoMethodError, /undefined method `things' for #<Object:/) end end + +describe Spec::Matchers::Have, "for a collection owner that implements #send" do + include HaveSpecHelper + + before(:each) do + @collection = Object.new + def @collection.floozles; [1,2] end + def @collection.send(*args); raise "DOH! Library developers shouldn't use #send!" end + end + + it "should work in the straightforward case" do + lambda { + @collection.should have(2).floozles + }.should_not raise_error + end + + it "should work when doing automatic pluralization" do + lambda { + @collection.should have_at_least(1).floozle + }.should_not raise_error + end + + it "should blow up when the owner doesn't respond to that method" do + lambda { + @collection.should have(99).problems + }.should raise_error(NoMethodError, /problems/) + end +end + +module Spec + module Matchers + describe Have do + treats_method_missing_as_private :noop => false + + describe "respond_to?" do + before :each do + @have = Have.new(:foo) + @a_method_which_have_defines = Have.instance_methods.first + @a_method_which_object_defines = Object.instance_methods.first + end + + it "should be true for a method which Have defines" do + @have.should respond_to(@a_method_which_have_defines) + end + + it "should be true for a method that it's superclass (Object) defines" do + @have.should respond_to(@a_method_which_object_defines) + end + + it "should be false for a method which neither Object nor nor Have defines" do + @have.should_not respond_to(:foo_bar_baz) + end + + it "should be false if the owner doesn't respond to the method" do + have = Have.new(99) + have.should_not respond_to(:problems) + end + + it "should be true if the owner responds to the method" do + have = Have.new(:a_symbol) + have.should respond_to(:to_sym) + end + end + end + end +end diff --git a/vendor/plugins/rspec/spec/spec/matchers/include_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/include_spec.rb index f1057f3fd..2b959b589 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/include_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/include_spec.rb @@ -1,10 +1,14 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' describe "should include(expected)" do it "should pass if target includes expected" do [1,2,3].should include(3) "abc".should include("a") end + + it 'should pass if target is a Hash and has the expected as a key' do + {:key => 'value'}.should include(:key) + end it "should fail if target does not include expected" do lambda { @@ -13,6 +17,9 @@ describe "should include(expected)" do lambda { "abc".should include("d") }.should fail_with("expected \"abc\" to include \"d\"") + lambda { + {:key => 'value'}.should include(:other) + }.should fail_with(%Q|expected {:key=>"value"} to include :other|) end end @@ -20,11 +27,21 @@ describe "should include(with, multiple, args)" do it "should pass if target includes all items" do [1,2,3].should include(1,2,3) end + + it 'should pass if target is a Hash including all items as keys' do + {:key => 'value', :other => 'value'}.should include(:key, :other) + end it "should fail if target does not include any one of the items" do lambda { [1,2,3].should include(1,2,4) - }.should fail_with("expected [1, 2, 3] to include 1, 2 and 4") + }.should fail_with("expected [1, 2, 3] to include 1, 2, and 4") + end + + it 'should pass if target is a Hash missing any item as a key' do + lambda { + {:key => 'value'}.should include(:key, :other) + }.should fail_with(%Q|expected {:key=>"value"} to include :key and :other|) end end @@ -33,6 +50,10 @@ describe "should_not include(expected)" do [1,2,3].should_not include(4) "abc".should_not include("d") end + + it 'should pass if target is a Hash and does not have the expected as a key' do + {:other => 'value'}.should_not include(:key) + end it "should fail if target includes expected" do lambda { @@ -41,5 +62,27 @@ describe "should_not include(expected)" do lambda { "abc".should_not include("c") }.should fail_with("expected \"abc\" not to include \"c\"") + lambda { + {:key => 'value'}.should_not include(:key) + }.should fail_with(%Q|expected {:key=>"value"} not to include :key|) + end +end + +describe "should include(:key => value)" do + it "should pass if target is a Hash and includes the key/value pair" do + {:key => 'value'}.should include(:key => 'value') + end + it "should pass if target is a Hash and includes the key/value pair among others" do + {:key => 'value', :other => 'different'}.should include(:key => 'value') + end + it "should fail if target is a Hash and has a different value for key" do + lambda { + {:key => 'different'}.should include(:key => 'value') + }.should fail_with(%Q|expected {:key=>"different"} to include {:key=>"value"}|) + end + it "should fail if target is a Hash and has a different key" do + lambda { + {:other => 'value'}.should include(:key => 'value') + }.should fail_with(%Q|expected {:other=>"value"} to include {:key=>"value"}|) end end diff --git a/vendor/plugins/rspec/spec/spec/matchers/match_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/match_spec.rb index f69f7efad..e5dc800a6 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/match_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/match_spec.rb @@ -1,20 +1,30 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' describe "should match(expected)" do it "should pass when target (String) matches expected (Regexp)" do "string".should match(/tri/) end + it "should pass when target (String) matches expected (String)" do + "string".should match("tri") + end + it "should fail when target (String) does not match expected (Regexp)" do lambda { "string".should match(/rings/) }.should fail end + + it "should fail when target (String) does not match expected (String)" do + lambda { + "string".should match("rings") + }.should fail + end it "should provide message, expected and actual on failure" do matcher = match(/rings/) matcher.matches?("string") - matcher.failure_message.should == ["expected \"string\" to match /rings/", /rings/, "string"] + matcher.failure_message_for_should.should == "expected \"string\" to match /rings/" end end @@ -23,15 +33,25 @@ describe "should_not match(expected)" do "string".should_not match(/rings/) end + it "should pass when target (String) matches does not match (String)" do + "string".should_not match("rings") + end + it "should fail when target (String) matches expected (Regexp)" do lambda { "string".should_not match(/tri/) }.should fail end + it "should fail when target (String) matches expected (String)" do + lambda { + "string".should_not match("tri") + }.should fail + end + it "should provide message, expected and actual on failure" do matcher = match(/tri/) matcher.matches?("string") - matcher.negative_failure_message.should == ["expected \"string\" not to match /tri/", /tri/, "string"] + matcher.failure_message_for_should_not.should == "expected \"string\" not to match /tri/" end end diff --git a/vendor/plugins/rspec/spec/spec/matchers/matcher_methods_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/matcher_methods_spec.rb index 80cc9855a..291a2afa4 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/matcher_methods_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/matcher_methods_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Matchers @@ -16,18 +16,9 @@ This module should provide the following methods, each of which returns a Matche it "be_arbitrary_predicate" do be_arbitrary_predicate.should be_an_instance_of(Be) end - it "be_close" do - be_close(1,2).should be_an_instance_of(BeClose) - end it "change" do change("target", :message).should be_an_instance_of(Change) end - it "eql" do - eql(:expected).should be_an_instance_of(Eql) - end - it "equal" do - equal(:expected).should be_an_instance_of(Equal) - end it "have" do have(0).should be_an_instance_of(Have) end @@ -40,12 +31,6 @@ This module should provide the following methods, each of which returns a Matche it "have_at_most" do have_at_most(0).should be_an_instance_of(Have) end - it "include" do - include(:value).should be_an_instance_of(Include) - end - it "match" do - match(:value).should be_an_instance_of(Match) - end it "raise_error" do raise_error.should be_an_instance_of(RaiseError) raise_error(NoMethodError).should be_an_instance_of(RaiseError) diff --git a/vendor/plugins/rspec/spec/spec/matchers/mock_constraint_matchers_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/mock_constraint_matchers_spec.rb deleted file mode 100644 index 1292918c7..000000000 --- a/vendor/plugins/rspec/spec/spec/matchers/mock_constraint_matchers_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' - -describe "The anything() mock argument constraint matcher" do - specify { anything.should == Object.new } - specify { anything.should == Class } - specify { anything.should == 1 } - specify { anything.should == "a string" } - specify { anything.should == :a_symbol } -end - -describe "The boolean() mock argument constraint matcher" do - specify { boolean.should == true } - specify { boolean.should == false } - specify { boolean.should_not == Object.new } - specify { boolean.should_not == Class } - specify { boolean.should_not == 1 } - specify { boolean.should_not == "a string" } - specify { boolean.should_not == :a_symbol } -end - -describe "The an_instance_of() mock argument constraint matcher" do - # NOTE - this is implemented as a predicate_matcher - see example_group_methods.rb - specify { an_instance_of(String).should == "string" } -end diff --git a/vendor/plugins/rspec/spec/spec/matchers/operator_matcher_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/operator_matcher_spec.rb index 1985df0d9..86e637e0f 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/operator_matcher_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/operator_matcher_spec.rb @@ -1,6 +1,6 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' -require 'spec/expectations/differs/default' +require 'spec/runner/differs/default' describe "should ==" do @@ -10,12 +10,17 @@ describe "should ==" do subject.should == "apple" end + it "should return true on success" do + subject = "apple" + (subject.should == "apple").should be_true + end + it "should fail when target.==(actual) returns false" do subject = "apple" Spec::Expectations.should_receive(:fail_with).with(%[expected: "orange",\n got: "apple" (using ==)], "orange", "apple") subject.should == "orange" end - + end describe "should_not ==" do @@ -26,12 +31,17 @@ describe "should_not ==" do subject.should_not == "apple" end + it "should return true on success" do + subject = "apple" + (subject.should_not == "orange").should be_false + end + it "should fail when target.==(actual) returns false" do subject = "apple" Spec::Expectations.should_receive(:fail_with).with(%[expected not: == "apple",\n got: "apple"], "apple", "apple") subject.should_not == "apple" end - + end describe "should ===" do @@ -156,3 +166,26 @@ describe "should <=" do end +describe Spec::Matchers::PositiveOperatorMatcher do + + it "should work when the target has implemented #send" do + o = Object.new + def o.send(*args); raise "DOH! Library developers shouldn't use #send!" end + lambda { + o.should == o + }.should_not raise_error + end + +end + +describe Spec::Matchers::NegativeOperatorMatcher do + + it "should work when the target has implemented #send" do + o = Object.new + def o.send(*args); raise "DOH! Library developers shouldn't use #send!" end + lambda { + o.should_not == :foo + }.should_not raise_error + end + +end diff --git a/vendor/plugins/rspec/spec/spec/matchers/raise_error_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/raise_error_spec.rb index a500d3b50..785065adc 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/raise_error_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/raise_error_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' describe "should raise_error" do it "should pass if anything is raised" do @@ -12,6 +12,24 @@ describe "should raise_error" do end end +describe "should raise_error {|err| ... }" do + it "passes if there is an error" do + ran = false + lambda { non_existent_method }.should raise_error {|e| + ran = true + } + ran.should be_true + end + + it "passes the error to the block" do + error = nil + lambda { non_existent_method }.should raise_error {|e| + error = e + } + error.should be_kind_of(NameError) + end +end + describe "should_not raise_error" do it "should pass if nothing is raised" do lambda {}.should_not raise_error @@ -100,8 +118,8 @@ describe "should_not raise_error(NamedError)" do it "should fail if named error is raised" do lambda { - lambda { non_existent_method }.should_not raise_error(NameError) - }.should fail_with(/expected no NameError, got #<NameError: undefined/) + lambda { 1 + 'b' }.should_not raise_error(TypeError) + }.should fail_with(/expected no TypeError, got #<TypeError: String can't be/) end end diff --git a/vendor/plugins/rspec/spec/spec/matchers/respond_to_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/respond_to_spec.rb index 2cdbbcd63..8d8f3c1ac 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/respond_to_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/respond_to_spec.rb @@ -1,54 +1,116 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' describe "should respond_to(:sym)" do - it "should pass if target responds to :sym" do + it "passes if target responds to :sym" do Object.new.should respond_to(:methods) end - it "should fail target does not respond to :sym" do + it "fails if target does not respond to :sym" do lambda { - Object.new.should respond_to(:some_method) - }.should fail_with("expected target to respond to :some_method") + "this string".should respond_to(:some_method) + }.should fail_with(%q|expected "this string" to respond to :some_method|) end end +describe "should respond_to(:sym).with(1).argument" do + it "passes if target responds to :sym with 1 arg" do + obj = Object.new + def obj.foo(arg); end + obj.should respond_to(:foo).with(1).argument + end + + it "fails if target does not respond to :sym" do + obj = Object.new + lambda { + obj.should respond_to(:some_method).with(1).argument + }.should fail_with(/expected .* to respond to :some_method/) + end + + it "fails if :sym expects 0 args" do + obj = Object.new + def obj.foo; end + lambda { + obj.should respond_to(:foo).with(1).argument + }.should fail_with(/expected #<Object.*> to respond to :foo with 1 argument/) + end + + it "fails if :sym expects 2 args" do + obj = Object.new + def obj.foo(arg, arg2); end + lambda { + obj.should respond_to(:foo).with(1).argument + }.should fail_with(/expected #<Object.*> to respond to :foo with 1 argument/) + end +end + describe "should respond_to(message1, message2)" do - it "should pass if target responds to both messages" do + it "passes if target responds to both messages" do Object.new.should respond_to('methods', 'inspect') end - it "should fail target does not respond to first message" do + it "fails if target does not respond to first message" do lambda { Object.new.should respond_to('method_one', 'inspect') - }.should fail_with('expected target to respond to "method_one"') + }.should fail_with(/expected #<Object:.*> to respond to "method_one"/) end - it "should fail target does not respond to second message" do + it "fails if target does not respond to second message" do lambda { Object.new.should respond_to('inspect', 'method_one') - }.should fail_with('expected target to respond to "method_one"') + }.should fail_with(/expected #<Object:.*> to respond to "method_one"/) end - it "should fail target does not respond to either message" do + it "fails if target does not respond to either message" do lambda { Object.new.should respond_to('method_one', 'method_two') - }.should fail_with('expected target to respond to "method_one", "method_two"') + }.should fail_with(/expected #<Object:.*> to respond to "method_one", "method_two"/) + end +end + +describe "should respond_to(:sym).with(2).arguments" do + it "passes if target responds to :sym with 2 args" do + obj = Object.new + def obj.foo(a1, a2); end + obj.should respond_to(:foo).with(2).arguments + end + + it "fails if target does not respond to :sym" do + obj = Object.new + lambda { + obj.should respond_to(:some_method).with(2).arguments + }.should fail_with(/expected .* to respond to :some_method/) + end + + it "fails if :sym expects 0 args" do + obj = Object.new + def obj.foo; end + lambda { + obj.should respond_to(:foo).with(2).arguments + }.should fail_with(/expected #<Object.*> to respond to :foo with 2 arguments/) + end + + it "fails if :sym expects 2 args" do + obj = Object.new + def obj.foo(arg); end + lambda { + obj.should respond_to(:foo).with(2).arguments + }.should fail_with(/expected #<Object.*> to respond to :foo with 2 arguments/) end end describe "should_not respond_to(:sym)" do - it "should pass if target does not respond to :sym" do + it "passes if target does not respond to :sym" do Object.new.should_not respond_to(:some_method) end - it "should fail target responds to :sym" do + it "fails if target responds to :sym" do lambda { Object.new.should_not respond_to(:methods) - }.should fail_with("expected target not to respond to :methods") + }.should fail_with(/expected #<Object:.*> not to respond to :methods/) end end diff --git a/vendor/plugins/rspec/spec/spec/matchers/satisfy_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/satisfy_spec.rb index 7e8d6f972..e50c395a6 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/satisfy_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/satisfy_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' describe "should satisfy { block }" do it "should pass if block returns true" do diff --git a/vendor/plugins/rspec/spec/spec/matchers/simple_matcher_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/simple_matcher_spec.rb index b731af92d..8071a9f31 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/simple_matcher_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/simple_matcher_spec.rb @@ -1,9 +1,9 @@ -require File.dirname(__FILE__) + '/../../spec_helper' +require 'spec_helper' module Spec module Matchers describe SimpleMatcher do - it "should match pass match arg to block" do + it "should pass match arg to block" do actual = nil matcher = simple_matcher("message") do |given| actual = given end matcher.matches?("foo") @@ -22,10 +22,72 @@ module Spec matcher.negative_failure_message.should =~ /expected not to get \"thing\", but got \"other\"/ end - it "should provide a description" do + it "should provide the given description" do matcher = simple_matcher("thing") do end matcher.description.should =="thing" end + + it "should fail if a wrapped 'should' fails" do + matcher = simple_matcher("should fail") do + 2.should == 3 + end + lambda do + matcher.matches?("anything").should be_true + end.should fail_with(/expected: 3/) + end + end + + describe "with arity of 2" do + it "should provide the matcher so you can access its messages" do + provided_matcher = nil + matcher = simple_matcher("thing") do |given, matcher| + provided_matcher = matcher + end + matcher.matches?("anything") + provided_matcher.should equal(matcher) + end + + it "should support a custom failure message" do + matcher = simple_matcher("thing") do |given, matcher| + matcher.failure_message = "custom message" + end + matcher.matches?("other") + matcher.failure_message.should == "custom message" + end + + it "should complain when asked for a failure message if you don't give it a description or a message" do + matcher = simple_matcher do |given, matcher| end + matcher.matches?("other") + matcher.failure_message.should =~ /No description provided/ + end + + it "should support a custom negative failure message" do + matcher = simple_matcher("thing") do |given, matcher| + matcher.negative_failure_message = "custom message" + end + matcher.matches?("other") + matcher.negative_failure_message.should == "custom message" + end + + it "should complain when asked for a negative failure message if you don't give it a description or a message" do + matcher = simple_matcher do |given, matcher| end + matcher.matches?("other") + matcher.negative_failure_message.should =~ /No description provided/ + end + + it "should support a custom description" do + matcher = simple_matcher("thing") do |given, matcher| + matcher.description = "custom message" + end + matcher.matches?("description") + matcher.description.should == "custom message" + end + + it "should tell you no description was provided when it doesn't receive one" do + matcher = simple_matcher do end + matcher.description.should =~ /No description provided/ + end end + end end
\ No newline at end of file diff --git a/vendor/plugins/rspec/spec/spec/matchers/throw_symbol_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/throw_symbol_spec.rb index 74595659a..402f812fc 100644 --- a/vendor/plugins/rspec/spec/spec/matchers/throw_symbol_spec.rb +++ b/vendor/plugins/rspec/spec/spec/matchers/throw_symbol_spec.rb @@ -1,53 +1,95 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Matchers - describe ThrowSymbol, "(constructed with no Symbol)" do - before(:each) { @matcher = ThrowSymbol.new } - - it "should match if any Symbol is thrown" do - @matcher.matches?(lambda{ throw :sym }).should be_true - end - it "should not match if no Symbol is thrown" do - @matcher.matches?(lambda{ }).should be_false - end - it "should provide a failure message" do - @matcher.matches?(lambda{}) - @matcher.failure_message.should == "expected a Symbol but nothing was thrown" - end - it "should provide a negative failure message" do - @matcher.matches?(lambda{ throw :sym}) - @matcher.negative_failure_message.should == "expected no Symbol, got :sym" - end - end - - describe ThrowSymbol, "(constructed with a Symbol)" do - before(:each) { @matcher = ThrowSymbol.new(:sym) } + describe ThrowSymbol do + describe "with no args" do + before(:each) { @matcher = ThrowSymbol.new } - it "should match if correct Symbol is thrown" do - @matcher.matches?(lambda{ throw :sym }).should be_true + it "should match if any Symbol is thrown" do + @matcher.matches?(lambda{ throw :sym }).should be_true + end + it "should match if any Symbol is thrown with an arg" do + @matcher.matches?(lambda{ throw :sym, "argument" }).should be_true + end + it "should not match if no Symbol is thrown" do + @matcher.matches?(lambda{ }).should be_false + end + it "should provide a failure message" do + @matcher.matches?(lambda{}) + @matcher.failure_message_for_should.should == "expected a Symbol but nothing was thrown" + end + it "should provide a negative failure message" do + @matcher.matches?(lambda{ throw :sym}) + @matcher.failure_message_for_should_not.should == "expected no Symbol, got :sym" + end end - it "should not match if no Symbol is thrown" do - @matcher.matches?(lambda{ }).should be_false - end - it "should not match if correct Symbol is thrown" do - @matcher.matches?(lambda{ throw :other_sym }).should be_false - @matcher.failure_message.should == "expected :sym, got :other_sym" - end - it "should provide a failure message when no Symbol is thrown" do - @matcher.matches?(lambda{}) - @matcher.failure_message.should == "expected :sym but nothing was thrown" - end - it "should provide a failure message when wrong Symbol is thrown" do - @matcher.matches?(lambda{ throw :other_sym }) - @matcher.failure_message.should == "expected :sym, got :other_sym" - end - it "should provide a negative failure message" do - @matcher.matches?(lambda{ throw :sym }) - @matcher.negative_failure_message.should == "expected :sym not to be thrown" + + describe "with a symbol" do + before(:each) { @matcher = ThrowSymbol.new(:sym) } + + it "should match if correct Symbol is thrown" do + @matcher.matches?(lambda{ throw :sym }).should be_true + end + it "should match if correct Symbol is thrown with an arg" do + @matcher.matches?(lambda{ throw :sym, "argument" }).should be_true + end + it "should not match if no Symbol is thrown" do + @matcher.matches?(lambda{ }).should be_false + end + it "should not match if correct Symbol is thrown" do + @matcher.matches?(lambda{ throw :other_sym }).should be_false + end + it "should provide a failure message when no Symbol is thrown" do + @matcher.matches?(lambda{}) + @matcher.failure_message_for_should.should == "expected :sym but nothing was thrown" + end + it "should provide a failure message when wrong Symbol is thrown" do + @matcher.matches?(lambda{ throw :other_sym }) + @matcher.failure_message_for_should.should == "expected :sym, got :other_sym" + end + it "should provide a negative failure message" do + @matcher.matches?(lambda{ throw :sym }) + @matcher.failure_message_for_should_not.should == "expected :sym not to be thrown" + end + it "should only match NameErrors raised by uncaught throws" do + @matcher.matches?(lambda{ sym }).should be_false + end end - it "should only match NameErrors raised by uncaught throws" do - @matcher.matches?(lambda{ sym }).should be_false + + describe "with a symbol and an arg" do + before(:each) { @matcher = ThrowSymbol.new(:sym, "a") } + + it "should match if correct Symbol and args are thrown" do + @matcher.matches?(lambda{ throw :sym, "a" }).should be_true + end + it "should not match if nothing is thrown" do + @matcher.matches?(lambda{ }).should be_false + end + it "should not match if other Symbol is thrown" do + @matcher.matches?(lambda{ throw :other_sym, "a" }).should be_false + end + it "should not match if no arg is thrown" do + @matcher.matches?(lambda{ throw :sym }).should be_false + end + it "should not match if wrong arg is thrown" do + @matcher.matches?(lambda{ throw :sym, "b" }).should be_false + end + it "should provide a failure message when no Symbol is thrown" do + @matcher.matches?(lambda{}) + @matcher.failure_message_for_should.should == %q[expected :sym with "a" but nothing was thrown] + end + it "should provide a failure message when wrong Symbol is thrown" do + @matcher.matches?(lambda{ throw :other_sym }) + @matcher.failure_message_for_should.should == %q[expected :sym with "a", got :other_sym] + end + it "should provide a negative failure message" do + @matcher.matches?(lambda{ throw :sym }) + @matcher.failure_message_for_should_not.should == %q[expected :sym with "a" not to be thrown] + end + it "should only match NameErrors raised by uncaught throws" do + @matcher.matches?(lambda{ sym }).should be_false + end end end end diff --git a/vendor/plugins/rspec/spec/spec/mocks/any_number_of_times_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/any_number_of_times_spec.rb index 3f50dcfc5..9a3f6edaf 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/any_number_of_times_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/any_number_of_times_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Mocks @@ -23,6 +23,13 @@ module Spec it "should pass if any number of times method is not called" do @mock.should_receive(:random_call).any_number_of_times end + + it "should return the mocked value when called after a similar stub" do + @mock.stub!(:message).and_return :stub_value + @mock.should_receive(:message).any_number_of_times.and_return(:mock_value) + @mock.message.should == :mock_value + @mock.message.should == :mock_value + end end end diff --git a/vendor/plugins/rspec/spec/spec/mocks/argument_expectation_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/argument_expectation_spec.rb index 2bebbdd4f..496f7507c 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/argument_expectation_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/argument_expectation_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Mocks diff --git a/vendor/plugins/rspec/spec/spec/mocks/at_least_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/at_least_spec.rb index 01b133dc3..0b76d3213 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/at_least_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/at_least_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Mocks diff --git a/vendor/plugins/rspec/spec/spec/mocks/at_most_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/at_most_spec.rb index f3c5e2150..744c9ff1b 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/at_most_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/at_most_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Mocks diff --git a/vendor/plugins/rspec/spec/spec/mocks/bug_report_10260_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/bug_report_10260_spec.rb index 2f7b5803d..783782f64 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/bug_report_10260_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/bug_report_10260_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' describe "An RSpec Mock" do it "should hide internals in its inspect representation" do diff --git a/vendor/plugins/rspec/spec/spec/mocks/bug_report_10263_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/bug_report_10263_spec.rb index e32192257..8a0bc505f 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/bug_report_10263_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/bug_report_10263_spec.rb @@ -7,7 +7,10 @@ describe "Mock" do @mock.should_receive(:msg) do |b| b.should be_true #this call exposes the problem end - @mock.msg(false) rescue nil + begin + @mock.msg(false) + rescue Exception + end end specify "then the next example should behave as expected instead of saying" do @@ -17,7 +20,7 @@ describe "Mock" do begin @mock.foobar rescue Exception => e - e.message.should == "Mock 'test mock' received unexpected message :foobar with (no args)" + e.message.should == "Mock \"test mock\" received unexpected message :foobar with (no args)" end end end diff --git a/vendor/plugins/rspec/spec/spec/mocks/bug_report_11545_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/bug_report_11545_spec.rb index 212a50e9f..7eb7c6e45 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/bug_report_11545_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/bug_report_11545_spec.rb @@ -1,13 +1,11 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' class LiarLiarPantsOnFire - include Spec::MetaClass - extend Spec::MetaClass - def respond_to?(sym) + def respond_to?(sym, incl_private=false) true end - def self.respond_to?(sym) + def self.respond_to?(sym, incl_private=false) true end end @@ -28,6 +26,7 @@ describe 'should_receive' do end it 'should cleanup after itself' do - LiarLiarPantsOnFire.metaclass.instance_methods.should_not include("something") + (class << LiarLiarPantsOnFire; self; end).instance_methods.should_not include("something") end end + diff --git a/vendor/plugins/rspec/spec/spec/mocks/bug_report_15719_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/bug_report_15719_spec.rb index 82d49ea97..efd7a7824 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/bug_report_15719_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/bug_report_15719_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Mocks @@ -9,7 +9,7 @@ module Spec m.should_receive(:bar).with("message") lambda { m.bar("different message") - }.should raise_error(Spec::Mocks::MockExpectationError, %Q{Mock 'foo' expected :bar with ("message") but received it with ("different message")}) + }.should raise_error(Spec::Mocks::MockExpectationError, %Q{Mock "foo" received :bar with unexpected arguments\n expected: ("message")\n got: ("different message")}) m.bar("message") # allows the spec to pass end @@ -22,7 +22,7 @@ module Spec m.should_receive(:bar).with("message") lambda { m.bar("different message") - }.should raise_error(Spec::Mocks::MockExpectationError, %Q{Mock 'foo' expected :bar with ("message") but received it with ("different message")}) + }.should raise_error(Spec::Mocks::MockExpectationError, %Q{Mock "foo" received :bar with unexpected arguments\n expected: ("message")\n got: ("different message")}) m.bar("message") # allows the spec to pass end end diff --git a/vendor/plugins/rspec/spec/spec/mocks/bug_report_7611_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/bug_report_7611_spec.rb index 6c9705bcc..ff1ef8795 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/bug_report_7611_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/bug_report_7611_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Bug7611 class Foo diff --git a/vendor/plugins/rspec/spec/spec/mocks/bug_report_7805_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/bug_report_7805_spec.rb index f7edfac17..9a3d493d9 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/bug_report_7805_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/bug_report_7805_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Bug7805 #This is really a duplicate of 8302 diff --git a/vendor/plugins/rspec/spec/spec/mocks/bug_report_8165_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/bug_report_8165_spec.rb index 7edc3c076..8d8d01772 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/bug_report_8165_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/bug_report_8165_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' describe "An object where respond_to? is true and does not have method" do # When should_receive(:sym) is sent to any object, the Proxy sends diff --git a/vendor/plugins/rspec/spec/spec/mocks/bug_report_8302_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/bug_report_8302_spec.rb index a41df43d8..55d8d3acd 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/bug_report_8302_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/bug_report_8302_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Bug8302 class Foo diff --git a/vendor/plugins/rspec/spec/spec/mocks/failing_mock_argument_constraints_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/failing_mock_argument_constraints_spec.rb deleted file mode 100644 index 3993cbfc6..000000000 --- a/vendor/plugins/rspec/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +++ /dev/null @@ -1,123 +0,0 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' - -module Spec - module Mocks - describe "failing MockArgumentConstraints" do - before(:each) do - @mock = mock("test mock") - @reporter = Mock.new("reporter", :null_object => true) - end - - after(:each) do - @mock.rspec_reset - end - - it "should reject non boolean" do - @mock.should_receive(:random_call).with(boolean()) - lambda do - @mock.random_call("false") - end.should raise_error(MockExpectationError) - end - - it "should reject non numeric" do - @mock.should_receive(:random_call).with(an_instance_of(Numeric)) - lambda do - @mock.random_call("1") - end.should raise_error(MockExpectationError) - end - - it "should reject non string" do - @mock.should_receive(:random_call).with(an_instance_of(String)) - lambda do - @mock.random_call(123) - end.should raise_error(MockExpectationError) - end - - it "should reject goose when expecting a duck" do - @mock.should_receive(:random_call).with(duck_type(:abs, :div)) - lambda { @mock.random_call("I don't respond to :abs or :div") }.should raise_error(MockExpectationError) - end - - it "should fail if regexp does not match submitted string" do - @mock.should_receive(:random_call).with(/bcd/) - lambda { @mock.random_call("abc") }.should raise_error(MockExpectationError) - end - - it "should fail if regexp does not match submitted regexp" do - @mock.should_receive(:random_call).with(/bcd/) - lambda { @mock.random_call(/bcde/) }.should raise_error(MockExpectationError) - end - - it "should fail for a hash w/ wrong values" do - @mock.should_receive(:random_call).with(:a => "b", :c => "d") - lambda do - @mock.random_call(:a => "b", :c => "e") - end.should raise_error(MockExpectationError, /Mock 'test mock' expected :random_call with \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\) but received it with \(\{(:a=>\"b\", :c=>\"e\"|:c=>\"e\", :a=>\"b\")\}\)/) - end - - it "should fail for a hash w/ wrong keys" do - @mock.should_receive(:random_call).with(:a => "b", :c => "d") - lambda do - @mock.random_call("a" => "b", "c" => "d") - end.should raise_error(MockExpectationError, /Mock 'test mock' expected :random_call with \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\) but received it with \(\{(\"a\"=>\"b\", \"c\"=>\"d\"|\"c\"=>\"d\", \"a\"=>\"b\")\}\)/) - end - - it "should match against a Matcher" do - lambda do - @mock.should_receive(:msg).with(equal(3)) - @mock.msg(37) - end.should raise_error(MockExpectationError, "Mock 'test mock' expected :msg with (equal 3) but received it with (37)") - end - - it "should fail no_args with one arg" do - lambda do - @mock.should_receive(:msg).with(no_args) - @mock.msg(37) - end.should raise_error(MockExpectationError, "Mock 'test mock' expected :msg with (no args) but received it with (37)") - end - - it "should fail hash_including with missing key" do - lambda do - @mock.should_receive(:msg).with(hash_including(:a => 1)) - @mock.msg({}) - end.should raise_error(MockExpectationError, "Mock 'test mock' expected :msg with (hash_including(:a=>1)) but received it with ({})") - end - - end - - describe "failing deprecated MockArgumentConstraints" do - before(:each) do - @mock = mock("test mock") - @reporter = Mock.new("reporter", :null_object => true) - Kernel.stub!(:warn) - end - - after(:each) do - @mock.rspec_reset - end - - it "should reject non boolean" do - @mock.should_receive(:random_call).with(:boolean) - lambda do - @mock.random_call("false") - end.should raise_error(MockExpectationError) - end - - it "should reject non numeric" do - @mock.should_receive(:random_call).with(:numeric) - lambda do - @mock.random_call("1") - end.should raise_error(MockExpectationError) - end - - it "should reject non string" do - @mock.should_receive(:random_call).with(:string) - lambda do - @mock.random_call(123) - end.should raise_error(MockExpectationError) - end - - - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/mocks/hash_including_matcher_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/hash_including_matcher_spec.rb index 29fae3101..d757f619a 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/hash_including_matcher_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/hash_including_matcher_spec.rb @@ -1,32 +1,90 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Mocks - describe HashIncludingConstraint do - - it "should match the same hash" do - hash_including(:a => 1).matches?(:a => 1).should be_true - end - - it "should not match a non-hash" do - hash_including(:a => 1).matches?(1).should_not be_true - end + module ArgumentMatchers + describe HashIncludingMatcher do + + it "should describe itself properly" do + HashIncludingMatcher.new(:a => 1).description.should == "hash_including(:a=>1)" + end - it "should match a hash with extra stuff" do - hash_including(:a => 1).matches?(:a => 1, :b => 2).should be_true - end - - it "should not match a hash with a missing key" do - hash_including(:a => 1).matches?(:b => 2).should_not be_true - end + describe "passing" do + it "should match the same hash" do + hash_including(:a => 1).should == {:a => 1} + end - it "should not match a hash with an incorrect value" do - hash_including(:a => 1, :b => 2).matches?(:a => 1, :b => 3).should_not be_true - end + it "should match a hash with extra stuff" do + hash_including(:a => 1).should == {:a => 1, :b => 2} + end + + describe "when matching against other matchers" do + it "should match an int against anything()" do + hash_including(:a => anything, :b => 2).should == {:a => 1, :b => 2} + end - it "should describe itself properly" do - HashIncludingConstraint.new(:a => 1).description.should == "hash_including(:a=>1)" - end + it "should match a string against anything()" do + hash_including(:a => anything, :b => 2).should == {:a => "1", :b => 2} + end + end + + describe "when passed only keys or keys mixed with key/value pairs" do + it "should match if the key is present" do + hash_including(:a).should == {:a => 1, :b => 2} + end + + it "should match if more keys are present" do + hash_including(:a, :b).should == {:a => 1, :b => 2, :c => 3} + end + + it "should match a string against a given key" do + hash_including(:a).should == {:a => "1", :b => 2} + end + + it "should match if passed one key and one key/value pair" do + hash_including(:a, :b => 2).should == {:a => 1, :b => 2} + end + + it "should match if passed many keys and one key/value pair" do + hash_including(:a, :b, :c => 3).should == {:a => 1, :b => 2, :c => 3, :d => 4} + end + + it "should match if passed many keys and many key/value pairs" do + hash_including(:a, :b, :c => 3, :e => 5).should == {:a => 1, :b => 2, :c => 3, :d => 4, :e => 5} + end + end + end + + describe "failing" do + it "should not match a non-hash" do + hash_including(:a => 1).should_not == 1 + end + + it "should not match a hash with a missing key" do + hash_including(:a => 1).should_not == {:b => 2} + end + + it "should not match a hash with a missing key" do + hash_including(:a).should_not == {:b => 2} + end + + it "should not match an empty hash with a given key" do + hash_including(:a).should_not == {} + end + + it "should not match a hash with a missing key when one pair is matching" do + hash_including(:a, :b => 2).should_not == {:b => 2} + end + + it "should not match a hash with an incorrect value" do + hash_including(:a => 1, :b => 2).should_not == {:a => 1, :b => 3} + end + + it "should not match when values are nil but keys are different" do + hash_including(:a => nil).should_not == {:b => nil} + end + end + end end - end -end
\ No newline at end of file + end +end diff --git a/vendor/plugins/rspec/spec/spec/mocks/mock_ordering_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/mock_ordering_spec.rb index 919da2970..4bd15478f 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/mock_ordering_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/mock_ordering_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper' +require 'spec_helper' module Spec module Mocks @@ -36,7 +36,7 @@ module Spec @mock.should_receive(:two).ordered lambda do @mock.two - end.should raise_error(MockExpectationError, "Mock 'test mock' received :two out of order") + end.should raise_error(MockExpectationError, "Mock \"test mock\" received :two out of order") end it "should fail if third call comes first" do @@ -46,7 +46,7 @@ module Spec @mock.one lambda do @mock.three - end.should raise_error(MockExpectationError, "Mock 'test mock' received :three out of order") + end.should raise_error(MockExpectationError, "Mock \"test mock\" received :three out of order") end it "should fail if third call comes second" do @@ -56,7 +56,7 @@ module Spec @mock.one lambda do @mock.three - end.should raise_error(MockExpectationError, "Mock 'test mock' received :three out of order") + end.should raise_error(MockExpectationError, "Mock \"test mock\" received :three out of order") end it "should ignore order of non ordered calls" do @@ -78,6 +78,16 @@ module Spec @mock.ignored_1 @mock.rspec_verify end + + it "should pass when duplicates exist" do + @mock.should_receive(:a).ordered + @mock.should_receive(:b).ordered + @mock.should_receive(:a).ordered + + @mock.a + @mock.b + @mock.a + end end end diff --git a/vendor/plugins/rspec/spec/spec/mocks/mock_space_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/mock_space_spec.rb index 23ffd01bc..878239307 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/mock_space_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/mock_space_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' require 'spec/mocks' module Spec diff --git a/vendor/plugins/rspec/spec/spec/mocks/mock_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/mock_spec.rb index f6d377f7d..9c636a338 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/mock_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/mock_spec.rb @@ -1,17 +1,33 @@ -require File.dirname(__FILE__) + '/../../spec_helper' +require 'spec_helper' module Spec module Mocks describe Mock do - + treats_method_missing_as_private :subject => Mock.new, :noop => false + before(:each) do @mock = mock("test mock") end - + after(:each) do @mock.rspec_reset end - + + describe "deprecated #stub_everything method" do + before(:each) do + Kernel.stub!(:warn) + end + + it "creates a mock that behaves as a null object" do + stub_everything.should be_null_object + end + + it "provides deprecation warning" do + Kernel.should_receive(:warn).with(/DEPRECATION: stub_everything.* is deprecated./) + stub_everything + end + end + it "should report line number of expectation of unreceived message" do expected_error_line = __LINE__; @mock.should_receive(:wont_happen).with("x", 3) begin @@ -22,92 +38,104 @@ module Spec e.backtrace[0].should match(/#{File.basename(__FILE__)}:#{expected_error_line}/) end end - + + it "should report line number of expectation of unreceived message after #should_receive after similar stub" do + @mock.stub!(:wont_happen) + expected_error_line = __LINE__; @mock.should_receive(:wont_happen).with("x", 3) + begin + @mock.rspec_verify + violated + rescue MockExpectationError => e + # NOTE - this regexp ended w/ $, but jruby adds extra info at the end of the line + e.backtrace[0].should match(/#{File.basename(__FILE__)}:#{expected_error_line}/) + end + end + it "should pass when not receiving message specified as not to be received" do @mock.should_not_receive(:not_expected) @mock.rspec_verify end - + it "should pass when receiving message specified as not to be received with different args" do @mock.should_not_receive(:message).with("unwanted text") @mock.should_receive(:message).with("other text") @mock.message "other text" @mock.rspec_verify end - + it "should fail when receiving message specified as not to be received" do @mock.should_not_receive(:not_expected) lambda { @mock.not_expected violated - }.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once") + }.should raise_error(MockExpectationError, "Mock \"test mock\" expected :not_expected with (no args) 0 times, but received it once") end - + it "should fail when receiving message specified as not to be received with args" do @mock.should_not_receive(:not_expected).with("unexpected text") lambda { @mock.not_expected("unexpected text") violated - }.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (\"unexpected text\") 0 times, but received it once") + }.should raise_error(MockExpectationError, "Mock \"test mock\" expected :not_expected with (\"unexpected text\") 0 times, but received it once") end - + it "should pass when receiving message specified as not to be received with wrong args" do @mock.should_not_receive(:not_expected).with("unexpected text") @mock.not_expected "really unexpected text" @mock.rspec_verify end - + it "should allow block to calculate return values" do @mock.should_receive(:something).with("a","b","c").and_return { |a,b,c| c+b+a } @mock.something("a","b","c").should == "cba" @mock.rspec_verify end - + it "should allow parameter as return value" do @mock.should_receive(:something).with("a","b","c").and_return("booh") @mock.something("a","b","c").should == "booh" @mock.rspec_verify end - + it "should return nil if no return value set" do @mock.should_receive(:something).with("a","b","c") @mock.something("a","b","c").should be_nil @mock.rspec_verify end - + it "should raise exception if args don't match when method called" do @mock.should_receive(:something).with("a","b","c").and_return("booh") lambda { @mock.something("a","d","c") violated - }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")") + }.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (\"a\", \"b\", \"c\")\n got: (\"a\", \"d\", \"c\")") end - + it "should raise exception if args don't match when method called even when the method is stubbed" do @mock.stub!(:something) @mock.should_receive(:something).with("a","b","c") lambda { @mock.something("a","d","c") @mock.rspec_verify - }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")") + }.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (\"a\", \"b\", \"c\")\n got: ([\"a\", \"d\", \"c\"])") end - + it "should raise exception if args don't match when method called even when using null_object" do @mock = mock("test mock", :null_object => true) @mock.should_receive(:something).with("a","b","c") lambda { @mock.something("a","d","c") @mock.rspec_verify - }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")") + }.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (\"a\", \"b\", \"c\")\n got: ([\"a\", \"d\", \"c\"])") end - + it "should fail if unexpected method called" do lambda { @mock.something("a","b","c") violated - }.should raise_error(MockExpectationError, "Mock 'test mock' received unexpected message :something with (\"a\", \"b\", \"c\")") + }.should raise_error(MockExpectationError, "Mock \"test mock\" received unexpected message :something with (\"a\", \"b\", \"c\")") end - + it "should use block for expectation if provided" do @mock.should_receive(:something) do | a, b | a.should == "a" @@ -117,35 +145,35 @@ module Spec @mock.something("a", "b").should == "booh" @mock.rspec_verify end - + it "should fail if expectation block fails" do @mock.should_receive(:something) {| bool | bool.should be_true} lambda { @mock.something false - }.should raise_error(MockExpectationError, /Mock 'test mock' received :something but passed block failed with: expected true, got false/) + }.should raise_error(MockExpectationError, /Mock "test mock" received :something but passed block failed with: expected true, got false/) end - + it "should fail right away when method defined as never is received" do @mock.should_receive(:not_expected).never lambda { @mock.not_expected - }.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once") + }.should raise_error(MockExpectationError, "Mock \"test mock\" expected :not_expected with (no args) 0 times, but received it once") end - + it "should eventually fail when method defined as never is received" do @mock.should_receive(:not_expected).never lambda { @mock.not_expected - }.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once") + }.should raise_error(MockExpectationError, "Mock \"test mock\" expected :not_expected with (no args) 0 times, but received it once") end - + it "should raise when told to" do @mock.should_receive(:something).and_raise(RuntimeError) lambda do @mock.something end.should raise_error(RuntimeError) end - + it "should raise passed an Exception instance" do error = RuntimeError.new("error message") @mock.should_receive(:something).and_raise(error) @@ -153,28 +181,28 @@ module Spec @mock.something }.should raise_error(RuntimeError, "error message") end - + it "should raise RuntimeError with passed message" do @mock.should_receive(:something).and_raise("error message") lambda { @mock.something }.should raise_error(RuntimeError, "error message") end - + it "should not raise when told to if args dont match" do @mock.should_receive(:something).with(2).and_raise(RuntimeError) lambda { @mock.something 1 }.should raise_error(MockExpectationError) end - + it "should throw when told to" do @mock.should_receive(:something).and_throw(:blech) lambda { @mock.something }.should throw_symbol(:blech) end - + it "should raise when explicit return and block constrained" do lambda { @mock.should_receive(:fruit) do |colour| @@ -182,7 +210,7 @@ module Spec end.and_return :apple }.should raise_error(AmbiguousReturnError) end - + it "should ignore args on any args" do @mock.should_receive(:something).at_least(:once).with(any_args) @mock.something @@ -191,35 +219,35 @@ module Spec @mock.something [], {}, "joe", 7 @mock.rspec_verify end - + it "should fail on no args if any args received" do @mock.should_receive(:something).with(no_args()) lambda { @mock.something 1 - }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (no args) but received it with (1)") + }.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (no args)\n got: (1)") end - + it "should fail when args are expected but none are received" do @mock.should_receive(:something).with(1) lambda { @mock.something - }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (1) but received it with (no args)") + }.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (1)\n got: (no args)") end - + it "should return value from block by default" do @mock.stub!(:method_that_yields).and_yield @mock.method_that_yields { :returned_obj }.should == :returned_obj @mock.rspec_verify end - + it "should yield 0 args to blocks that take a variable number of arguments" do @mock.should_receive(:yield_back).with(no_args()).once.and_yield a = nil - @mock.yield_back {|*a|} + @mock.yield_back {|*x| a = x} a.should == [] @mock.rspec_verify end - + it "should yield 0 args multiple times to blocks that take a variable number of arguments" do @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield. and_yield @@ -229,15 +257,15 @@ module Spec b.should == [ [], [] ] @mock.rspec_verify end - + it "should yield one arg to blocks that take a variable number of arguments" do @mock.should_receive(:yield_back).with(no_args()).once.and_yield(99) a = nil - @mock.yield_back {|*a|} + @mock.yield_back {|*x| a = x} a.should == [99] @mock.rspec_verify end - + it "should yield one arg 3 times consecutively to blocks that take a variable number of arguments" do @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield(99). and_yield(43). @@ -248,15 +276,15 @@ module Spec b.should == [[99], [43], ["something fruity"]] @mock.rspec_verify end - + it "should yield many args to blocks that take a variable number of arguments" do @mock.should_receive(:yield_back).with(no_args()).once.and_yield(99, 27, "go") a = nil - @mock.yield_back {|*a|} + @mock.yield_back {|*x| a = x} a.should == [99, 27, "go"] @mock.rspec_verify end - + it "should yield many args 3 times consecutively to blocks that take a variable number of arguments" do @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield(99, :green, "go"). and_yield("wait", :amber). @@ -267,15 +295,15 @@ module Spec b.should == [[99, :green, "go"], ["wait", :amber], ["stop", 12, :red]] @mock.rspec_verify end - + it "should yield single value" do @mock.should_receive(:yield_back).with(no_args()).once.and_yield(99) a = nil - @mock.yield_back {|a|} + @mock.yield_back {|x| a = x} a.should == 99 @mock.rspec_verify end - + it "should yield single value 3 times consecutively" do @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield(99). and_yield(43). @@ -286,16 +314,16 @@ module Spec b.should == [99, 43, "something fruity"] @mock.rspec_verify end - + it "should yield two values" do @mock.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup') a, b = nil - @mock.yield_back {|a,b|} + @mock.yield_back {|x,y| a=x; b=y} a.should == 'wha' b.should == 'zup' @mock.rspec_verify end - + it "should yield two values 3 times consecutively" do @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield('wha', 'zup'). and_yield('not', 'down'). @@ -306,14 +334,14 @@ module Spec c.should == [['wha', 'zup'], ['not', 'down'], [14, 65]] @mock.rspec_verify end - + it "should fail when calling yielding method with wrong arity" do @mock.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup') lambda { @mock.yield_back {|a|} - }.should raise_error(MockExpectationError, "Mock 'test mock' yielded |\"wha\", \"zup\"| to block with arity of 1") + }.should raise_error(MockExpectationError, "Mock \"test mock\" yielded |\"wha\", \"zup\"| to block with arity of 1") end - + it "should fail when calling yielding method consecutively with wrong arity" do @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield('wha', 'zup'). and_yield('down'). @@ -322,79 +350,79 @@ module Spec a, b = nil c = [] @mock.yield_back {|a,b| c << [a, b]} - }.should raise_error(MockExpectationError, "Mock 'test mock' yielded |\"down\"| to block with arity of 2") + }.should raise_error(MockExpectationError, "Mock \"test mock\" yielded |\"down\"| to block with arity of 2") end - + it "should fail when calling yielding method without block" do @mock.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup') lambda { @mock.yield_back - }.should raise_error(MockExpectationError, "Mock 'test mock' asked to yield |[\"wha\", \"zup\"]| but no block was passed") + }.should raise_error(MockExpectationError, "Mock \"test mock\" asked to yield |[\"wha\", \"zup\"]| but no block was passed") end - + it "should be able to mock send" do @mock.should_receive(:send).with(any_args) @mock.send 'hi' @mock.rspec_verify end - + it "should be able to raise from method calling yielding mock" do @mock.should_receive(:yield_me).and_yield 44 - + lambda { @mock.yield_me do |x| raise "Bang" end }.should raise_error(StandardError, "Bang") - + @mock.rspec_verify end - + it "should clear expectations after verify" do @mock.should_receive(:foobar) @mock.foobar @mock.rspec_verify lambda { @mock.foobar - }.should raise_error(MockExpectationError, "Mock 'test mock' received unexpected message :foobar with (no args)") + }.should raise_error(MockExpectationError, "Mock \"test mock\" received unexpected message :foobar with (no args)") end - + it "should restore objects to their original state on rspec_reset" do mock = mock("this is a mock") mock.should_receive(:blah) mock.rspec_reset mock.rspec_verify #should throw if reset didn't work end - + it "should work even after method_missing starts raising NameErrors instead of NoMethodErrors" do # Object#method_missing throws either NameErrors or NoMethodErrors. # - # On a fresh ruby program Object#method_missing: + # On a fresh ruby program Object#method_missing: # * raises a NoMethodError when called directly # * raises a NameError when called indirectly # # Once Object#method_missing has been called at least once (on any object) - # it starts behaving differently: + # it starts behaving differently: # * raises a NameError when called directly # * raises a NameError when called indirectly # # There was a bug in Mock#method_missing that relied on the fact # that calling Object#method_missing directly raises a NoMethodError. # This example tests that the bug doesn't exist anymore. - - + + # Ensures that method_missing always raises NameErrors. a_method_that_doesnt_exist rescue - - + + @mock.should_receive(:foobar) @mock.foobar @mock.rspec_verify - + lambda { @mock.foobar }.should_not raise_error(NameError) lambda { @mock.foobar }.should raise_error(MockExpectationError) end - + it "should temporarily replace a method stub on a mock" do @mock.stub!(:msg).and_return(:stub_value) @mock.should_receive(:msg).with(:arg).and_return(:mock_value) @@ -403,7 +431,22 @@ module Spec @mock.msg.should equal(:stub_value) @mock.rspec_verify end - + + it "should not require a different signature to replace a method stub" do + @mock.stub!(:msg).and_return(:stub_value) + @mock.should_receive(:msg).and_return(:mock_value) + @mock.msg(:arg).should equal(:mock_value) + @mock.msg.should equal(:stub_value) + @mock.msg.should equal(:stub_value) + @mock.rspec_verify + end + + it "should raise an error when a previously stubbed method has a negative expectation" do + @mock.stub!(:msg).and_return(:stub_value) + @mock.should_not_receive(:msg).and_return(:mock_value) + lambda {@mock.msg(:arg)}.should raise_error(MockExpectationError) + end + it "should temporarily replace a method stub on a non-mock" do non_mock = Object.new non_mock.stub!(:msg).and_return(:stub_value) @@ -413,82 +456,139 @@ module Spec non_mock.msg.should equal(:stub_value) non_mock.rspec_verify end - + + it "should return the stubbed value when no new value specified" do + @mock.stub!(:msg).and_return(:stub_value) + @mock.should_receive(:msg) + @mock.msg.should equal(:stub_value) + @mock.rspec_verify + end + + it "should not mess with the stub's yielded values when also mocked" do + @mock.stub!(:yield_back).and_yield(:stub_value) + @mock.should_receive(:yield_back).and_yield(:mock_value) + @mock.yield_back{|v| v.should == :mock_value } + @mock.yield_back{|v| v.should == :stub_value } + @mock.rspec_verify + end + + it "should yield multiple values after a similar stub" do + File.stub!(:open).and_yield(:stub_value) + File.should_receive(:open).and_yield(:first_call).and_yield(:second_call) + yielded_args = [] + File.open {|v| yielded_args << v } + yielded_args.should == [:first_call, :second_call] + File.open {|v| v.should == :stub_value } + File.rspec_verify + end + it "should assign stub return values" do mock = Mock.new('name', :message => :response) mock.message.should == :response end - + end - + describe "a mock message receiving a block" do before(:each) do @mock = mock("mock") @calls = 0 end - + def add_call @calls = @calls + 1 end - + it "should call the block after #should_receive" do @mock.should_receive(:foo) { add_call } - + + @mock.foo + + @calls.should == 1 + end + + it "should call the block after #should_receive after a similar stub" do + @mock.stub!(:foo).and_return(:bar) + @mock.should_receive(:foo) { add_call } + @mock.foo - + @calls.should == 1 end - + it "should call the block after #once" do @mock.should_receive(:foo).once { add_call } - + @mock.foo - + @calls.should == 1 end - + it "should call the block after #twice" do @mock.should_receive(:foo).twice { add_call } - + @mock.foo @mock.foo - + @calls.should == 2 end - + it "should call the block after #times" do @mock.should_receive(:foo).exactly(10).times { add_call } - + (1..10).each { @mock.foo } - + @calls.should == 10 end - + it "should call the block after #any_number_of_times" do @mock.should_receive(:foo).any_number_of_times { add_call } - + (1..7).each { @mock.foo } - + @calls.should == 7 end - - it "should call the block after #with" do - @mock.should_receive(:foo).with(:arg) { add_call } - - @mock.foo(:arg) - - @calls.should == 1 - end - + it "should call the block after #ordered" do @mock.should_receive(:foo).ordered { add_call } @mock.should_receive(:bar).ordered { add_call } - + @mock.foo @mock.bar - + @calls.should == 2 end end + + describe 'string representation generated by #to_s' do + it 'should not contain < because that might lead to invalid HTML in some situations' do + mock = mock("Dog") + valid_html_str = "#{mock}" + valid_html_str.should_not include('<') + end + end + + describe "mock created with no name" do + it "should not use a name in a failure message" do + mock = mock() + expect {mock.foo}.to raise_error(/Mock received/) + end + + it "should respond to initially stubbed methods" do + mock = mock(:foo => "woo", :bar => "car") + mock.foo.should == "woo" + mock.bar.should == "car" + end + end + + describe "==" do + it "sends '== self' to the comparison object" do + first = mock('first') + second = mock('second') + + first.should_receive(:==).with(second) + second == first + end + end end end diff --git a/vendor/plugins/rspec/spec/spec/mocks/multiple_return_value_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/multiple_return_value_spec.rb index 3e26b73f4..08a6b066c 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/multiple_return_value_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/multiple_return_value_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper' +require 'spec_helper' module Spec module Mocks @@ -20,7 +20,7 @@ module Spec third = Object.new @mock.message.should == @return_values[0] @mock.message.should == @return_values[1] - lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it twice") + lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it twice") end it "should complain when there are too many calls" do @@ -29,7 +29,7 @@ module Spec @mock.message.should == @return_values[1] @mock.message.should == @return_values[2] @mock.message.should == @return_values[2] - lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it 4 times") + lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it 4 times") end end @@ -51,7 +51,7 @@ module Spec third = Object.new @mock.message.should == @return_values[0] @mock.message.should == @return_values[1] - lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it twice") + lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it twice") end it "should complain when there are too many calls" do @@ -60,7 +60,7 @@ module Spec @mock.message.should == @return_values[1] @mock.message.should == @return_values[2] @mock.message.should == @return_values[2] - lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it 4 times") + lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it 4 times") end end @@ -79,7 +79,7 @@ module Spec it "should fail when called less than the specified number" do @mock.message.should equal(11) - lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (no args) twice, but received it once") + lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (no args) twice, but received it once") end end describe "a Mock expectation with multiple return values with a specified count larger than the number of values" do @@ -97,7 +97,7 @@ module Spec it "should fail when called less than the specified number" do @mock.message.should equal(11) - lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it once") + lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it once") end it "should fail when called greater than the specified number" do @@ -105,7 +105,7 @@ module Spec @mock.message.should equal(22) @mock.message.should equal(22) @mock.message.should equal(22) - lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it 4 times") + lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it 4 times") end end end diff --git a/vendor/plugins/rspec/spec/spec/mocks/null_object_mock_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/null_object_mock_spec.rb index 57e8ca31c..8af6b49d7 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/null_object_mock_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/null_object_mock_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Mocks @@ -36,5 +36,19 @@ module Spec @mock.message(:unexpected_arg) end end + + describe "#null_object?" do + it "should default to false" do + obj = mock('anything') + obj.should_not be_null_object + end + end + + describe "#as_null_object" do + it "should set the object to null_object" do + obj = mock('anything').as_null_object + obj.should be_null_object + end + end end end diff --git a/vendor/plugins/rspec/spec/spec/mocks/once_counts_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/once_counts_spec.rb index 2c15d5c2e..951298321 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/once_counts_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/once_counts_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Mocks diff --git a/vendor/plugins/rspec/spec/spec/mocks/options_hash_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/options_hash_spec.rb index 0bfab26d7..f82757827 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/options_hash_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/options_hash_spec.rb @@ -1,44 +1,34 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Mocks describe "calling :should_receive with an options hash" do - it_should_behave_like "sandboxed rspec_options" - attr_reader :reporter, :example_group - before do - @reporter = ::Spec::Runner::Reporter.new(options) - @example_group = Class.new(::Spec::Example::ExampleGroup) do - plugin_mock_framework - describe("Some Examples") - end - reporter.add_example_group example_group - end - it "should report the file and line submitted with :expected_from" do - example_definition = example_group.it "spec" do + begin mock = Spec::Mocks::Mock.new("a mock") mock.should_receive(:message, :expected_from => "/path/to/blah.ext:37") mock.rspec_verify + rescue Exception => e + ensure + e.backtrace.to_s.should =~ /\/path\/to\/blah.ext:37/m end - example = example_group.new(example_definition) - - reporter.should_receive(:example_finished) do |spec, error| - error.backtrace.detect {|line| line =~ /\/path\/to\/blah.ext:37/}.should_not be_nil - end - example.execute(options, {}) end it "should use the message supplied with :message" do - example_definition = @example_group.it "spec" do - mock = Spec::Mocks::Mock.new("a mock") - mock.should_receive(:message, :message => "recebi nada") - mock.rspec_verify - end - example = @example_group.new(example_definition) - @reporter.should_receive(:example_finished) do |spec, error| - error.message.should == "recebi nada" - end - example.execute(@options, {}) + lambda { + m = Spec::Mocks::Mock.new("a mock") + m.should_receive(:message, :message => "recebi nada") + m.rspec_verify + }.should raise_error("recebi nada") + end + + it "should use the message supplied with :message after a similar stub" do + lambda { + m = Spec::Mocks::Mock.new("a mock") + m.stub!(:message) + m.should_receive(:message, :message => "from mock") + m.rspec_verify + }.should raise_error("from mock") end end end diff --git a/vendor/plugins/rspec/spec/spec/mocks/partial_mock_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/partial_mock_spec.rb index 25472557f..c19ecd304 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/partial_mock_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/partial_mock_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Mocks @@ -11,7 +11,14 @@ module Spec @object.should_receive(:foo) lambda do @object.rspec_verify - end.should raise_error(Spec::Mocks::MockExpectationError, /Object/) + end.should raise_error(Spec::Mocks::MockExpectationError, /<Object:.*> expected/) + end + + it "should name the class in the failure message when expectation is on class" do + Object.should_receive(:foo) + lambda do + Object.rspec_verify + end.should raise_error(Spec::Mocks::MockExpectationError, /<Object \(class\)>/) end it "should not conflict with @options in the object" do @@ -21,11 +28,10 @@ module Spec end it "should_not_receive should mock out the method" do - pending("example raises the expected error, yet fails") @object.should_not_receive(:fuhbar) lambda do @object.fuhbar - end.should raise_error(MockExpectationError, "Mock 'Object' expected :fuhbar with (no args) 0 times, but received it once") + end.should raise_error(MockExpectationError, /<Object:.*> expected :fuhbar with \(no args\) 0 times/) end it "should_not_receive should return a negative message expectation" do @@ -66,7 +72,6 @@ module Spec end it "should_not_receive should also take a String argument" do - pending("example raises the expected error, yet fails") @object.should_not_receive('foobar') lambda do @object.foobar @@ -74,10 +79,12 @@ module Spec end it "should use report nil in the error message" do + allow_message_expectations_on_nil + @this_will_resolve_to_nil.should_receive(:foobar) lambda do @this_will_resolve_to_nil.rspec_verify - end.should raise_error(Spec::Mocks::MockExpectationError, /NilClass.*expected :foobar with/) + end.should raise_error(Spec::Mocks::MockExpectationError, /nil expected :foobar with/) end end @@ -121,19 +128,34 @@ module Spec it 'should keep public methods public' do @object.should_receive(:public_method) - @object.public_methods.should include('public_method') + with_ruby('1.9') do + @object.public_methods.should include(:public_method) + end + with_ruby('1.8') do + @object.public_methods.should include('public_method') + end @object.public_method end it 'should keep private methods private' do @object.should_receive(:private_method) - @object.private_methods.should include('private_method') + with_ruby('1.9') do + @object.private_methods.should include(:private_method) + end + with_ruby('1.8') do + @object.private_methods.should include('private_method') + end @object.public_method end it 'should keep protected methods protected' do @object.should_receive(:protected_method) - @object.protected_methods.should include('protected_method') + with_ruby('1.9') do + @object.protected_methods.should include(:protected_method) + end + with_ruby('1.8') do + @object.protected_methods.should include('protected_method') + end @object.public_method end diff --git a/vendor/plugins/rspec/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb index c857d8380..a69aa6ac0 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Mocks diff --git a/vendor/plugins/rspec/spec/spec/mocks/passing_mock_argument_constraints_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/passing_mock_argument_constraints_spec.rb deleted file mode 100644 index 057af44fa..000000000 --- a/vendor/plugins/rspec/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +++ /dev/null @@ -1,160 +0,0 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' - -module Spec - module Mocks - describe "mock argument constraints", :shared => true do - before(:each) do - @mock = Mock.new("test mock") - Kernel.stub!(:warn) - end - - after(:each) do - @mock.rspec_verify - end - end - - describe Methods, "handling argument constraints with DEPRECATED symbols" do - it_should_behave_like "mock argument constraints" - - it "should accept true as boolean" do - @mock.should_receive(:random_call).with(:boolean) - @mock.random_call(true) - end - - it "should accept false as boolean" do - @mock.should_receive(:random_call).with(:boolean) - @mock.random_call(false) - end - - it "should accept fixnum as numeric" do - @mock.should_receive(:random_call).with(:numeric) - @mock.random_call(1) - end - - it "should accept float as numeric" do - @mock.should_receive(:random_call).with(:numeric) - @mock.random_call(1.5) - end - - it "should accept string as anything" do - @mock.should_receive(:random_call).with("a", :anything, "c") - @mock.random_call("a", "whatever", "c") - end - - it "should match string" do - @mock.should_receive(:random_call).with(:string) - @mock.random_call("a string") - end - - it "should match no args against any_args" do - @mock.should_receive(:random_call).with(:any_args) - @mock.random_call("a string") - end - - it "should match no args against no_args" do - @mock.should_receive(:random_call).with(:no_args) - @mock.random_call - end - end - - describe Methods, "handling argument constraints" do - it_should_behave_like "mock argument constraints" - - it "should accept true as boolean()" do - @mock.should_receive(:random_call).with(boolean()) - @mock.random_call(true) - end - - it "should accept false as boolean()" do - @mock.should_receive(:random_call).with(boolean()) - @mock.random_call(false) - end - - it "should accept fixnum as an_instance_of(Numeric)" do - @mock.should_receive(:random_call).with(an_instance_of(Numeric)) - @mock.random_call(1) - end - - it "should accept float as an_instance_of(Numeric)" do - @mock.should_receive(:random_call).with(an_instance_of(Numeric)) - @mock.random_call(1.5) - end - - it "should accept string as anything()" do - @mock.should_receive(:random_call).with("a", anything(), "c") - @mock.random_call("a", "whatever", "c") - end - - it "should match duck type with one method" do - @mock.should_receive(:random_call).with(duck_type(:length)) - @mock.random_call([]) - end - - it "should match duck type with two methods" do - @mock.should_receive(:random_call).with(duck_type(:abs, :div)) - @mock.random_call(1) - end - - it "should match no args against any_args()" do - @mock.should_receive(:random_call).with(any_args) - @mock.random_call() - end - - it "should match one arg against any_args()" do - @mock.should_receive(:random_call).with(any_args) - @mock.random_call("a string") - end - - it "should match no args against no_args()" do - @mock.should_receive(:random_call).with(no_args) - @mock.random_call() - end - - it "should match hash with hash_including same hash" do - @mock.should_receive(:random_call).with(hash_including(:a => 1)) - @mock.random_call(:a => 1) - end - - end - - describe Methods, "handling non-constraint arguments" do - - it "should match non special symbol (can be removed when deprecated symbols are removed)" do - @mock.should_receive(:random_call).with(:some_symbol) - @mock.random_call(:some_symbol) - end - - it "should match string against regexp" do - @mock.should_receive(:random_call).with(/bcd/) - @mock.random_call("abcde") - end - - it "should match regexp against regexp" do - @mock.should_receive(:random_call).with(/bcd/) - @mock.random_call(/bcd/) - end - - it "should match against a hash submitted and received by value" do - @mock.should_receive(:random_call).with(:a => "a", :b => "b") - @mock.random_call(:a => "a", :b => "b") - end - - it "should match against a hash submitted by reference and received by value" do - opts = {:a => "a", :b => "b"} - @mock.should_receive(:random_call).with(opts) - @mock.random_call(:a => "a", :b => "b") - end - - it "should match against a hash submitted by value and received by reference" do - opts = {:a => "a", :b => "b"} - @mock.should_receive(:random_call).with(:a => "a", :b => "b") - @mock.random_call(opts) - end - - it "should match against a Matcher" do - @mock.should_receive(:msg).with(equal(37)) - @mock.msg(37) - end - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/mocks/precise_counts_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/precise_counts_spec.rb index ba3898943..5b64ef281 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/precise_counts_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/precise_counts_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Mocks diff --git a/vendor/plugins/rspec/spec/spec/mocks/record_messages_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/record_messages_spec.rb index ec247726d..bed2fbff6 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/record_messages_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/record_messages_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper' +require 'spec_helper' module Spec module Mocks diff --git a/vendor/plugins/rspec/spec/spec/mocks/stub_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/stub_spec.rb index d6e23d71e..e0b7b2640 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/stub_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/stub_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Mocks @@ -14,12 +14,17 @@ module Spec end end @instance = @class.new + @stub = Object.new end - it "should return expected value when expected message is received" do - @instance.stub!(:msg).and_return(:return_value) - @instance.msg.should equal(:return_value) - @instance.rspec_verify + [:stub!, :stub].each do |method| + context "using #{method}" do + it "should return expected value when expected message is received" do + @instance.send(method, :msg).and_return(:return_value) + @instance.msg.should equal(:return_value) + @instance.rspec_verify + end + end end it "should ignore when expected message is received" do @@ -44,7 +49,13 @@ module Spec @instance.rspec_verify end.should_not raise_error end - + + it "should handle multiple stubbed methods" do + @instance.stub!(:msg1 => 1, :msg2 => 2) + @instance.msg1.should == 1 + @instance.msg2.should == 2 + end + it "should clear itself when verified" do @instance.stub!(:this_should_go).and_return(:blah) @instance.this_should_go.should == :blah @@ -79,7 +90,7 @@ module Spec @instance.rspec_verify @instance.existing_instance_method.should equal(:original_value) end - + it "should revert to original class method if there is one" do @class.existing_class_method.should equal(:original_value) @class.stub!(:existing_class_method).and_return(:mock_value) @@ -104,7 +115,7 @@ module Spec current_value.should == [:yielded_value, :another_value] @instance.rspec_verify end - + it "should yield a specified object and return another specified object" do yielded_obj = mock("my mock") yielded_obj.should_receive(:foo).with(:bar) @@ -118,20 +129,26 @@ module Spec @mock.something end.should throw_symbol(:up) end - + it "should override a pre-existing stub" do @stub.stub!(:existing_instance_method).and_return(:updated_stub_value) @stub.existing_instance_method.should == :updated_stub_value end - + it "should limit " do @stub.stub!(:foo).with("bar") @stub.should_receive(:foo).with("baz") @stub.foo("bar") @stub.foo("baz") end + + it "calculates return value by executing block passed to #and_return" do + @mock.stub!(:something).with("a","b","c").and_return { |a,b,c| c+b+a } + @mock.something("a","b","c").should == "cba" + @mock.rspec_verify + end end - + describe "A method stub with args" do before(:each) do @stub = Object.new @@ -171,10 +188,15 @@ module Spec @stub.foo("other") end.should raise_error end - + it "should support options" do @stub.stub!(:foo, :expected_from => "bar") end + + it "should use 'Stub' in the failure message" do + stub = stub('name') + expect {stub.foo}.to raise_error(/Stub "name" received/) + end end end diff --git a/vendor/plugins/rspec/spec/spec/mocks/twice_counts_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/twice_counts_spec.rb index d07e45736..4538eb8f9 100644 --- a/vendor/plugins/rspec/spec/spec/mocks/twice_counts_spec.rb +++ b/vendor/plugins/rspec/spec/spec/mocks/twice_counts_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Mocks diff --git a/vendor/plugins/rspec/spec/spec/package/bin_spec_spec.rb b/vendor/plugins/rspec/spec/spec/package/bin_spec_spec.rb index 44bfd96a0..6628fad72 100644 --- a/vendor/plugins/rspec/spec/spec/package/bin_spec_spec.rb +++ b/vendor/plugins/rspec/spec/spec/package/bin_spec_spec.rb @@ -1,14 +1,16 @@ -require File.dirname(__FILE__) + '/../../spec_helper' -require File.dirname(__FILE__) + '/../../ruby_forker' +require 'spec_helper' +require 'ruby_forker' describe "The bin/spec script" do include RubyForker it "should have no warnings" do - pending "Hangs on JRuby" if PLATFORM =~ /java/ - spec_path = "#{File.dirname(__FILE__)}/../../../bin/spec" - - output = ruby "-w #{spec_path} --help 2>&1" + output = ruby "-w -Ilib bin/spec --help" output.should_not =~ /warning/n end + + it "should show the help w/ no args" do + output = ruby "-w -Ilib bin/spec" + output.should =~ /^Usage: spec/ + end end diff --git a/vendor/plugins/rspec/spec/spec/runner/class_and_argument_parser_spec.rb b/vendor/plugins/rspec/spec/spec/runner/class_and_argument_parser_spec.rb index b4e9e7f53..1168818f0 100644 --- a/vendor/plugins/rspec/spec/spec/runner/class_and_argument_parser_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/class_and_argument_parser_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Runner diff --git a/vendor/plugins/rspec/spec/spec/runner/command_line_spec.rb b/vendor/plugins/rspec/spec/spec/runner/command_line_spec.rb index 3c3be8cea..c22b30668 100644 --- a/vendor/plugins/rspec/spec/spec/runner/command_line_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/command_line_spec.rb @@ -1,146 +1,140 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Runner describe CommandLine, ".run" do - it_should_behave_like "sandboxed rspec_options" - attr_reader :options, :err, :out - before do - @err = options.error_stream - @out = options.output_stream - end - - it "should run directory" do - file = File.dirname(__FILE__) + '/../../../examples/pure' - Spec::Runner::CommandLine.run(OptionParser.parse([file,"-p","**/*.rb"], @err, @out)) + with_sandboxed_options do + attr_reader :err, :out + before do + @err = options.error_stream + @out = options.output_stream + end + + it "should run directory" do + file = File.dirname(__FILE__) + '/../../../examples/passing' + run_with(OptionParser.parse([file,"-p","**/*_spec.rb,**/*_example.rb"], @err, @out)) - @out.rewind - @out.read.should =~ /\d+ examples, 0 failures, 3 pending/n - end + @out.rewind + @out.read.should =~ /\d+ examples, 0 failures, 3 pending/n + end - it "should run file" do - file = File.dirname(__FILE__) + '/../../../failing_examples/predicate_example.rb' - Spec::Runner::CommandLine.run(OptionParser.parse([file], @err, @out)) + it "should run file" do + file = File.dirname(__FILE__) + '/../../../examples/failing/predicate_example.rb' + run_with(OptionParser.parse([file], @err, @out)) - @out.rewind - @out.read.should =~ /2 examples, 1 failure/n - end + @out.rewind + @out.read.should =~ /3 examples, 2 failures/n + end - it "should raise when file does not exist" do - file = File.dirname(__FILE__) + '/doesntexist' + it "should raise when file does not exist" do + file = File.dirname(__FILE__) + '/doesntexist' - lambda { - Spec::Runner::CommandLine.run(OptionParser.parse([file], @err, @out)) - }.should raise_error - end + lambda { + Spec::Runner::CommandLine.run(OptionParser.parse([file], @err, @out)) + }.should raise_error + end - it "should return true when in --generate-options mode" do - # NOTE - this used to say /dev/null but jruby hangs on that for some reason - Spec::Runner::CommandLine.run( - OptionParser.parse(['--generate-options', '/tmp/foo'], @err, @out) - ).should be_true - end + it "should return true when in --generate-options mode" do + # NOTE - this used to say /dev/null but jruby hangs on that for some reason + Spec::Runner::CommandLine.run( + OptionParser.parse(['--generate-options', '/tmp/foo'], @err, @out) + ).should be_true + end - it "should dump even if Interrupt exception is occurred" do - example_group = Class.new(::Spec::Example::ExampleGroup) do - describe("example_group") - it "no error" do - end + it "should dump even if Interrupt exception is occurred" do + example_group = Class.new(::Spec::Example::ExampleGroup) do + describe("example_group") + it "no error" do + end - it "should interrupt" do - raise Interrupt, "I'm interrupting" + it "should interrupt" do + raise Interrupt, "I'm interrupting" + end end - end - options = ::Spec::Runner::Options.new(@err, @out) - ::Spec::Runner::Options.should_receive(:new).with(@err, @out).and_return(options) - options.reporter.should_receive(:dump) - options.add_example_group(example_group) + options = ::Spec::Runner::Options.new(@err, @out) + ::Spec::Runner::Options.should_receive(:new).with(@err, @out).and_return(options) + options.reporter.should_receive(:dump) + options.add_example_group(example_group) - Spec::Runner::CommandLine.run(OptionParser.parse([], @err, @out)) - end + Spec::Runner::CommandLine.run(OptionParser.parse([], @err, @out)) + end - it "should heckle when options have heckle_runner" do - example_group = Class.new(::Spec::Example::ExampleGroup).describe("example_group") do - it "no error" do + it "should heckle when options have heckle_runner" do + example_group = Class.new(::Spec::Example::ExampleGroup).describe("example_group") do + it "no error" do + end end - end - options = ::Spec::Runner::Options.new(@err, @out) - ::Spec::Runner::Options.should_receive(:new).with(@err, @out).and_return(options) - options.add_example_group example_group + options = ::Spec::Runner::Options.new(@err, @out) + ::Spec::Runner::Options.should_receive(:new).with(@err, @out).and_return(options) + options.add_example_group example_group - heckle_runner = mock("heckle_runner") - heckle_runner.should_receive(:heckle_with) - $rspec_mocks.__send__(:mocks).delete(heckle_runner) + heckle_runner = mock("heckle_runner") + heckle_runner.should_receive(:heckle_with) + $rspec_mocks.__send__(:mocks).delete(heckle_runner) - options.heckle_runner = heckle_runner - options.add_example_group(example_group) + options.heckle_runner = heckle_runner + options.add_example_group(example_group) - Spec::Runner::CommandLine.run(OptionParser.parse([], @err, @out)) - heckle_runner.rspec_verify - end + Spec::Runner::CommandLine.run(OptionParser.parse([], @err, @out)) + heckle_runner.rspec_verify + end - it "should run examples backwards if options.reverse is true" do - options = ::Spec::Runner::Options.new(@err, @out) - ::Spec::Runner::Options.should_receive(:new).with(@err, @out).and_return(options) - options.reverse = true + it "should run examples backwards if options.reverse is true" do + options = ::Spec::Runner::Options.new(@err, @out) + ::Spec::Runner::Options.should_receive(:new).with(@err, @out).and_return(options) + options.reverse = true - b1 = Class.new(Spec::Example::ExampleGroup) - b2 = Class.new(Spec::Example::ExampleGroup) + b1 = Class.new(Spec::Example::ExampleGroup) + b2 = Class.new(Spec::Example::ExampleGroup) - b2.should_receive(:run).ordered - b1.should_receive(:run).ordered + b2.should_receive(:run).ordered + b1.should_receive(:run).ordered - options.add_example_group(b1) - options.add_example_group(b2) + options.add_example_group(b1) + options.add_example_group(b2) - Spec::Runner::CommandLine.run(OptionParser.parse([], @err, @out)) - end + Spec::Runner::CommandLine.run(OptionParser.parse([], @err, @out)) + end - it "should pass its ExampleGroup to the reporter" do - example_group = Class.new(::Spec::Example::ExampleGroup).describe("example_group") do - it "should" do + it "should pass its ExampleGroup to the reporter" do + example_group = describe("example_group") do + it "should" do + end end - end - options = ::Spec::Runner::Options.new(@err, @out) - options.add_example_group(example_group) + options = ::Spec::Runner::Options.new(@err, @out) + options.add_example_group(example_group) - ::Spec::Runner::Options.should_receive(:new).with(@err, @out).and_return(options) - options.reporter.should_receive(:add_example_group).with(example_group) + ::Spec::Runner::Options.should_receive(:new).with(@err, @out).and_return(options) + options.reporter.should_receive(:add_example_group).with(Spec::Example::ExampleGroupProxy.new(example_group)) - Spec::Runner::CommandLine.run(OptionParser.parse([], @err, @out)) - end - - it "runs only selected Examples when options.examples is set" do - options = ::Spec::Runner::Options.new(@err, @out) - ::Spec::Runner::Options.should_receive(:new).with(@err, @out).and_return(options) - - options.examples << "example_group should" - should_has_run = false - should_not_has_run = false - example_group = Class.new(::Spec::Example::ExampleGroup).describe("example_group") do - it "should" do - should_has_run = true - end - it "should not" do - should_not_has_run = true - end + Spec::Runner::CommandLine.run(OptionParser.parse([], @err, @out)) end - options.reporter.should_receive(:add_example_group).with(example_group) + it "runs only selected Examples when options.examples is set" do + options = ::Spec::Runner::Options.new(@err, @out) + ::Spec::Runner::Options.should_receive(:new).with(@err, @out).and_return(options) + + options.examples << "example group expected example" + expected_example_was_run = false + unexpected_example_was_run = false + example_group = describe("example group") do + it "expected example" do + expected_example_was_run = true + end + it "unexpected example" do + unexpected_example_was_run = true + end + end - options.add_example_group example_group - Spec::Runner::CommandLine.run(OptionParser.parse([], @err, @out)) + options.reporter.should_receive(:add_example_group).with(Spec::Example::ExampleGroupProxy.new(example_group)) - should_has_run.should be_true - should_not_has_run.should be_false - end + options.add_example_group example_group + run_with(options) - it "sets Spec.run to true" do - ::Spec.run = false - ::Spec.should_not be_run - Spec::Runner::CommandLine.run(OptionParser.parse([], @err, @out)) - ::Spec.should be_run + expected_example_was_run.should be_true + unexpected_example_was_run.should be_false + end end end end diff --git a/vendor/plugins/rspec/spec/spec/runner/drb_command_line_spec.rb b/vendor/plugins/rspec/spec/spec/runner/drb_command_line_spec.rb index 760ec37a9..0c17a7f68 100644 --- a/vendor/plugins/rspec/spec/spec/runner/drb_command_line_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/drb_command_line_spec.rb @@ -1,92 +1,107 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Runner - describe DrbCommandLine, "without running local server" do - unless Config::CONFIG['ruby_install_name'] == 'jruby' - it "should print error when there is no running local server" do - err = StringIO.new - out = StringIO.new - DrbCommandLine.run(OptionParser.parse(['--version'], err, out)) - - err.rewind - err.read.should =~ /No server is running/ - end - end - end + unless jruby? + describe DrbCommandLine do - class DrbCommandLineSpec < ::Spec::Example::ExampleGroup - describe DrbCommandLine, "with local server" + context "without server running" do + it "prints error" do + err = out = StringIO.new + DrbCommandLine.run(OptionParser.parse(['--version'], err, out)) - class CommandLineForSpec - def self.run(argv, stderr, stdout) - exit Spec::Runner::CommandLine.run(OptionParser.parse(argv, stderr, stdout)) - end - end - - unless Config::CONFIG['ruby_install_name'] == 'jruby' - before(:all) do - DRb.start_service("druby://localhost:8989", CommandLineForSpec) - @@drb_example_file_counter = 0 - end + err.rewind + err.read.should =~ /No server is running/ + end + + it "returns nil" do + err = out = StringIO.new + result = DrbCommandLine.run(OptionParser.parse(['--version'], err, out)) + result.should be_false + end + end - before(:each) do - create_dummy_spec_file - @@drb_example_file_counter = @@drb_example_file_counter + 1 - end + context "with server running" do + class ::CommandLineForDrbSpec + def self.run(argv, stderr, stdout) + orig_options = Spec::Runner.options + tmp_options = Spec::Runner::OptionParser.parse(argv, stderr, stdout) + Spec::Runner.use tmp_options + Spec::Runner::CommandLine.run(tmp_options) + ensure + Spec::Runner.use orig_options + end + end - after(:each) do - File.delete(@dummy_spec_filename) - end + before(:all) do + DRb.start_service("druby://127.0.0.1:8989", ::CommandLineForDrbSpec) + @@drb_example_file_counter = 0 + end - after(:all) do - DRb.stop_service - end + before(:each) do + create_dummy_spec_file + @@drb_example_file_counter = @@drb_example_file_counter + 1 + end - it "should run against local server" do - out = run_spec_via_druby(['--version']) - out.should =~ /RSpec/n - end + after(:each) do + File.delete(@dummy_spec_filename) + end - it "should output green colorized text when running with --colour option" do - out = run_spec_via_druby(["--colour", @dummy_spec_filename]) - out.should =~ /\e\[32m/n - end + after(:all) do + DRb.stop_service + end - it "should output red colorized text when running with -c option" do - out = run_spec_via_druby(["-c", @dummy_spec_filename]) - out.should =~ /\e\[31m/n - end + it "returns true" do + err = out = StringIO.new + result = DrbCommandLine.run(OptionParser.parse(['--version'], err, out)) + result.should be_true + end - def create_dummy_spec_file - @dummy_spec_filename = File.expand_path(File.dirname(__FILE__)) + "/_dummy_spec#{@@drb_example_file_counter}.rb" - File.open(@dummy_spec_filename, 'w') do |f| - f.write %{ - describe "DUMMY CONTEXT for 'DrbCommandLine with -c option'" do - it "should be output with green bar" do - true.should be_true - end + it "should run against local server" do + out = run_spec_via_druby(['--version']) + out.should =~ /rspec \d+\.\d+\.\d+.*/n + end + + it "should output green colorized text when running with --colour option" do + out = run_spec_via_druby(["--colour", @dummy_spec_filename]) + out.should =~ /\e\[32m/n + end + + it "should output red colorized text when running with -c option" do + out = run_spec_via_druby(["-c", @dummy_spec_filename]) + out.should =~ /\e\[31m/n + end + + def create_dummy_spec_file + @dummy_spec_filename = File.expand_path(File.dirname(__FILE__)) + "/_dummy_spec#{@@drb_example_file_counter}.rb" + File.open(@dummy_spec_filename, 'w') do |f| + f.write %{ + describe "DUMMY CONTEXT for 'DrbCommandLine with -c option'" do + it "should be output with green bar" do + true.should be_true + end - it "should be output with red bar" do - violated("I want to see a red bar!") + it "should be output with red bar" do + violated("I want to see a red bar!") + end end - end - } + } + end end - end - def run_spec_via_druby(argv) - err, out = StringIO.new, StringIO.new - out.instance_eval do - def tty?; true end + def run_spec_via_druby(argv) + err, out = StringIO.new, StringIO.new + out.instance_eval do + def tty?; true end + end + options = ::Spec::Runner::Options.new(err, out) + options.argv = argv + Spec::Runner::DrbCommandLine.run(options) + out.rewind; out.read end - options = ::Spec::Runner::Options.new(err, out) - options.argv = argv - Spec::Runner::DrbCommandLine.run(options) - out.rewind; out.read end - end + end end end end diff --git a/vendor/plugins/rspec/spec/spec/runner/execution_context_spec.rb b/vendor/plugins/rspec/spec/spec/runner/execution_context_spec.rb deleted file mode 100644 index 2c8c23f18..000000000 --- a/vendor/plugins/rspec/spec/spec/runner/execution_context_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' - -describe "ExecutionContext" do - - it "should provide duck_type()" do - dt = duck_type(:length) - dt.should be_an_instance_of(Spec::Mocks::DuckTypeArgConstraint) - dt.matches?([]).should be_true - end - - it "should provide hash_including" do - hi = hash_including(:a => 1) - hi.should be_an_instance_of(Spec::Mocks::HashIncludingConstraint) - hi.matches?(:a => 1).should be_true - end - - it "should violate when violated()" do - lambda do - violated - end.should raise_error(Spec::Expectations::ExpectationNotMetError) - end - - it "should provide mock()" do - mock("thing").should be_an_instance_of(Spec::Mocks::Mock) - end - - it "should provide stub()" do - thing_stub = stub("thing").should be_an_instance_of(Spec::Mocks::Mock) - end - - it "should add method stubs to stub()" do - thing_stub = stub("thing", :a => "A", :b => "B") - thing_stub.a.should == "A" - thing_stub.b.should == "B" - end - -end diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb index e54cdb09f..b390131ad 100644 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../spec_helper' +require 'spec_helper' require 'spec/runner/formatter/failing_example_groups_formatter' module Spec @@ -15,11 +15,11 @@ module Spec end it "should add example name for each failure" do - formatter.add_example_group(Class.new(ExampleGroup).describe("b 1")) - formatter.example_failed("e 1", nil, Reporter::Failure.new(nil, RuntimeError.new)) - formatter.add_example_group(Class.new(ExampleGroup).describe("b 2")) - formatter.example_failed("e 2", nil, Reporter::Failure.new(nil, RuntimeError.new)) - formatter.example_failed("e 3", nil, Reporter::Failure.new(nil, RuntimeError.new)) + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(Class.new(::Spec::Example::ExampleGroupDouble).describe("b 1"))) + formatter.example_failed("e 1", nil, Spec::Runner::Reporter::Failure.new("g", nil, RuntimeError.new)) + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(Class.new(::Spec::Example::ExampleGroupDouble).describe("b 2"))) + formatter.example_failed("e 2", nil, Spec::Runner::Reporter::Failure.new("g", nil, RuntimeError.new)) + formatter.example_failed("e 3", nil, Spec::Runner::Reporter::Failure.new("g", nil, RuntimeError.new)) io.string.should include("b 1") io.string.should include("b 2") end @@ -29,14 +29,14 @@ module Spec child_example_group = Class.new(parent_example_group).describe("#child_method") grand_child_example_group = Class.new(child_example_group).describe("GrandChild") - formatter.add_example_group(grand_child_example_group) - formatter.example_failed("failure", nil, Reporter::Failure.new(nil, RuntimeError.new)) + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(grand_child_example_group)) + formatter.example_failed("failure", nil, ::Spec::Runner::Reporter::Failure.new("g", nil, RuntimeError.new)) io.string.should == "Parent#child_method GrandChild\n" end it "should remove druby url, which is used by Spec::Distributed" do - @formatter.add_example_group(Class.new(ExampleGroup).describe("something something (druby://99.99.99.99:99)")) - @formatter.example_failed("e 1", nil, Reporter::Failure.new(nil, RuntimeError.new)) + @formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(Class.new(::Spec::Example::ExampleGroupDouble).describe("something something (druby://99.99.99.99:99)"))) + @formatter.example_failed("e 1", nil, ::Spec::Runner::Reporter::Failure.new("g", nil, RuntimeError.new)) io.string.should == "something something\n" end end diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/failing_examples_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/failing_examples_formatter_spec.rb index fda64f95f..76d03fa39 100644 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/formatter/failing_examples_formatter_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../spec_helper' +require 'spec_helper' require 'spec/runner/formatter/failing_examples_formatter' module Spec @@ -12,14 +12,14 @@ module Spec end it "should add example name for each failure" do - example_group_1 = Class.new(ExampleGroup).describe("A") + example_group_1 = Class.new(::Spec::Example::ExampleGroupDouble).describe("A") example_group_2 = Class.new(example_group_1).describe("B") - @formatter.add_example_group(example_group_1) - @formatter.example_failed(example_group_1.it("a1"){}, nil, Reporter::Failure.new(nil, RuntimeError.new)) - @formatter.add_example_group(example_group_2) - @formatter.example_failed(example_group_2.it("b2"){}, nil, Reporter::Failure.new(nil, RuntimeError.new)) - @formatter.example_failed(example_group_2.it("b3"){}, nil, Reporter::Failure.new(nil, RuntimeError.new)) + @formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group_1)) + @formatter.example_failed(example_group_1.it("a1"){}, nil, ::Spec::Runner::Reporter::Failure.new("g", nil, RuntimeError.new)) + @formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group_2)) + @formatter.example_failed(example_group_2.it("b2"){}, nil, ::Spec::Runner::Reporter::Failure.new("g", nil, RuntimeError.new)) + @formatter.example_failed(example_group_2.it("b3"){}, nil, ::Spec::Runner::Reporter::Failure.new("g", nil, RuntimeError.new)) @io.string.should eql(<<-EOF A a1 A B b2 diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.4.html b/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.4.html deleted file mode 100644 index 9cc458fdb..000000000 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.4.html +++ /dev/null @@ -1,365 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - <title>RSpec results</title> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <meta http-equiv="Expires" content="-1" /> - <meta http-equiv="Pragma" content="no-cache" /> - <style type="text/css"> - body { - margin: 0; - padding: 0; - background: #fff; - font-size: 80%; - } - </style> -</head> -<body> -<div class="rspec-report"> - <script type="text/javascript"> - // <![CDATA[ -function moveProgressBar(percentDone) { - document.getElementById("rspec-header").style.width = percentDone +"%"; -} -function makeRed(element_id) { - document.getElementById(element_id).style.background = '#C40D0D'; - document.getElementById(element_id).style.color = '#FFFFFF'; -} - -function makeYellow(element_id) { - if (element_id == "rspec-header" && document.getElementById(element_id).style.background != '#C40D0D') - { - document.getElementById(element_id).style.background = '#FAF834'; - document.getElementById(element_id).style.color = '#000000'; - } - else - { - document.getElementById(element_id).style.background = '#FAF834'; - document.getElementById(element_id).style.color = '#000000'; - } -} - - // ]]> - </script> - <style type="text/css"> -#rspec-header { - background: #65C400; color: #fff; -} - -.rspec-report h1 { - margin: 0px 10px 0px 10px; - padding: 10px; - font-family: "Lucida Grande", Helvetica, sans-serif; - font-size: 1.8em; -} - -#summary { - margin: 0; padding: 5px 10px; - font-family: "Lucida Grande", Helvetica, sans-serif; - text-align: right; - position: absolute; - top: 0px; - right: 0px; -} - -#summary p { - margin: 0 0 0 2px; -} - -#summary #totals { - font-size: 1.2em; -} - -.example_group { - margin: 0 10px 5px; - background: #fff; -} - -dl { - margin: 0; padding: 0 0 5px; - font: normal 11px "Lucida Grande", Helvetica, sans-serif; -} - -dt { - padding: 3px; - background: #65C400; - color: #fff; - font-weight: bold; -} - -dd { - margin: 5px 0 5px 5px; - padding: 3px 3px 3px 18px; -} - -dd.spec.passed { - border-left: 5px solid #65C400; - border-bottom: 1px solid #65C400; - background: #DBFFB4; color: #3D7700; -} - -dd.spec.failed { - border-left: 5px solid #C20000; - border-bottom: 1px solid #C20000; - color: #C20000; background: #FFFBD3; -} - -dd.spec.not_implemented { - border-left: 5px solid #FAF834; - border-bottom: 1px solid #FAF834; - background: #FCFB98; color: #131313; -} - -dd.spec.pending_fixed { - border-left: 5px solid #0000C2; - border-bottom: 1px solid #0000C2; - color: #0000C2; background: #D3FBFF; -} - -.backtrace { - color: #000; - font-size: 12px; -} - -a { - color: #BE5C00; -} - -/* Ruby code, style similar to vibrant ink */ -.ruby { - font-size: 12px; - font-family: monospace; - color: white; - background-color: black; - padding: 0.1em 0 0.2em 0; -} - -.ruby .keyword { color: #FF6600; } -.ruby .constant { color: #339999; } -.ruby .attribute { color: white; } -.ruby .global { color: white; } -.ruby .module { color: white; } -.ruby .class { color: white; } -.ruby .string { color: #66FF00; } -.ruby .ident { color: white; } -.ruby .method { color: #FFCC00; } -.ruby .number { color: white; } -.ruby .char { color: white; } -.ruby .comment { color: #9933CC; } -.ruby .symbol { color: white; } -.ruby .regex { color: #44B4CC; } -.ruby .punct { color: white; } -.ruby .escape { color: white; } -.ruby .interp { color: white; } -.ruby .expr { color: white; } - -.ruby .offending { background-color: gray; } -.ruby .linenum { - width: 75px; - padding: 0.1em 1em 0.2em 0; - color: #000000; - background-color: #FFFBD3; -} - - </style> - -<div id="rspec-header"> - <h1>RSpec Results</h1> - - <div id="summary"> - <p id="totals"> </p> - <p id="duration"> </p> - </div> -</div> - -<div class="results"> -<div class="example_group"> - <dl> - <dt id="example_group_1">Mocker</dt> - <script type="text/javascript">moveProgressBar('5.8');</script> - <dd class="spec passed"><span class="passed_spec_name">should be able to call mock()</span></dd> - <script type="text/javascript">makeRed('rspec-header');</script> - <script type="text/javascript">makeRed('example_group_1');</script> - <script type="text/javascript">moveProgressBar('11.7');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should fail when expected message not received</span> - <div class="failure" id="failure_1"> - <div class="message"><pre>Mock 'poke me' expected :poke with (any args) once, but received it 0 times</pre></div> - <div class="backtrace"><pre>./failing_examples/mocking_example.rb:13: -./spec/spec/runner/formatter/html_formatter_spec.rb:24: -./spec/spec/runner/formatter/html_formatter_spec.rb:20:</pre></div> - <pre class="ruby"><code><span class="linenum">11</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">should fail when expected message not received</span><span class="punct">"</span> <span class="keyword">do</span> -<span class="linenum">12</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">poke me</span><span class="punct">")</span> -<span class="offending"><span class="linenum">13</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:poke</span><span class="punct">)</span></span> -<span class="linenum">14</span> <span class="keyword">end</span> -<span class="linenum">15</span> </code></pre> - </div> - </dd> - <script type="text/javascript">moveProgressBar('17.6');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should fail when messages are received out of order</span> - <div class="failure" id="failure_2"> - <div class="message"><pre>Mock 'one two three' received :three out of order</pre></div> - <div class="backtrace"><pre>./failing_examples/mocking_example.rb:22: -./spec/spec/runner/formatter/html_formatter_spec.rb:24: -./spec/spec/runner/formatter/html_formatter_spec.rb:20:</pre></div> - <pre class="ruby"><code><span class="linenum">20</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:three</span><span class="punct">).</span><span class="ident">ordered</span> -<span class="linenum">21</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">one</span> -<span class="offending"><span class="linenum">22</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">three</span></span> -<span class="linenum">23</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">two</span> -<span class="linenum">24</span> <span class="keyword">end</span></code></pre> - </div> - </dd> - <script type="text/javascript">moveProgressBar('23.5');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should get yelled at when sending unexpected messages</span> - <div class="failure" id="failure_3"> - <div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (any args) 0 times, but received it once</pre></div> - <div class="backtrace"><pre>./failing_examples/mocking_example.rb:28: -./spec/spec/runner/formatter/html_formatter_spec.rb:24: -./spec/spec/runner/formatter/html_formatter_spec.rb:20:</pre></div> - <pre class="ruby"><code><span class="linenum">26</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">should get yelled at when sending unexpected messages</span><span class="punct">"</span> <span class="keyword">do</span> -<span class="linenum">27</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">don't talk to me</span><span class="punct">")</span> -<span class="offending"><span class="linenum">28</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span></span> -<span class="linenum">29</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span> -<span class="linenum">30</span> <span class="keyword">end</span></code></pre> - </div> - </dd> - <script type="text/javascript">moveProgressBar('29.4');</script> - <dd class="spec pending_fixed"> - <span class="failed_spec_name">has a bug we need to fix</span> - <div class="failure" id="failure_4"> - <div class="message"><pre>Expected pending 'here is the bug' to fail. No Error was raised.</pre></div> - <div class="backtrace"><pre>./failing_examples/mocking_example.rb:33: -./spec/spec/runner/formatter/html_formatter_spec.rb:24: -./spec/spec/runner/formatter/html_formatter_spec.rb:20:</pre></div> - <pre class="ruby"><code><span class="linenum">31</span> -<span class="linenum">32</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">has a bug we need to fix</span><span class="punct">"</span> <span class="keyword">do</span> -<span class="offending"><span class="linenum">33</span> <span class="ident">pending</span> <span class="punct">"</span><span class="string">here is the bug</span><span class="punct">"</span> <span class="keyword">do</span></span> -<span class="linenum">34</span> <span class="comment"># Actually, no. It's fixed. This will fail because it passes :-)</span> -<span class="linenum">35</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">Bug</span><span class="punct">")</span></code></pre> - </div> - </dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_2">Running specs with --diff</dt> - <script type="text/javascript">makeRed('example_group_2');</script> - <script type="text/javascript">moveProgressBar('35.2');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should print diff of different strings</span> - <div class="failure" id="failure_5"> - <div class="message"><pre>expected: "RSpec is a\nbehaviour driven development\nframework for Ruby\n", - got: "RSpec is a\nbehavior driven development\nframework for Ruby\n" (using ==) -Diff: -@@ -1,4 +1,4 @@ - RSpec is a --behavior driven development -+behaviour driven development - framework for Ruby -</pre></div> - <div class="backtrace"><pre>./failing_examples/diffing_spec.rb:13: -./spec/spec/runner/formatter/html_formatter_spec.rb:24: -./spec/spec/runner/formatter/html_formatter_spec.rb:20:</pre></div> - <pre class="ruby"><code><span class="linenum">11</span><span class="ident">framework</span> <span class="keyword">for</span> <span class="constant">Ruby</span> -<span class="linenum">12</span><span class="constant">EOF</span> -<span class="offending"><span class="linenum">13</span> <span class="ident">usa</span><span class="punct">.</span><span class="ident">should</span> <span class="punct">==</span> <span class="ident">uk</span></span> -<span class="linenum">14</span> <span class="keyword">end</span></code></pre> - </div> - </dd> - <script type="text/javascript">moveProgressBar('41.1');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should print diff of different objects' pretty representation</span> - <div class="failure" id="failure_6"> - <div class="message"><pre>expected <Animal -name=bob, -species=tortoise -> -, got <Animal -name=bob, -species=giraffe -> - (using .eql?) -Diff: -@@ -1,5 +1,5 @@ - <Animal - name=bob, --species=giraffe -+species=tortoise - > -</pre></div> - <div class="backtrace"><pre>./failing_examples/diffing_spec.rb:34: -./spec/spec/runner/formatter/html_formatter_spec.rb:24: -./spec/spec/runner/formatter/html_formatter_spec.rb:20:</pre></div> - <pre class="ruby"><code><span class="linenum">32</span> <span class="ident">expected</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">"</span><span class="string">bob</span><span class="punct">",</span> <span class="punct">"</span><span class="string">giraffe</span><span class="punct">"</span> -<span class="linenum">33</span> <span class="ident">actual</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">"</span><span class="string">bob</span><span class="punct">",</span> <span class="punct">"</span><span class="string">tortoise</span><span class="punct">"</span> -<span class="offending"><span class="linenum">34</span> <span class="ident">expected</span><span class="punct">.</span><span class="ident">should</span> <span class="ident">eql</span><span class="punct">(</span><span class="ident">actual</span><span class="punct">)</span></span> -<span class="linenum">35</span> <span class="keyword">end</span> -<span class="linenum">36</span><span class="keyword">end</span></code></pre> - </div> - </dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_3">A consumer of a stub</dt> - <script type="text/javascript">moveProgressBar('47.0');</script> - <dd class="spec passed"><span class="passed_spec_name">should be able to stub methods on any Object</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_4">A stubbed method on a class</dt> - <script type="text/javascript">moveProgressBar('52.9');</script> - <dd class="spec passed"><span class="passed_spec_name">should return the stubbed value</span></dd> - <script type="text/javascript">moveProgressBar('58.8');</script> - <dd class="spec passed"><span class="passed_spec_name">should revert to the original method after each spec</span></dd> - <script type="text/javascript">moveProgressBar('64.7');</script> - <dd class="spec passed"><span class="passed_spec_name">can stub! and mock the same message</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_5">A mock</dt> - <script type="text/javascript">moveProgressBar('70.5');</script> - <dd class="spec passed"><span class="passed_spec_name">can stub!</span></dd> - <script type="text/javascript">moveProgressBar('76.4');</script> - <dd class="spec passed"><span class="passed_spec_name">can stub! and mock</span></dd> - <script type="text/javascript">moveProgressBar('82.3');</script> - <dd class="spec passed"><span class="passed_spec_name">can stub! and mock the same message</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_6">pending example (using pending method)</dt> - <script type="text/javascript">makeYellow('example_group_6');</script> - <script type="text/javascript">moveProgressBar('88.2');</script> - <dd class="spec not_implemented"><span class="not_implemented_spec_name">should be reported as "PENDING: for some reason" (PENDING: for some reason)</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_7">pending example (with no block)</dt> - <script type="text/javascript">makeYellow('example_group_7');</script> - <script type="text/javascript">moveProgressBar('94.1');</script> - <dd class="spec not_implemented"><span class="not_implemented_spec_name">should be reported as "PENDING: Not Yet Implemented" (PENDING: Not Yet Implemented)</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_8">pending example (with block for pending)</dt> - <script type="text/javascript">makeYellow('example_group_8');</script> - <script type="text/javascript">moveProgressBar('100.0');</script> - <dd class="spec not_implemented"><span class="not_implemented_spec_name">should have a failing block, passed to pending, reported as "PENDING: for some reason" (PENDING: for some reason)</span></dd> - </dl> -</div> -<script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>x seconds</strong>";</script> -<script type="text/javascript">document.getElementById('totals').innerHTML = "17 examples, 6 failures, 3 pending";</script> -</div> -</div> -</body> -</html> diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.5-jruby.html b/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.5-jruby.html deleted file mode 100644 index 8bf1ed9cd..000000000 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.5-jruby.html +++ /dev/null @@ -1,387 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - <title>RSpec results</title> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <meta http-equiv="Expires" content="-1" /> - <meta http-equiv="Pragma" content="no-cache" /> - <style type="text/css"> - body { - margin: 0; - padding: 0; - background: #fff; - font-size: 80%; - } - </style> -</head> -<body> -<div class="rspec-report"> - <script type="text/javascript"> - // <![CDATA[ -function moveProgressBar(percentDone) { - document.getElementById("rspec-header").style.width = percentDone +"%"; -} -function makeRed(element_id) { - document.getElementById(element_id).style.background = '#C40D0D'; - document.getElementById(element_id).style.color = '#FFFFFF'; -} - -function makeYellow(element_id) { - if (element_id == "rspec-header" && document.getElementById(element_id).style.background != '#C40D0D') - { - document.getElementById(element_id).style.background = '#FAF834'; - document.getElementById(element_id).style.color = '#000000'; - } - else - { - document.getElementById(element_id).style.background = '#FAF834'; - document.getElementById(element_id).style.color = '#000000'; - } -} - - // ]]> - </script> - <style type="text/css"> -#rspec-header { - background: #65C400; color: #fff; -} - -.rspec-report h1 { - margin: 0px 10px 0px 10px; - padding: 10px; - font-family: "Lucida Grande", Helvetica, sans-serif; - font-size: 1.8em; -} - -#summary { - margin: 0; padding: 5px 10px; - font-family: "Lucida Grande", Helvetica, sans-serif; - text-align: right; - position: absolute; - top: 0px; - right: 0px; -} - -#summary p { - margin: 0 0 0 2px; -} - -#summary #totals { - font-size: 1.2em; -} - -.example_group { - margin: 0 10px 5px; - background: #fff; -} - -dl { - margin: 0; padding: 0 0 5px; - font: normal 11px "Lucida Grande", Helvetica, sans-serif; -} - -dt { - padding: 3px; - background: #65C400; - color: #fff; - font-weight: bold; -} - -dd { - margin: 5px 0 5px 5px; - padding: 3px 3px 3px 18px; -} - -dd.spec.passed { - border-left: 5px solid #65C400; - border-bottom: 1px solid #65C400; - background: #DBFFB4; color: #3D7700; -} - -dd.spec.failed { - border-left: 5px solid #C20000; - border-bottom: 1px solid #C20000; - color: #C20000; background: #FFFBD3; -} - -dd.spec.not_implemented { - border-left: 5px solid #FAF834; - border-bottom: 1px solid #FAF834; - background: #FCFB98; color: #131313; -} - -dd.spec.pending_fixed { - border-left: 5px solid #0000C2; - border-bottom: 1px solid #0000C2; - color: #0000C2; background: #D3FBFF; -} - -.backtrace { - color: #000; - font-size: 12px; -} - -a { - color: #BE5C00; -} - -/* Ruby code, style similar to vibrant ink */ -.ruby { - font-size: 12px; - font-family: monospace; - color: white; - background-color: black; - padding: 0.1em 0 0.2em 0; -} - -.ruby .keyword { color: #FF6600; } -.ruby .constant { color: #339999; } -.ruby .attribute { color: white; } -.ruby .global { color: white; } -.ruby .module { color: white; } -.ruby .class { color: white; } -.ruby .string { color: #66FF00; } -.ruby .ident { color: white; } -.ruby .method { color: #FFCC00; } -.ruby .number { color: white; } -.ruby .char { color: white; } -.ruby .comment { color: #9933CC; } -.ruby .symbol { color: white; } -.ruby .regex { color: #44B4CC; } -.ruby .punct { color: white; } -.ruby .escape { color: white; } -.ruby .interp { color: white; } -.ruby .expr { color: white; } - -.ruby .offending { background-color: gray; } -.ruby .linenum { - width: 75px; - padding: 0.1em 1em 0.2em 0; - color: #000000; - background-color: #FFFBD3; -} - - </style> - -<div id="rspec-header"> - <h1>RSpec Results</h1> - - <div id="summary"> - <p id="totals"> </p> - <p id="duration"> </p> - </div> -</div> - -<div class="results"> -<div class="example_group"> - <dl> - <dt id="example_group_1">Mocker</dt> - <script type="text/javascript">moveProgressBar('5.8');</script> - <dd class="spec passed"><span class="passed_spec_name">should be able to call mock()</span></dd> - <script type="text/javascript">makeRed('rspec-header');</script> - <script type="text/javascript">makeRed('example_group_1');</script> - <script type="text/javascript">moveProgressBar('11.7');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should fail when expected message not received</span> - <div class="failure" id="failure_1"> - <div class="message"><pre>Mock 'poke me' expected :poke with (any args) once, but received it 0 times</pre></div> - <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:13:in `should_receive' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:24:in `run' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `instance_eval'</pre></div> - <pre class="ruby"><code><span class="linenum">11</span> it "should fail when expected message not received" do -<span class="linenum">12</span> mock = mock("poke me") -<span class="offending"><span class="linenum">13</span> mock.should_receive(:poke)</span> -<span class="linenum">14</span> end -<span class="linenum">15</span> -<span class="linenum">16</span><span class="comment"># gem install syntax to get syntax highlighting</span></code></pre> - </div> - </dd> - <script type="text/javascript">moveProgressBar('17.6');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should fail when messages are received out of order</span> - <div class="failure" id="failure_2"> - <div class="message"><pre>Mock 'one two three' received :three out of order</pre></div> - <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:22:in `three' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:16:in `instance_eval' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:24:in `run' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `instance_eval'</pre></div> - <pre class="ruby"><code><span class="linenum">20</span> mock.should_receive(:three).ordered -<span class="linenum">21</span> mock.one -<span class="offending"><span class="linenum">22</span> mock.three</span> -<span class="linenum">23</span> mock.two -<span class="linenum">24</span> end -<span class="linenum">25</span><span class="comment"># gem install syntax to get syntax highlighting</span></code></pre> - </div> - </dd> - <script type="text/javascript">moveProgressBar('23.5');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should get yelled at when sending unexpected messages</span> - <div class="failure" id="failure_3"> - <div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (any args) 0 times, but received it once</pre></div> - <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:28:in `should_not_receive' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:24:in `run' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `instance_eval'</pre></div> - <pre class="ruby"><code><span class="linenum">26</span> it "should get yelled at when sending unexpected messages" do -<span class="linenum">27</span> mock = mock("don't talk to me") -<span class="offending"><span class="linenum">28</span> mock.should_not_receive(:any_message_at_all)</span> -<span class="linenum">29</span> mock.any_message_at_all -<span class="linenum">30</span> end -<span class="linenum">31</span><span class="comment"># gem install syntax to get syntax highlighting</span></code></pre> - </div> - </dd> - <script type="text/javascript">moveProgressBar('29.4');</script> - <dd class="spec pending_fixed"> - <span class="failed_spec_name">has a bug we need to fix</span> - <div class="failure" id="failure_4"> - <div class="message"><pre>Expected pending 'here is the bug' to fail. No Error was raised.</pre></div> - <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:33:in `pending' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:33:in `instance_eval' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:24:in `run' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `instance_eval'</pre></div> - <pre class="ruby"><code><span class="linenum">31</span> -<span class="linenum">32</span> it "has a bug we need to fix" do -<span class="offending"><span class="linenum">33</span> pending "here is the bug" do</span> -<span class="linenum">34</span> # Actually, no. It's fixed. This will fail because it passes :-) -<span class="linenum">35</span> mock = mock("Bug") -<span class="linenum">36</span><span class="comment"># gem install syntax to get syntax highlighting</span></code></pre> - </div> - </dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_2">Running specs with --diff</dt> - <script type="text/javascript">makeRed('example_group_2');</script> - <script type="text/javascript">moveProgressBar('35.2');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should print diff of different strings</span> - <div class="failure" id="failure_5"> - <div class="message"><pre>expected: "RSpec is a\nbehaviour driven development\nframework for Ruby\n", - got: "RSpec is a\nbehavior driven development\nframework for Ruby\n" (using ==) -Diff: -@@ -1,4 +1,4 @@ - RSpec is a --behavior driven development -+behaviour driven development - framework for Ruby -</pre></div> - <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/diffing_spec.rb:13:in `==' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:24:in `run' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `instance_eval'</pre></div> - <pre class="ruby"><code><span class="linenum">11</span>framework for Ruby -<span class="linenum">12</span>EOF -<span class="offending"><span class="linenum">13</span> usa.should == uk</span> -<span class="linenum">14</span> end -<span class="linenum">15</span> -<span class="linenum">16</span><span class="comment"># gem install syntax to get syntax highlighting</span></code></pre> - </div> - </dd> - <script type="text/javascript">moveProgressBar('41.1');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should print diff of different objects' pretty representation</span> - <div class="failure" id="failure_6"> - <div class="message"><pre>expected <Animal -name=bob, -species=tortoise -> -, got <Animal -name=bob, -species=giraffe -> - (using .eql?) -Diff: -@@ -1,5 +1,5 @@ - <Animal - name=bob, --species=giraffe -+species=tortoise - > -</pre></div> - <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/diffing_spec.rb:34:in `should' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/diffing_spec.rb:31:in `instance_eval' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:24:in `run' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:20:in `instance_eval'</pre></div> - <pre class="ruby"><code><span class="linenum">32</span> expected = Animal.new "bob", "giraffe" -<span class="linenum">33</span> actual = Animal.new "bob", "tortoise" -<span class="offending"><span class="linenum">34</span> expected.should eql(actual)</span> -<span class="linenum">35</span> end -<span class="linenum">36</span>end -<span class="linenum">37</span><span class="comment"># gem install syntax to get syntax highlighting</span></code></pre> - </div> - </dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_3">A consumer of a stub</dt> - <script type="text/javascript">moveProgressBar('47.0');</script> - <dd class="spec passed"><span class="passed_spec_name">should be able to stub methods on any Object</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_4">A stubbed method on a class</dt> - <script type="text/javascript">moveProgressBar('52.9');</script> - <dd class="spec passed"><span class="passed_spec_name">should return the stubbed value</span></dd> - <script type="text/javascript">moveProgressBar('58.8');</script> - <dd class="spec passed"><span class="passed_spec_name">should revert to the original method after each spec</span></dd> - <script type="text/javascript">moveProgressBar('64.7');</script> - <dd class="spec passed"><span class="passed_spec_name">can stub! and mock the same message</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_5">A mock</dt> - <script type="text/javascript">moveProgressBar('70.5');</script> - <dd class="spec passed"><span class="passed_spec_name">can stub!</span></dd> - <script type="text/javascript">moveProgressBar('76.4');</script> - <dd class="spec passed"><span class="passed_spec_name">can stub! and mock</span></dd> - <script type="text/javascript">moveProgressBar('82.3');</script> - <dd class="spec passed"><span class="passed_spec_name">can stub! and mock the same message</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_6">pending example (using pending method)</dt> - <script type="text/javascript">makeYellow('example_group_6');</script> - <script type="text/javascript">moveProgressBar('88.2');</script> - <dd class="spec not_implemented"><span class="not_implemented_spec_name">should be reported as "PENDING: for some reason" (PENDING: for some reason)</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_7">pending example (with no block)</dt> - <script type="text/javascript">makeYellow('example_group_7');</script> - <script type="text/javascript">moveProgressBar('94.1');</script> - <dd class="spec not_implemented"><span class="not_implemented_spec_name">should be reported as "PENDING: Not Yet Implemented" (PENDING: Not Yet Implemented)</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_8">pending example (with block for pending)</dt> - <script type="text/javascript">makeYellow('example_group_8');</script> - <script type="text/javascript">moveProgressBar('100.0');</script> - <dd class="spec not_implemented"><span class="not_implemented_spec_name">should have a failing block, passed to pending, reported as "PENDING: for some reason" (PENDING: for some reason)</span></dd> - </dl> -</div> -<script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>x seconds</strong>";</script> -<script type="text/javascript">document.getElementById('totals').innerHTML = "17 examples, 6 failures, 3 pending";</script> -</div> -</div> -</body> -</html> diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.5.html b/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.5.html deleted file mode 100644 index cda7226bf..000000000 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.5.html +++ /dev/null @@ -1,371 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - <title>RSpec results</title> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <meta http-equiv="Expires" content="-1" /> - <meta http-equiv="Pragma" content="no-cache" /> - <style type="text/css"> - body { - margin: 0; - padding: 0; - background: #fff; - font-size: 80%; - } - </style> -</head> -<body> -<div class="rspec-report"> - <script type="text/javascript"> - // <![CDATA[ -function moveProgressBar(percentDone) { - document.getElementById("rspec-header").style.width = percentDone +"%"; -} -function makeRed(element_id) { - document.getElementById(element_id).style.background = '#C40D0D'; - document.getElementById(element_id).style.color = '#FFFFFF'; -} - -function makeYellow(element_id) { - if (element_id == "rspec-header" && document.getElementById(element_id).style.background != '#C40D0D') - { - document.getElementById(element_id).style.background = '#FAF834'; - document.getElementById(element_id).style.color = '#000000'; - } - else - { - document.getElementById(element_id).style.background = '#FAF834'; - document.getElementById(element_id).style.color = '#000000'; - } -} - - // ]]> - </script> - <style type="text/css"> -#rspec-header { - background: #65C400; color: #fff; -} - -.rspec-report h1 { - margin: 0px 10px 0px 10px; - padding: 10px; - font-family: "Lucida Grande", Helvetica, sans-serif; - font-size: 1.8em; -} - -#summary { - margin: 0; padding: 5px 10px; - font-family: "Lucida Grande", Helvetica, sans-serif; - text-align: right; - position: absolute; - top: 0px; - right: 0px; -} - -#summary p { - margin: 0 0 0 2px; -} - -#summary #totals { - font-size: 1.2em; -} - -.example_group { - margin: 0 10px 5px; - background: #fff; -} - -dl { - margin: 0; padding: 0 0 5px; - font: normal 11px "Lucida Grande", Helvetica, sans-serif; -} - -dt { - padding: 3px; - background: #65C400; - color: #fff; - font-weight: bold; -} - -dd { - margin: 5px 0 5px 5px; - padding: 3px 3px 3px 18px; -} - -dd.spec.passed { - border-left: 5px solid #65C400; - border-bottom: 1px solid #65C400; - background: #DBFFB4; color: #3D7700; -} - -dd.spec.failed { - border-left: 5px solid #C20000; - border-bottom: 1px solid #C20000; - color: #C20000; background: #FFFBD3; -} - -dd.spec.not_implemented { - border-left: 5px solid #FAF834; - border-bottom: 1px solid #FAF834; - background: #FCFB98; color: #131313; -} - -dd.spec.pending_fixed { - border-left: 5px solid #0000C2; - border-bottom: 1px solid #0000C2; - color: #0000C2; background: #D3FBFF; -} - -.backtrace { - color: #000; - font-size: 12px; -} - -a { - color: #BE5C00; -} - -/* Ruby code, style similar to vibrant ink */ -.ruby { - font-size: 12px; - font-family: monospace; - color: white; - background-color: black; - padding: 0.1em 0 0.2em 0; -} - -.ruby .keyword { color: #FF6600; } -.ruby .constant { color: #339999; } -.ruby .attribute { color: white; } -.ruby .global { color: white; } -.ruby .module { color: white; } -.ruby .class { color: white; } -.ruby .string { color: #66FF00; } -.ruby .ident { color: white; } -.ruby .method { color: #FFCC00; } -.ruby .number { color: white; } -.ruby .char { color: white; } -.ruby .comment { color: #9933CC; } -.ruby .symbol { color: white; } -.ruby .regex { color: #44B4CC; } -.ruby .punct { color: white; } -.ruby .escape { color: white; } -.ruby .interp { color: white; } -.ruby .expr { color: white; } - -.ruby .offending { background-color: gray; } -.ruby .linenum { - width: 75px; - padding: 0.1em 1em 0.2em 0; - color: #000000; - background-color: #FFFBD3; -} - - </style> - -<div id="rspec-header"> - <h1>RSpec Results</h1> - - <div id="summary"> - <p id="totals"> </p> - <p id="duration"> </p> - </div> -</div> - -<div class="results"> -<div class="example_group"> - <dl> - <dt id="example_group_1">Mocker</dt> - <script type="text/javascript">moveProgressBar('5.8');</script> - <dd class="spec passed"><span class="passed_spec_name">should be able to call mock()</span></dd> - <script type="text/javascript">makeRed('rspec-header');</script> - <script type="text/javascript">makeRed('example_group_1');</script> - <script type="text/javascript">moveProgressBar('11.7');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should fail when expected message not received</span> - <div class="failure" id="failure_1"> - <div class="message"><pre>Mock 'poke me' expected :poke with (any args) once, but received it 0 times</pre></div> - <div class="backtrace"><pre>./failing_examples/mocking_example.rb:13: -./spec/spec/runner/formatter/html_formatter_spec.rb:17: -./spec/spec/runner/formatter/html_formatter_spec.rb:13:in `chdir' -./spec/spec/runner/formatter/html_formatter_spec.rb:13:</pre></div> - <pre class="ruby"><code><span class="linenum">11</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">should fail when expected message not received</span><span class="punct">"</span> <span class="keyword">do</span> -<span class="linenum">12</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">poke me</span><span class="punct">")</span> -<span class="offending"><span class="linenum">13</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:poke</span><span class="punct">)</span></span> -<span class="linenum">14</span> <span class="keyword">end</span> -<span class="linenum">15</span> </code></pre> - </div> - </dd> - <script type="text/javascript">moveProgressBar('17.6');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should fail when messages are received out of order</span> - <div class="failure" id="failure_2"> - <div class="message"><pre>Mock 'one two three' received :three out of order</pre></div> - <div class="backtrace"><pre>./failing_examples/mocking_example.rb:22: -./spec/spec/runner/formatter/html_formatter_spec.rb:17: -./spec/spec/runner/formatter/html_formatter_spec.rb:13:in `chdir' -./spec/spec/runner/formatter/html_formatter_spec.rb:13:</pre></div> - <pre class="ruby"><code><span class="linenum">20</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:three</span><span class="punct">).</span><span class="ident">ordered</span> -<span class="linenum">21</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">one</span> -<span class="offending"><span class="linenum">22</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">three</span></span> -<span class="linenum">23</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">two</span> -<span class="linenum">24</span> <span class="keyword">end</span></code></pre> - </div> - </dd> - <script type="text/javascript">moveProgressBar('23.5');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should get yelled at when sending unexpected messages</span> - <div class="failure" id="failure_3"> - <div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (any args) 0 times, but received it once</pre></div> - <div class="backtrace"><pre>./failing_examples/mocking_example.rb:28: -./spec/spec/runner/formatter/html_formatter_spec.rb:17: -./spec/spec/runner/formatter/html_formatter_spec.rb:13:in `chdir' -./spec/spec/runner/formatter/html_formatter_spec.rb:13:</pre></div> - <pre class="ruby"><code><span class="linenum">26</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">should get yelled at when sending unexpected messages</span><span class="punct">"</span> <span class="keyword">do</span> -<span class="linenum">27</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">don't talk to me</span><span class="punct">")</span> -<span class="offending"><span class="linenum">28</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span></span> -<span class="linenum">29</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span> -<span class="linenum">30</span> <span class="keyword">end</span></code></pre> - </div> - </dd> - <script type="text/javascript">moveProgressBar('29.4');</script> - <dd class="spec pending_fixed"> - <span class="failed_spec_name">has a bug we need to fix</span> - <div class="failure" id="failure_4"> - <div class="message"><pre>Expected pending 'here is the bug' to fail. No Error was raised.</pre></div> - <div class="backtrace"><pre>./failing_examples/mocking_example.rb:33: -./spec/spec/runner/formatter/html_formatter_spec.rb:17: -./spec/spec/runner/formatter/html_formatter_spec.rb:13:in `chdir' -./spec/spec/runner/formatter/html_formatter_spec.rb:13:</pre></div> - <pre class="ruby"><code><span class="linenum">31</span> -<span class="linenum">32</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">has a bug we need to fix</span><span class="punct">"</span> <span class="keyword">do</span> -<span class="offending"><span class="linenum">33</span> <span class="ident">pending</span> <span class="punct">"</span><span class="string">here is the bug</span><span class="punct">"</span> <span class="keyword">do</span></span> -<span class="linenum">34</span> <span class="comment"># Actually, no. It's fixed. This will fail because it passes :-)</span> -<span class="linenum">35</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">Bug</span><span class="punct">")</span></code></pre> - </div> - </dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_2">Running specs with --diff</dt> - <script type="text/javascript">makeRed('example_group_2');</script> - <script type="text/javascript">moveProgressBar('35.2');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should print diff of different strings</span> - <div class="failure" id="failure_5"> - <div class="message"><pre>expected: "RSpec is a\nbehaviour driven development\nframework for Ruby\n", - got: "RSpec is a\nbehavior driven development\nframework for Ruby\n" (using ==) -Diff: -@@ -1,4 +1,4 @@ - RSpec is a --behavior driven development -+behaviour driven development - framework for Ruby -</pre></div> - <div class="backtrace"><pre>./failing_examples/diffing_spec.rb:13: -./spec/spec/runner/formatter/html_formatter_spec.rb:17: -./spec/spec/runner/formatter/html_formatter_spec.rb:13:in `chdir' -./spec/spec/runner/formatter/html_formatter_spec.rb:13:</pre></div> - <pre class="ruby"><code><span class="linenum">11</span><span class="ident">framework</span> <span class="keyword">for</span> <span class="constant">Ruby</span> -<span class="linenum">12</span><span class="constant">EOF</span> -<span class="offending"><span class="linenum">13</span> <span class="ident">usa</span><span class="punct">.</span><span class="ident">should</span> <span class="punct">==</span> <span class="ident">uk</span></span> -<span class="linenum">14</span> <span class="keyword">end</span></code></pre> - </div> - </dd> - <script type="text/javascript">moveProgressBar('41.1');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should print diff of different objects' pretty representation</span> - <div class="failure" id="failure_6"> - <div class="message"><pre>expected <Animal -name=bob, -species=tortoise -> -, got <Animal -name=bob, -species=giraffe -> - (using .eql?) -Diff: -@@ -1,5 +1,5 @@ - <Animal - name=bob, --species=giraffe -+species=tortoise - > -</pre></div> - <div class="backtrace"><pre>./failing_examples/diffing_spec.rb:34: -./spec/spec/runner/formatter/html_formatter_spec.rb:17: -./spec/spec/runner/formatter/html_formatter_spec.rb:13:in `chdir' -./spec/spec/runner/formatter/html_formatter_spec.rb:13:</pre></div> - <pre class="ruby"><code><span class="linenum">32</span> <span class="ident">expected</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">"</span><span class="string">bob</span><span class="punct">",</span> <span class="punct">"</span><span class="string">giraffe</span><span class="punct">"</span> -<span class="linenum">33</span> <span class="ident">actual</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">"</span><span class="string">bob</span><span class="punct">",</span> <span class="punct">"</span><span class="string">tortoise</span><span class="punct">"</span> -<span class="offending"><span class="linenum">34</span> <span class="ident">expected</span><span class="punct">.</span><span class="ident">should</span> <span class="ident">eql</span><span class="punct">(</span><span class="ident">actual</span><span class="punct">)</span></span> -<span class="linenum">35</span> <span class="keyword">end</span> -<span class="linenum">36</span><span class="keyword">end</span></code></pre> - </div> - </dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_3">A consumer of a stub</dt> - <script type="text/javascript">moveProgressBar('47.0');</script> - <dd class="spec passed"><span class="passed_spec_name">should be able to stub methods on any Object</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_4">A stubbed method on a class</dt> - <script type="text/javascript">moveProgressBar('52.9');</script> - <dd class="spec passed"><span class="passed_spec_name">should return the stubbed value</span></dd> - <script type="text/javascript">moveProgressBar('58.8');</script> - <dd class="spec passed"><span class="passed_spec_name">should revert to the original method after each spec</span></dd> - <script type="text/javascript">moveProgressBar('64.7');</script> - <dd class="spec passed"><span class="passed_spec_name">can stub! and mock the same message</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_5">A mock</dt> - <script type="text/javascript">moveProgressBar('70.5');</script> - <dd class="spec passed"><span class="passed_spec_name">can stub!</span></dd> - <script type="text/javascript">moveProgressBar('76.4');</script> - <dd class="spec passed"><span class="passed_spec_name">can stub! and mock</span></dd> - <script type="text/javascript">moveProgressBar('82.3');</script> - <dd class="spec passed"><span class="passed_spec_name">can stub! and mock the same message</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_6">pending example (using pending method)</dt> - <script type="text/javascript">makeYellow('example_group_6');</script> - <script type="text/javascript">moveProgressBar('88.2');</script> - <dd class="spec not_implemented"><span class="not_implemented_spec_name">should be reported as "PENDING: for some reason" (PENDING: for some reason)</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_7">pending example (with no block)</dt> - <script type="text/javascript">makeYellow('example_group_7');</script> - <script type="text/javascript">moveProgressBar('94.1');</script> - <dd class="spec not_implemented"><span class="not_implemented_spec_name">should be reported as "PENDING: Not Yet Implemented" (PENDING: Not Yet Implemented)</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_8">pending example (with block for pending)</dt> - <script type="text/javascript">makeYellow('example_group_8');</script> - <script type="text/javascript">moveProgressBar('100.0');</script> - <dd class="spec not_implemented"><span class="not_implemented_spec_name">should have a failing block, passed to pending, reported as "PENDING: for some reason" (PENDING: for some reason)</span></dd> - </dl> -</div> -<script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>x seconds</strong>";</script> -<script type="text/javascript">document.getElementById('totals').innerHTML = "17 examples, 6 failures, 3 pending";</script> -</div> -</div> -</body> -</html> diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html b/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html index 466621865..029cee62e 100644 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html +++ b/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html @@ -16,9 +16,6 @@ font-size: 80%; } </style> -</head> -<body> -<div class="rspec-report"> <script type="text/javascript"> // <![CDATA[ function moveProgressBar(percentDone) { @@ -46,7 +43,7 @@ function makeYellow(element_id) { </script> <style type="text/css"> #rspec-header { - background: #65C400; color: #fff; + background: #65C400; color: #fff; height: 4em; } .rspec-report h1 { @@ -54,15 +51,16 @@ function makeYellow(element_id) { padding: 10px; font-family: "Lucida Grande", Helvetica, sans-serif; font-size: 1.8em; + position: absolute; } #summary { margin: 0; padding: 5px 10px; font-family: "Lucida Grande", Helvetica, sans-serif; text-align: right; - position: absolute; top: 0px; right: 0px; + float:right; } #summary p { @@ -165,9 +163,14 @@ a { } </style> +</head> +<body> +<div class="rspec-report"> <div id="rspec-header"> - <h1>RSpec Results</h1> + <div id="label"> + <h1>RSpec Code Examples</h1> + </div> <div id="summary"> <p id="totals"> </p> @@ -187,52 +190,50 @@ a { <dd class="spec failed"> <span class="failed_spec_name">should fail when expected message not received</span> <div class="failure" id="failure_1"> - <div class="message"><pre>Mock 'poke me' expected :poke with (any args) once, but received it 0 times</pre></div> - <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:13: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:28: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `instance_eval'</pre></div> - <pre class="ruby"><code><span class="linenum">11</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">should fail when expected message not received</span><span class="punct">"</span> <span class="keyword">do</span> -<span class="linenum">12</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">poke me</span><span class="punct">")</span> -<span class="offending"><span class="linenum">13</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:poke</span><span class="punct">)</span></span> -<span class="linenum">14</span> <span class="keyword">end</span> -<span class="linenum">15</span> </code></pre> + <div class="message"><pre>Mock "poke me" expected :poke with (any args) once, but received it 0 times</pre></div> + <div class="backtrace"><pre>examples/failing/mocking_example.rb:11: +spec/spec_helper.rb:42:in `run_with' +./spec/spec/runner/formatter/html_formatter_spec.rb:41: +./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir' +./spec/spec/runner/formatter/html_formatter_spec.rb:29:</pre></div> + <pre class="ruby"><code><span class="linenum">9</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">should fail when expected message not received</span><span class="punct">"</span> <span class="keyword">do</span> +<span class="linenum">10</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">poke me</span><span class="punct">")</span> +<span class="offending"><span class="linenum">11</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:poke</span><span class="punct">)</span></span> +<span class="linenum">12</span> <span class="keyword">end</span> +<span class="linenum">13</span> </code></pre> </div> </dd> <script type="text/javascript">moveProgressBar('17.6');</script> <dd class="spec failed"> <span class="failed_spec_name">should fail when messages are received out of order</span> <div class="failure" id="failure_2"> - <div class="message"><pre>Mock 'one two three' received :three out of order</pre></div> - <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:22: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:16:in `instance_eval' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:28: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `instance_eval'</pre></div> - <pre class="ruby"><code><span class="linenum">20</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:three</span><span class="punct">).</span><span class="ident">ordered</span> -<span class="linenum">21</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">one</span> -<span class="offending"><span class="linenum">22</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">three</span></span> -<span class="linenum">23</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">two</span> -<span class="linenum">24</span> <span class="keyword">end</span></code></pre> + <div class="message"><pre>Mock "one two three" received :three out of order</pre></div> + <div class="backtrace"><pre>examples/failing/mocking_example.rb:20: +spec/spec_helper.rb:42:in `run_with' +./spec/spec/runner/formatter/html_formatter_spec.rb:41: +./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir' +./spec/spec/runner/formatter/html_formatter_spec.rb:29:</pre></div> + <pre class="ruby"><code><span class="linenum">18</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:three</span><span class="punct">).</span><span class="ident">ordered</span> +<span class="linenum">19</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">one</span> +<span class="offending"><span class="linenum">20</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">three</span></span> +<span class="linenum">21</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">two</span> +<span class="linenum">22</span> <span class="keyword">end</span></code></pre> </div> </dd> <script type="text/javascript">moveProgressBar('23.5');</script> <dd class="spec failed"> <span class="failed_spec_name">should get yelled at when sending unexpected messages</span> <div class="failure" id="failure_3"> - <div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (any args) 0 times, but received it once</pre></div> - <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:28: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:28: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `instance_eval'</pre></div> - <pre class="ruby"><code><span class="linenum">26</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">should get yelled at when sending unexpected messages</span><span class="punct">"</span> <span class="keyword">do</span> -<span class="linenum">27</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">don't talk to me</span><span class="punct">")</span> -<span class="offending"><span class="linenum">28</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span></span> -<span class="linenum">29</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span> -<span class="linenum">30</span> <span class="keyword">end</span></code></pre> + <div class="message"><pre>Mock "don't talk to me" expected :any_message_at_all with (no args) 0 times, but received it once</pre></div> + <div class="backtrace"><pre>examples/failing/mocking_example.rb:27: +spec/spec_helper.rb:42:in `run_with' +./spec/spec/runner/formatter/html_formatter_spec.rb:41: +./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir' +./spec/spec/runner/formatter/html_formatter_spec.rb:29:</pre></div> + <pre class="ruby"><code><span class="linenum">25</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">don't talk to me</span><span class="punct">")</span> +<span class="linenum">26</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span> +<span class="offending"><span class="linenum">27</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span></span> +<span class="linenum">28</span> <span class="keyword">end</span></code></pre> </div> </dd> <script type="text/javascript">moveProgressBar('29.4');</script> @@ -240,17 +241,16 @@ a { <span class="failed_spec_name">has a bug we need to fix</span> <div class="failure" id="failure_4"> <div class="message"><pre>Expected pending 'here is the bug' to fail. No Error was raised.</pre></div> - <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:33: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:33:in `instance_eval' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:28: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `instance_eval'</pre></div> - <pre class="ruby"><code><span class="linenum">31</span> -<span class="linenum">32</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">has a bug we need to fix</span><span class="punct">"</span> <span class="keyword">do</span> -<span class="offending"><span class="linenum">33</span> <span class="ident">pending</span> <span class="punct">"</span><span class="string">here is the bug</span><span class="punct">"</span> <span class="keyword">do</span></span> -<span class="linenum">34</span> <span class="comment"># Actually, no. It's fixed. This will fail because it passes :-)</span> -<span class="linenum">35</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">Bug</span><span class="punct">")</span></code></pre> + <div class="backtrace"><pre>examples/failing/mocking_example.rb:31: +spec/spec_helper.rb:42:in `run_with' +./spec/spec/runner/formatter/html_formatter_spec.rb:41: +./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir' +./spec/spec/runner/formatter/html_formatter_spec.rb:29:</pre></div> + <pre class="ruby"><code><span class="linenum">29</span> +<span class="linenum">30</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">has a bug we need to fix</span><span class="punct">"</span> <span class="keyword">do</span> +<span class="offending"><span class="linenum">31</span> <span class="ident">pending</span> <span class="punct">"</span><span class="string">here is the bug</span><span class="punct">"</span> <span class="keyword">do</span></span> +<span class="linenum">32</span> <span class="comment"># Actually, no. It's fixed. This will fail because it passes :-)</span> +<span class="linenum">33</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">Bug</span><span class="punct">")</span></code></pre> </div> </dd> </dl> @@ -265,19 +265,19 @@ a { <div class="failure" id="failure_5"> <div class="message"><pre>expected: "RSpec is a\nbehaviour driven development\nframework for Ruby\n", got: "RSpec is a\nbehavior driven development\nframework for Ruby\n" (using ==) -Diff: + + Diff: @@ -1,4 +1,4 @@ RSpec is a --behavior driven development -+behaviour driven development +-behaviour driven development ++behavior driven development framework for Ruby </pre></div> - <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/diffing_spec.rb:13: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/diffing_spec.rb:2:in `instance_eval' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:28: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `instance_eval'</pre></div> + <div class="backtrace"><pre>examples/failing/diffing_spec.rb:13: +spec/spec_helper.rb:42:in `run_with' +./spec/spec/runner/formatter/html_formatter_spec.rb:41: +./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir' +./spec/spec/runner/formatter/html_formatter_spec.rb:29:</pre></div> <pre class="ruby"><code><span class="linenum">11</span><span class="ident">framework</span> <span class="keyword">for</span> <span class="constant">Ruby</span> <span class="linenum">12</span><span class="constant">EOF</span> <span class="offending"><span class="linenum">13</span> <span class="ident">usa</span><span class="punct">.</span><span class="ident">should</span> <span class="punct">==</span> <span class="ident">uk</span></span> @@ -288,29 +288,25 @@ Diff: <dd class="spec failed"> <span class="failed_spec_name">should print diff of different objects' pretty representation</span> <div class="failure" id="failure_6"> - <div class="message"><pre>expected <Animal + <div class="message"><pre> +expected <Animal name=bob, species=tortoise > -, got <Animal + + got <Animal name=bob, species=giraffe > - (using .eql?) -Diff: -@@ -1,5 +1,5 @@ - <Animal - name=bob, --species=giraffe -+species=tortoise - > + + +(compared using eql?) </pre></div> - <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/diffing_spec.rb:34: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/diffing_spec.rb:31:in `instance_eval' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:28: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `chdir' -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24: -/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `instance_eval'</pre></div> + <div class="backtrace"><pre>examples/failing/diffing_spec.rb:34: +spec/spec_helper.rb:42:in `run_with' +./spec/spec/runner/formatter/html_formatter_spec.rb:41: +./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir' +./spec/spec/runner/formatter/html_formatter_spec.rb:29:</pre></div> <pre class="ruby"><code><span class="linenum">32</span> <span class="ident">expected</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">"</span><span class="string">bob</span><span class="punct">",</span> <span class="punct">"</span><span class="string">giraffe</span><span class="punct">"</span> <span class="linenum">33</span> <span class="ident">actual</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">"</span><span class="string">bob</span><span class="punct">",</span> <span class="punct">"</span><span class="string">tortoise</span><span class="punct">"</span> <span class="offending"><span class="linenum">34</span> <span class="ident">expected</span><span class="punct">.</span><span class="ident">should</span> <span class="ident">eql</span><span class="punct">(</span><span class="ident">actual</span><span class="punct">)</span></span> diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6.html b/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6.html index bc6637583..1461d03e4 100644 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6.html +++ b/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6.html @@ -16,9 +16,6 @@ font-size: 80%; } </style> -</head> -<body> -<div class="rspec-report"> <script type="text/javascript"> // <![CDATA[ function moveProgressBar(percentDone) { @@ -46,7 +43,7 @@ function makeYellow(element_id) { </script> <style type="text/css"> #rspec-header { - background: #65C400; color: #fff; + background: #65C400; color: #fff; height: 4em; } .rspec-report h1 { @@ -54,15 +51,16 @@ function makeYellow(element_id) { padding: 10px; font-family: "Lucida Grande", Helvetica, sans-serif; font-size: 1.8em; + position: absolute; } #summary { margin: 0; padding: 5px 10px; font-family: "Lucida Grande", Helvetica, sans-serif; text-align: right; - position: absolute; top: 0px; right: 0px; + float:right; } #summary p { @@ -165,9 +163,14 @@ a { } </style> +</head> +<body> +<div class="rspec-report"> <div id="rspec-header"> - <h1>RSpec Results</h1> + <div id="label"> + <h1>RSpec Code Examples</h1> + </div> <div id="summary"> <p id="totals"> </p> @@ -187,47 +190,50 @@ a { <dd class="spec failed"> <span class="failed_spec_name">should fail when expected message not received</span> <div class="failure" id="failure_1"> - <div class="message"><pre>Mock 'poke me' expected :poke with (any args) once, but received it 0 times</pre></div> - <div class="backtrace"><pre>./failing_examples/mocking_example.rb:13: -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25: -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir' -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div> - <pre class="ruby"><code><span class="linenum">11</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">should fail when expected message not received</span><span class="punct">"</span> <span class="keyword">do</span> -<span class="linenum">12</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">poke me</span><span class="punct">")</span> -<span class="offending"><span class="linenum">13</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:poke</span><span class="punct">)</span></span> -<span class="linenum">14</span> <span class="keyword">end</span> -<span class="linenum">15</span> </code></pre> + <div class="message"><pre>Mock "poke me" expected :poke with (any args) once, but received it 0 times</pre></div> + <div class="backtrace"><pre>./examples/failing/mocking_example.rb:11: +./spec/spec_helper.rb:44:in `run_with' +./spec/spec/runner/formatter/html_formatter_spec.rb:41: +./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir' +./spec/spec/runner/formatter/html_formatter_spec.rb:29:</pre></div> + <pre class="ruby"><code><span class="linenum">9</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">should fail when expected message not received</span><span class="punct">"</span> <span class="keyword">do</span> +<span class="linenum">10</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">poke me</span><span class="punct">")</span> +<span class="offending"><span class="linenum">11</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:poke</span><span class="punct">)</span></span> +<span class="linenum">12</span> <span class="keyword">end</span> +<span class="linenum">13</span> </code></pre> </div> </dd> <script type="text/javascript">moveProgressBar('17.6');</script> <dd class="spec failed"> <span class="failed_spec_name">should fail when messages are received out of order</span> <div class="failure" id="failure_2"> - <div class="message"><pre>Mock 'one two three' received :three out of order</pre></div> - <div class="backtrace"><pre>./failing_examples/mocking_example.rb:22: -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25: -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir' -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div> - <pre class="ruby"><code><span class="linenum">20</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:three</span><span class="punct">).</span><span class="ident">ordered</span> -<span class="linenum">21</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">one</span> -<span class="offending"><span class="linenum">22</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">three</span></span> -<span class="linenum">23</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">two</span> -<span class="linenum">24</span> <span class="keyword">end</span></code></pre> + <div class="message"><pre>Mock "one two three" received :three out of order</pre></div> + <div class="backtrace"><pre>./examples/failing/mocking_example.rb:20: +./spec/spec_helper.rb:44:in `run_with' +./spec/spec/runner/formatter/html_formatter_spec.rb:41: +./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir' +./spec/spec/runner/formatter/html_formatter_spec.rb:29:</pre></div> + <pre class="ruby"><code><span class="linenum">18</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:three</span><span class="punct">).</span><span class="ident">ordered</span> +<span class="linenum">19</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">one</span> +<span class="offending"><span class="linenum">20</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">three</span></span> +<span class="linenum">21</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">two</span> +<span class="linenum">22</span> <span class="keyword">end</span></code></pre> </div> </dd> <script type="text/javascript">moveProgressBar('23.5');</script> <dd class="spec failed"> <span class="failed_spec_name">should get yelled at when sending unexpected messages</span> <div class="failure" id="failure_3"> - <div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (no args) 0 times, but received it once</pre></div> - <div class="backtrace"><pre>./failing_examples/mocking_example.rb:29: -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25: -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir' -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div> - <pre class="ruby"><code><span class="linenum">27</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">don't talk to me</span><span class="punct">")</span> -<span class="linenum">28</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span> -<span class="offending"><span class="linenum">29</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span></span> -<span class="linenum">30</span> <span class="keyword">end</span></code></pre> + <div class="message"><pre>Mock "don't talk to me" expected :any_message_at_all with (no args) 0 times, but received it once</pre></div> + <div class="backtrace"><pre>./examples/failing/mocking_example.rb:27: +./spec/spec_helper.rb:44:in `run_with' +./spec/spec/runner/formatter/html_formatter_spec.rb:41: +./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir' +./spec/spec/runner/formatter/html_formatter_spec.rb:29:</pre></div> + <pre class="ruby"><code><span class="linenum">25</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">don't talk to me</span><span class="punct">")</span> +<span class="linenum">26</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span> +<span class="offending"><span class="linenum">27</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span></span> +<span class="linenum">28</span> <span class="keyword">end</span></code></pre> </div> </dd> <script type="text/javascript">moveProgressBar('29.4');</script> @@ -235,15 +241,16 @@ a { <span class="failed_spec_name">has a bug we need to fix</span> <div class="failure" id="failure_4"> <div class="message"><pre>Expected pending 'here is the bug' to fail. No Error was raised.</pre></div> - <div class="backtrace"><pre>./failing_examples/mocking_example.rb:33: -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25: -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir' -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div> - <pre class="ruby"><code><span class="linenum">31</span> -<span class="linenum">32</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">has a bug we need to fix</span><span class="punct">"</span> <span class="keyword">do</span> -<span class="offending"><span class="linenum">33</span> <span class="ident">pending</span> <span class="punct">"</span><span class="string">here is the bug</span><span class="punct">"</span> <span class="keyword">do</span></span> -<span class="linenum">34</span> <span class="comment"># Actually, no. It's fixed. This will fail because it passes :-)</span> -<span class="linenum">35</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">Bug</span><span class="punct">")</span></code></pre> + <div class="backtrace"><pre>./examples/failing/mocking_example.rb:31: +./spec/spec_helper.rb:44:in `run_with' +./spec/spec/runner/formatter/html_formatter_spec.rb:41: +./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir' +./spec/spec/runner/formatter/html_formatter_spec.rb:29:</pre></div> + <pre class="ruby"><code><span class="linenum">29</span> +<span class="linenum">30</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">has a bug we need to fix</span><span class="punct">"</span> <span class="keyword">do</span> +<span class="offending"><span class="linenum">31</span> <span class="ident">pending</span> <span class="punct">"</span><span class="string">here is the bug</span><span class="punct">"</span> <span class="keyword">do</span></span> +<span class="linenum">32</span> <span class="comment"># Actually, no. It's fixed. This will fail because it passes :-)</span> +<span class="linenum">33</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">Bug</span><span class="punct">")</span></code></pre> </div> </dd> </dl> @@ -258,17 +265,19 @@ a { <div class="failure" id="failure_5"> <div class="message"><pre>expected: "RSpec is a\nbehaviour driven development\nframework for Ruby\n", got: "RSpec is a\nbehavior driven development\nframework for Ruby\n" (using ==) -Diff: + + Diff: @@ -1,4 +1,4 @@ RSpec is a -behaviour driven development +behavior driven development framework for Ruby </pre></div> - <div class="backtrace"><pre>./failing_examples/diffing_spec.rb:13: -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25: -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir' -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div> + <div class="backtrace"><pre>./examples/failing/diffing_spec.rb:13: +./spec/spec_helper.rb:44:in `run_with' +./spec/spec/runner/formatter/html_formatter_spec.rb:41: +./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir' +./spec/spec/runner/formatter/html_formatter_spec.rb:29:</pre></div> <pre class="ruby"><code><span class="linenum">11</span><span class="ident">framework</span> <span class="keyword">for</span> <span class="constant">Ruby</span> <span class="linenum">12</span><span class="constant">EOF</span> <span class="offending"><span class="linenum">13</span> <span class="ident">usa</span><span class="punct">.</span><span class="ident">should</span> <span class="punct">==</span> <span class="ident">uk</span></span> @@ -279,27 +288,25 @@ Diff: <dd class="spec failed"> <span class="failed_spec_name">should print diff of different objects' pretty representation</span> <div class="failure" id="failure_6"> - <div class="message"><pre>expected <Animal + <div class="message"><pre> +expected <Animal name=bob, species=tortoise > -, got <Animal + + got <Animal name=bob, species=giraffe > - (using .eql?) -Diff: -@@ -1,5 +1,5 @@ - <Animal - name=bob, --species=tortoise -+species=giraffe - > + + +(compared using eql?) </pre></div> - <div class="backtrace"><pre>./failing_examples/diffing_spec.rb:34: -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25: -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir' -/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div> + <div class="backtrace"><pre>./examples/failing/diffing_spec.rb:34: +./spec/spec_helper.rb:44:in `run_with' +./spec/spec/runner/formatter/html_formatter_spec.rb:41: +./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir' +./spec/spec/runner/formatter/html_formatter_spec.rb:29:</pre></div> <pre class="ruby"><code><span class="linenum">32</span> <span class="ident">expected</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">"</span><span class="string">bob</span><span class="punct">",</span> <span class="punct">"</span><span class="string">giraffe</span><span class="punct">"</span> <span class="linenum">33</span> <span class="ident">actual</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">"</span><span class="string">bob</span><span class="punct">",</span> <span class="punct">"</span><span class="string">tortoise</span><span class="punct">"</span> <span class="offending"><span class="linenum">34</span> <span class="ident">expected</span><span class="punct">.</span><span class="ident">should</span> <span class="ident">eql</span><span class="punct">(</span><span class="ident">actual</span><span class="punct">)</span></span> diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatter_spec.rb index f6388267f..bbff1ef42 100644 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatter_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatter_spec.rb @@ -1,63 +1,118 @@ -require File.dirname(__FILE__) + '/../../../spec_helper' -require 'hpricot' # Needed to compare generated with wanted HTML +# require 'spec_helper' + +begin # See rescue all the way at the bottom + +require 'nokogiri' # Needed to compare generated with wanted HTML require 'spec/runner/formatter/html_formatter' module Spec module Runner module Formatter describe HtmlFormatter do - ['--diff', '--dry-run'].each do |opt| - def jruby? - PLATFORM == 'java' - end - - it "should produce HTML identical to the one we designed manually with #{opt}" do - root = File.expand_path(File.dirname(__FILE__) + '/../../../..') - suffix = jruby? ? '-jruby' : '' - expected_file = File.dirname(__FILE__) + "/html_formatted-#{::VERSION}#{suffix}.html" - raise "There is no HTML file with expected content for this platform: #{expected_file}" unless File.file?(expected_file) - expected_html = File.read(expected_file) - - Dir.chdir(root) do - args = ['failing_examples/mocking_example.rb', 'failing_examples/diffing_spec.rb', 'examples/pure/stubbing_example.rb', 'examples/pure/pending_example.rb', '--format', 'html', opt] - err = StringIO.new - out = StringIO.new - CommandLine.run( - OptionParser.parse(args, err, out) - ) - - seconds = /\d+\.\d+ seconds/ - html = out.string.gsub seconds, 'x seconds' - expected_html.gsub! seconds, 'x seconds' - - if opt == '--diff' - # Uncomment this line temporarily in order to overwrite the expected with actual. - # Use with care!!! - # File.open(expected_file, 'w') {|io| io.write(html)} - - doc = Hpricot(html) - backtraces = doc.search("div.backtrace").collect {|e| e.at("/pre").inner_html} - doc.search("div.backtrace").remove - - expected_doc = Hpricot(expected_html) - expected_backtraces = expected_doc.search("div.backtrace").collect {|e| e.at("/pre").inner_html} - expected_doc.search("div.backtrace").remove - - doc.inner_html.should == expected_doc.inner_html - - expected_backtraces.each_with_index do |expected_line, i| - expected_path, expected_line_number, expected_suffix = expected_line.split(':') - actual_path, actual_line_number, actual_suffix = backtraces[i].split(':') - File.expand_path(actual_path).should == File.expand_path(expected_path) - actual_line_number.should == expected_line_number - end - else - html.should =~ /This was a dry-run/m - end + + treats_method_missing_as_private + + attr_reader :root, :expected_file, :expected_html + + before do + @root = File.expand_path("#{File.dirname(__FILE__)}/../../../..") + suffix = jruby? ? '-jruby' : '' + @expected_file = "#{File.dirname(__FILE__)}/html_formatted-#{::RUBY_VERSION}#{suffix}.html" + raise "There is no HTML file with expected content for this platform: #{expected_file}" unless File.file?(expected_file) + @expected_html = File.read(expected_file) + end + + # Uncomment this line temporarily in order to overwrite the expected with actual. + # Use with care!!! + # describe "file generator" do + # it "generates a new comparison file" do + # Dir.chdir(root) do + # args = [ + # 'examples/failing/mocking_example.rb', + # 'examples/failing/diffing_spec.rb', + # 'examples/passing/stubbing_example.rb', + # 'examples/passing/pending_example.rb', + # '--format', + # 'html', + # "--diff" + # ] + # err = StringIO.new + # out = StringIO.new + # run_with ::Spec::Runner::OptionParser.parse(args, err, out) + # + # seconds = /\d+\.\d+ seconds/ + # html = out.string.gsub seconds, 'x seconds' + # + # File.open(expected_file, 'w') {|io| io.write(html)} + # end + # end + # end + + it "should produce HTML identical to the one we designed manually with --diff" do + Dir.chdir(root) do + args = [ + 'examples/failing/mocking_example.rb', + 'examples/failing/diffing_spec.rb', + 'examples/passing/stubbing_example.rb', + 'examples/passing/pending_example.rb', + '--format', + 'html', + "--diff" + ] + err = StringIO.new + out = StringIO.new + run_with ::Spec::Runner::OptionParser.parse(args, err, out) + + seconds = /\d+\.\d+ seconds/ + html = out.string.gsub seconds, 'x seconds' + expected_html.gsub! seconds, 'x seconds' + + doc = Nokogiri::HTML(html) + backtraces = doc.search("div.backtrace").collect {|e| e.at("pre").inner_html} + doc.css("div.backtrace").remove + + expected_doc = Nokogiri::HTML(expected_html) + expected_backtraces = expected_doc.search("div.backtrace").collect {|e| e.at("pre").inner_html} + expected_doc.search("div.backtrace").remove + + doc.inner_html.should == expected_doc.inner_html + + expected_backtraces.each_with_index do |expected_line, i| + expected_path, expected_line_number, expected_suffix = expected_line.split(':') + actual_path, actual_line_number, actual_suffix = backtraces[i].split(':') + File.expand_path(actual_path).should == File.expand_path(expected_path) + actual_line_number.should == expected_line_number end end end + + it "should produce HTML identical to the one we designed manually with --dry-run" do + Dir.chdir(root) do + args = [ + 'examples/failing/mocking_example.rb', + 'examples/failing/diffing_spec.rb', + 'examples/passing/stubbing_example.rb', + 'examples/passing/pending_example.rb', + '--format', + 'html', + "--dry-run" + ] + err = StringIO.new + out = StringIO.new + run_with ::Spec::Runner::OptionParser.parse(args, err, out) + + seconds = /\d+\.\d+ seconds/ + html = out.string.gsub seconds, 'x seconds' + expected_html.gsub! seconds, 'x seconds' + + html.should =~ /This was a dry-run/m + end + end end end end end + +rescue LoadError + warn "nokogiri not loaded -- skipping HtmlFormatter specs" +end diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/nested_text_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/nested_text_formatter_spec.rb index 3a627451e..29e96ff52 100644 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/nested_text_formatter_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/formatter/nested_text_formatter_spec.rb @@ -1,177 +1,169 @@ -require File.dirname(__FILE__) + '/../../../spec_helper.rb' +require 'spec_helper' require 'spec/runner/formatter/nested_text_formatter' module Spec module Runner module Formatter describe NestedTextFormatter do - it_should_behave_like "sandboxed rspec_options" - attr_reader :io, :options, :formatter, :example_group - before(:each) do - @io = StringIO.new - options.stub!(:dry_run).and_return(false) - options.stub!(:colour).and_return(false) - @formatter = NestedTextFormatter.new(options, io) - @example_group = ::Spec::Example::ExampleGroup.describe("ExampleGroup") do - specify "example" do - end + with_sandboxed_options do + attr_reader :io, :options, :formatter, :example_group + before(:each) do + @io = StringIO.new + options.stub!(:dry_run).and_return(false) + options.stub!(:colour).and_return(false) + @formatter = NestedTextFormatter.new(options, io) + @example_group = Class.new(::Spec::Example::ExampleGroupDouble).describe("ExampleGroup") + @example_group.example("example") {} end - end - - describe "where ExampleGroup has no superclasss with a description" do - before do - add_example_group - end - - def add_example_group - formatter.add_example_group(example_group) - end - - describe "#dump_summary" do - it "should produce standard summary without pending when pending has a 0 count" do - formatter.dump_summary(3, 2, 1, 0) - expected_output = <<-OUT - ExampleGroup - - Finished in 3 seconds - - 2 examples, 1 failure - OUT - io.string.should == expected_output.gsub(/^ /, '') + describe "where ExampleGroup has no superclass with a description" do + def example_group_started + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group)) end - it "should produce standard summary" do - formatter.dump_summary(3, 2, 1, 4) - expected_output = <<-OUT - ExampleGroup + before do + example_group_started + end - Finished in 3 seconds + describe "#dump_summary" do + it "should produce standard summary without pending when pending has a 0 count" do + formatter.dump_summary(3, 2, 1, 0) + io.string.should == <<-OUT +ExampleGroup - 2 examples, 1 failure, 4 pending - OUT - io.string.should == expected_output.gsub(/^ /, '') - end - end +Finished in 3 seconds - describe "#add_example_group" do - describe "when ExampleGroup has description_args" do - before do - example_group.description_args.should_not be_nil +2 examples, 1 failure +OUT end - describe "when ExampleGroup has no parents with description args" do - before do - example_group.superclass.description_args.should be_nil - end + it "should produce standard summary" do + formatter.dump_summary(3, 2, 1, 4) + io.string.should == <<-OUT +ExampleGroup - it "should push ExampleGroup name" do - io.string.should eql("ExampleGroup\n") - end +Finished in 3 seconds + +2 examples, 1 failure, 4 pending +OUT end + end - describe "when ExampleGroup has one parent with description args" do - attr_reader :child_example_group - def add_example_group - example_group.description_args.should_not be_nil - @child_example_group = Class.new(example_group).describe("Child ExampleGroup") + describe "#example_group_started" do + describe "when ExampleGroup has a nested description" do + + describe "when ExampleGroup has no parents with nested description" do + it "should push ExampleGroup name" do + io.string.should eql("ExampleGroup\n") + end end - describe "and parent ExampleGroups have not been printed" do - before do - formatter.add_example_group(child_example_group) + describe "when ExampleGroup has one parent with nested description" do + attr_reader :child_example_group + def example_group_started + @child_example_group = Class.new(example_group).describe("Child ExampleGroup") + end + + describe "and parent ExampleGroups have not been printed" do + before do + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(child_example_group)) + end + + it "should push ExampleGroup name with two spaces of indentation" do + io.string.should == <<-OUT +ExampleGroup + Child ExampleGroup +OUT + end end - it "should push ExampleGroup name with two spaces of indentation" do - expected_output = <<-OUT - ExampleGroup - Child ExampleGroup - OUT - io.string.should == expected_output.gsub(/^ /, '') + describe "and parent ExampleGroups have been printed" do + before do + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group)) + io.string = "" + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(child_example_group)) + end + + it "should print only the indented ExampleGroup" do + io.string.should == <<-OUT + Child ExampleGroup +OUT + end end end - describe "and parent ExampleGroups have been printed" do - before do - formatter.add_example_group(example_group) - io.string = "" - formatter.add_example_group(child_example_group) + describe "when ExampleGroup has two parents with nested description" do + attr_reader :child_example_group, :grand_child_example_group + def example_group_started + @child_example_group = Class.new(example_group).describe("Child ExampleGroup") + @grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup") + end + + describe "and parent ExampleGroups have not been printed" do + before do + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(grand_child_example_group)) + + end + + it "should print the entire nested ExampleGroup heirarchy" do + io.string.should == <<-OUT +ExampleGroup + Child ExampleGroup + GrandChild ExampleGroup +OUT + end end - it "should print only the indented ExampleGroup" do - expected_output = <<-OUT - Child ExampleGroup - OUT - io.string.should == expected_output.gsub(/^ /, '') + describe "and parent ExampleGroups have been printed" do + before do + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(child_example_group)) + io.string = "" + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(grand_child_example_group)) + end + + it "should print only the indented ExampleGroup" do + io.string.should == <<-OUT + GrandChild ExampleGroup +OUT + end end end end - describe "when ExampleGroup has two parents with description args" do - attr_reader :child_example_group, :grand_child_example_group - def add_example_group - example_group.description_args.should_not be_nil - @child_example_group = Class.new(example_group).describe("Child ExampleGroup") - @grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup") - end + describe "when ExampleGroup nested description is blank" do + attr_reader :child_example_group describe "and parent ExampleGroups have not been printed" do - before do - formatter.add_example_group(grand_child_example_group) + def example_group_started + @child_example_group = Class.new(example_group) + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(child_example_group)) end - it "should print the entire nested ExampleGroup heirarchy" do - expected_output = <<-OUT - ExampleGroup - Child ExampleGroup - GrandChild ExampleGroup - OUT - io.string.should == expected_output.gsub(/^ /, '') + it "should render only the parent ExampleGroup" do + io.string.should == <<-OUT +ExampleGroup +OUT end end describe "and parent ExampleGroups have been printed" do - before do - formatter.add_example_group(child_example_group) + def example_group_started + @child_example_group = Class.new(example_group) + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group)) io.string = "" - formatter.add_example_group(grand_child_example_group) + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(child_example_group)) end - it "should print only the indented ExampleGroup" do - expected_output = <<-OUT - GrandChild ExampleGroup - OUT - io.string.should == expected_output.gsub(/^ /, '') + it "should not render anything" do + io.string.should == "" end end end - end - - describe "when ExampleGroup description_args is nil" do - attr_reader :child_example_group - - describe "and parent ExampleGroups have not been printed" do - def add_example_group - @child_example_group = Class.new(example_group) - child_example_group.description_args.should be_nil - formatter.add_example_group(child_example_group) - end - - it "should render only the parent ExampleGroup" do - expected_output = <<-OUT - ExampleGroup - OUT - io.string.should == expected_output.gsub(/^ /, '') - end - end - describe "and parent ExampleGroups have been printed" do - def add_example_group - @child_example_group = Class.new(example_group) - child_example_group.description_args.should be_nil - formatter.add_example_group(example_group) - io.string = "" - formatter.add_example_group(child_example_group) + describe "when ExampleGroup nested description is blank" do + def example_group_started + example_group.set_description + super end it "should not render anything" do @@ -180,154 +172,134 @@ module Spec end end - describe "when ExampleGroup description_args is empty" do - def add_example_group - example_group.set_description - example_group.description_args.should be_empty - super - end - - it "should not render anything" do - io.string.should == "" - end - end - end - - describe "#example_failed" do - describe "where ExampleGroup has no superclasss with a description" do - describe "when having an error" do - it "should push failing spec name and failure number" do - formatter.example_failed( - example_group.it("spec"), - 98, - Reporter::Failure.new("c s", RuntimeError.new) - ) - expected_output = <<-OUT - ExampleGroup - spec (ERROR - 98) - OUT - io.string.should == expected_output.gsub(/^ /, '') + describe "#example_failed" do + describe "where ExampleGroup has no superclasss with a description" do + describe "when having an error" do + it "should push failing spec name and failure number" do + formatter.example_failed( + example_group.it("spec"), + 98, + ::Spec::Runner::Reporter::Failure.new("g", "c s", RuntimeError.new) + ) + io.string.should == <<-OUT +ExampleGroup + spec (FAILED - 98) +OUT + end end - end - describe "when having an expectation failure" do - it "should push failing spec name and failure number" do - formatter.example_failed( - example_group.it("spec"), - 98, - Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new) - ) - expected_output = <<-OUT - ExampleGroup - spec (FAILED - 98) - OUT - io.string.should == expected_output.gsub(/^ /, '') + describe "when having an expectation failure" do + it "should push failing spec name and failure number" do + formatter.example_failed( + example_group.it("spec"), + 98, + ::Spec::Runner::Reporter::Failure.new("g", "c s", Spec::Expectations::ExpectationNotMetError.new) + ) + io.string.should == <<-OUT +ExampleGroup + spec (FAILED - 98) +OUT + end end end - end - describe "where ExampleGroup has two superclasses with a description" do - attr_reader :child_example_group, :grand_child_example_group + describe "where ExampleGroup has two superclasses with a description" do + attr_reader :child_example_group, :grand_child_example_group - def add_example_group - @child_example_group = Class.new(example_group).describe("Child ExampleGroup") - @grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup") - formatter.add_example_group(grand_child_example_group) - end + def example_group_started + @child_example_group = Class.new(example_group).describe("Child ExampleGroup") + @grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup") + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(grand_child_example_group)) + end - describe "when having an error" do - it "should push failing spec name and failure number" do - formatter.example_failed( - grand_child_example_group.it("spec"), - 98, - Reporter::Failure.new("c s", RuntimeError.new) - ) - expected_output = <<-OUT - ExampleGroup - Child ExampleGroup - GrandChild ExampleGroup - spec (ERROR - 98) - OUT - io.string.should == expected_output.gsub(/^ /, '') + describe "when having an error" do + it "should push failing spec name and failure number" do + formatter.example_failed( + grand_child_example_group.it("spec"), + 98, + ::Spec::Runner::Reporter::Failure.new("g", "c s", RuntimeError.new) + ) + io.string.should == <<-OUT +ExampleGroup + Child ExampleGroup + GrandChild ExampleGroup + spec (FAILED - 98) +OUT + end end - end - describe "when having an expectation" do - it "should push failing spec name and failure number" do - formatter.example_failed( - grand_child_example_group.it("spec"), - 98, - Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new) - ) - expected_output = <<-OUT - ExampleGroup - Child ExampleGroup - GrandChild ExampleGroup - spec (FAILED - 98) - OUT - io.string.should == expected_output.gsub(/^ /, '') + describe "when having an expectation" do + it "should push failing spec name and failure number" do + formatter.example_failed( + grand_child_example_group.it("spec"), + 98, + ::Spec::Runner::Reporter::Failure.new("g", "c s", Spec::Expectations::ExpectationNotMetError.new) + ) + io.string.should == <<-OUT +ExampleGroup + Child ExampleGroup + GrandChild ExampleGroup + spec (FAILED - 98) +OUT + end end end end - end - describe "#start" do - it "should push nothing on start" do - formatter.start(5) - expected_output = <<-OUT - ExampleGroup - OUT - io.string.should == expected_output.gsub(/^ /, '') + describe "#start" do + it "should push nothing on start" do + formatter.start(5) + io.string.should == <<-OUT +ExampleGroup +OUT + end end - end - describe "#start_dump" do - it "should push nothing on start dump" do - formatter.start_dump - expected_output = <<-OUT - ExampleGroup - OUT - io.string.should == expected_output.gsub(/^ /, '') + describe "#start_dump" do + it "should push nothing on start dump" do + formatter.start_dump + io.string.should == <<-OUT +ExampleGroup +OUT + end end - end - describe "#example_passed" do - it "should push passing spec name" do - formatter.example_passed(example_group.it("spec")) - expected_output = <<-OUT - ExampleGroup - spec - OUT - io.string.should == expected_output.gsub(/^ /, '') + describe "#example_passed" do + it "should push passing spec name" do + formatter.example_passed(example_group.it("spec")) + io.string.should == <<-OUT +ExampleGroup + spec +OUT + end end - end - describe "#example_pending" do - it "should push pending example name and message" do - formatter.example_pending(example_group.examples.first, 'reason') - expected_output = <<-OUT - ExampleGroup - example (PENDING: reason) - OUT - io.string.should == expected_output.gsub(/^ /, '') - end + describe "#example_pending" do + it "should push pending example name and message" do + formatter.example_pending(example_group.examples.first, 'reason', "#{__FILE__}:#{__LINE__}") + io.string.should == <<-OUT +ExampleGroup + example (PENDING: reason) +OUT + end - it "should dump pending" do - formatter.example_pending(example_group.examples.first, 'reason') - io.rewind - formatter.dump_pending - io.string.should =~ /Pending\:\nExampleGroup example \(reason\)\n/ + it "should dump pending" do + formatter.example_pending(example_group.examples.first, 'reason', "#{__FILE__}:#{__LINE__}") + io.rewind + formatter.dump_pending + io.string.should =~ /Pending\:\n\nExampleGroup example \(reason\)\n/ + end end - end - def have_single_level_example_group_output(expected_output) - expected = "ExampleGroup\n #{expected_output}" - ::Spec::Matchers::SimpleMatcher.new(expected) do |actual| - actual == expected + def have_single_level_example_group_output(expected_output) + expected = "ExampleGroup\n #{expected_output}" + ::Spec::Matchers::SimpleMatcher.new(expected) do |actual| + actual == expected + end end end end end end end -end +end
\ No newline at end of file diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/profile_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/profile_formatter_spec.rb index 981805411..338df7089 100644 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/profile_formatter_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/formatter/profile_formatter_spec.rb @@ -1,15 +1,19 @@ -require File.dirname(__FILE__) + '/../../../spec_helper.rb' +require 'spec_helper' require 'spec/runner/formatter/profile_formatter' module Spec module Runner module Formatter describe ProfileFormatter do + + treats_method_missing_as_private + attr_reader :io, :formatter before(:each) do @io = StringIO.new options = mock('options') options.stub!(:colour).and_return(true) + options.stub!(:autospec).and_return(true) @formatter = ProfileFormatter.new(options, io) end @@ -28,10 +32,10 @@ module Spec it "should correctly record a passed example" do now = Time.now Time.stub!(:now).and_return(now) - parent_example_group = Class.new(ExampleGroup).describe('Parent') + parent_example_group = Class.new(::Spec::Example::ExampleGroupDouble).describe('Parent') child_example_group = Class.new(parent_example_group).describe('Child') - formatter.add_example_group(child_example_group) + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(child_example_group)) formatter.example_started('when foo') Time.stub!(:now).and_return(now+1) @@ -49,7 +53,7 @@ module Spec it "should print the top 10 results" do example_group = Class.new(::Spec::Example::ExampleGroup).describe("ExampleGroup") - formatter.add_example_group(example_group) + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group)) formatter.instance_variable_set("@time", Time.now) 15.times do @@ -59,7 +63,8 @@ module Spec io.should_receive(:print).exactly(10) formatter.start_dump end + end end end -end
\ No newline at end of file +end diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/progress_bar_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/progress_bar_formatter_spec.rb index 64e11b1a5..ea96ca6c4 100644 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/formatter/progress_bar_formatter_spec.rb @@ -1,15 +1,19 @@ -require File.dirname(__FILE__) + '/../../../spec_helper.rb' +require 'spec_helper' require 'spec/runner/formatter/progress_bar_formatter' module Spec module Runner module Formatter describe ProgressBarFormatter do + + treats_method_missing_as_private + before(:each) do @io = StringIO.new @options = mock('options') @options.stub!(:dry_run).and_return(false) @options.stub!(:colour).and_return(false) + @options.stub!(:autospec).and_return(false) @formatter = ProgressBarFormatter.new(@options, @io) end @@ -29,7 +33,8 @@ module Spec end end example = example_group.examples.first - @formatter.example_pending(example, "message") + @formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group)) + @formatter.example_pending(example, "message", "#{__FILE__}:#{__LINE__}") @io.rewind @formatter.dump_summary(3, 2, 1, 1) @io.string.should eql(%Q| @@ -40,30 +45,34 @@ Finished in 3 seconds end it "should push green dot for passing spec" do - @io.should_receive(:tty?).and_return(true) - @options.should_receive(:colour).and_return(true) + @formatter.stub(:output_to_file?) {false} + @io.stub(:tty?) {true} + @options.stub(:colour) {true} @formatter.example_passed("spec") @io.string.should == "\e[32m.\e[0m" end it "should push red F for failure spec" do - @io.should_receive(:tty?).and_return(true) - @options.should_receive(:colour).and_return(true) - @formatter.example_failed("spec", 98, Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new)) + @formatter.stub(:output_to_file?) {false} + @io.stub(:tty?) {true} + @options.stub(:colour) {true} + @formatter.example_failed("spec", 98, Spec::Runner::Reporter::Failure.new("g", "c s", Spec::Expectations::ExpectationNotMetError.new)) @io.string.should eql("\e[31mF\e[0m") end - it "should push magenta F for error spec" do - @io.should_receive(:tty?).and_return(true) - @options.should_receive(:colour).and_return(true) - @formatter.example_failed("spec", 98, Reporter::Failure.new("c s", RuntimeError.new)) - @io.string.should eql("\e[35mF\e[0m") + it "should push red F for error spec" do + @formatter.stub(:output_to_file?) {false} + @io.stub(:tty?) {true} + @options.stub(:colour) {true} + @formatter.example_failed("spec", 98, Spec::Runner::Reporter::Failure.new("g", "c s", RuntimeError.new)) + @io.string.should eql("\e[31mF\e[0m") end it "should push blue F for fixed pending spec" do - @io.should_receive(:tty?).and_return(true) - @options.should_receive(:colour).and_return(true) - @formatter.example_failed("spec", 98, Reporter::Failure.new("c s", Spec::Example::PendingExampleFixedError.new)) + @formatter.stub(:output_to_file?) {false} + @io.stub(:tty?) {true} + @options.stub(:colour) {true} + @formatter.example_failed("spec", 98, Spec::Runner::Reporter::Failure.new("g", "c s", Spec::Example::PendingExampleFixedError.new)) @io.string.should eql("\e[34mF\e[0m") end @@ -88,15 +97,18 @@ EOE EOE end - it "should dump pending" do + it "should dump pending with file and line number" do example_group = ExampleGroup.describe("example_group") do specify "example" do end end example = example_group.examples.first - @formatter.example_pending(example, "message") + file = __FILE__ + line = __LINE__ - 5 + @formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group)) + @formatter.example_pending(example, "message", "#{__FILE__}:#{__LINE__}") @formatter.dump_pending - @io.string.should =~ /Pending\:\nexample_group example \(message\)\n/ + @io.string.should =~ /Pending:\n\nexample_group example \(message\)\n#{file}:#{line}/m end end @@ -106,11 +118,11 @@ EOE @options = mock('options') @out.stub!(:puts) @formatter = ProgressBarFormatter.new(@options, @out) - @formatter.class.send :public, :output_to_tty? + @formatter.class.__send__ :public, :output_to_tty? end after(:each) do - @formatter.class.send :protected, :output_to_tty? + @formatter.class.__send__ :protected, :output_to_tty? end it "should not throw NoMethodError on output_to_tty?" do diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/snippet_extractor_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/snippet_extractor_spec.rb index 4bb2f1585..c683c39a8 100644 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/snippet_extractor_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/formatter/snippet_extractor_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../spec_helper.rb' +require 'spec_helper' require 'spec/runner/formatter/snippet_extractor' module Spec diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb deleted file mode 100644 index da1b69f79..000000000 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +++ /dev/null @@ -1,103 +0,0 @@ -require File.dirname(__FILE__) + '/../../../spec_helper' -require 'hpricot' # Needed to compare generated with wanted HTML -require 'spec/runner/formatter/text_mate_formatter' - -module Spec - module Runner - module Formatter - describe TextMateFormatter do - attr_reader :root, :suffix, :expected_file - before do - @root = File.expand_path(File.dirname(__FILE__) + '/../../../..') - @suffix = jruby? ? '-jruby' : '' - @expected_file = File.dirname(__FILE__) + "/text_mate_formatted-#{::VERSION}#{suffix}.html" - end - - def jruby? - PLATFORM == 'java' - end - - def produces_html_identical_to_manually_designed_document(opt) - root = File.expand_path(File.dirname(__FILE__) + '/../../../..') - - Dir.chdir(root) do - args = [ - 'failing_examples/mocking_example.rb', - 'failing_examples/diffing_spec.rb', - 'examples/pure/stubbing_example.rb', - 'examples/pure/pending_example.rb', - '--format', - 'textmate', - opt - ] - err = StringIO.new - out = StringIO.new - options = ::Spec::Runner::OptionParser.parse(args, err, out) - Spec::Runner::CommandLine.run(options) - - yield(out.string) - end - end - - # # Uncomment this spec temporarily in order to overwrite the expected with actual. - # # Use with care!!! - # describe TextMateFormatter, "functional spec file generator" do - # it "generates a new comparison file" do - # Dir.chdir(root) do - # args = ['failing_examples/mocking_example.rb', 'failing_examples/diffing_spec.rb', 'examples/pure/stubbing_example.rb', 'examples/pure/pending_example.rb', '--format', 'textmate', '--diff'] - # err = StringIO.new - # out = StringIO.new - # Spec::Runner::CommandLine.run( - # ::Spec::Runner::OptionParser.parse(args, err, out) - # ) - # - # seconds = /\d+\.\d+ seconds/ - # html = out.string.gsub seconds, 'x seconds' - # - # File.open(expected_file, 'w') {|io| io.write(html)} - # end - # end - # end - - describe "functional spec using --diff" do - it "should produce HTML identical to the one we designed manually with --diff" do - produces_html_identical_to_manually_designed_document("--diff") do |html| - suffix = jruby? ? '-jruby' : '' - expected_file = File.dirname(__FILE__) + "/text_mate_formatted-#{::VERSION}#{suffix}.html" - unless File.file?(expected_file) - raise "There is no HTML file with expected content for this platform: #{expected_file}" - end - expected_html = File.read(expected_file) - - seconds = /\d+\.\d+ seconds/ - html.gsub! seconds, 'x seconds' - expected_html.gsub! seconds, 'x seconds' - - doc = Hpricot(html) - backtraces = doc.search("div.backtrace/a") - doc.search("div.backtrace").remove - - expected_doc = Hpricot(expected_html) - expected_doc.search("div.backtrace").remove - - doc.inner_html.should == expected_doc.inner_html - - backtraces.each do |backtrace_link| - backtrace_link[:href].should include("txmt://open?url=") - end - end - end - - end - - describe "functional spec using --dry-run" do - it "should produce HTML identical to the one we designed manually with --dry-run" do - produces_html_identical_to_manually_designed_document("--dry-run") do |html, expected_html| - html.should =~ /This was a dry-run/m - end - end - end - end - end - end -end
\ No newline at end of file diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/specdoc_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/specdoc_formatter_spec.rb index 3974f9533..ac4e0eeea 100644 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/specdoc_formatter_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/formatter/specdoc_formatter_spec.rb @@ -1,154 +1,155 @@ -require File.dirname(__FILE__) + '/../../../spec_helper.rb' +require 'spec_helper' require 'spec/runner/formatter/specdoc_formatter' module Spec module Runner module Formatter describe SpecdocFormatter do - it_should_behave_like "sandboxed rspec_options" - attr_reader :io, :options, :formatter, :example_group - before(:each) do - @io = StringIO.new - options.stub!(:dry_run).and_return(false) - options.stub!(:colour).and_return(false) - @formatter = SpecdocFormatter.new(options, io) - @example_group = ::Spec::Example::ExampleGroup.describe("ExampleGroup") do - specify "example" do + with_sandboxed_options do + attr_reader :io, :formatter, :example_group + before(:each) do + @io = StringIO.new + options.stub!(:dry_run).and_return(false) + options.stub!(:colour).and_return(false) + @formatter = SpecdocFormatter.new(options, io) + @example_group = ::Spec::Example::ExampleGroup.describe("ExampleGroup") do + specify "example" do + end end end - end - describe "where ExampleGroup has no superclasss with a description" do - before do - add_example_group - end - - def add_example_group - formatter.add_example_group(example_group) - end + describe "where ExampleGroup has no superclasss with a description" do + before do + example_group_started + end - describe "#dump_summary" do - it "should produce standard summary without pending when pending has a 0 count" do - formatter.dump_summary(3, 2, 1, 0) - io.string.should have_example_group_output("\nFinished in 3 seconds\n\n2 examples, 1 failure\n") + def example_group_started + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group)) end - it "should produce standard summary" do - formatter.dump_summary(3, 2, 1, 4) - io.string.should have_example_group_output("\nFinished in 3 seconds\n\n2 examples, 1 failure, 4 pending\n") + describe "#dump_summary" do + it "should produce standard summary without pending when pending has a 0 count" do + formatter.dump_summary(3, 2, 1, 0) + io.string.should have_example_group_output("\nFinished in 3 seconds\n\n2 examples, 1 failure\n") + end + + it "should produce standard summary" do + formatter.dump_summary(3, 2, 1, 4) + io.string.should have_example_group_output("\nFinished in 3 seconds\n\n2 examples, 1 failure, 4 pending\n") + end end - end - describe "#add_example_group" do - it "should push ExampleGroup name" do - io.string.should eql("\nExampleGroup\n") + describe "#example_group_started" do + it "should push ExampleGroup name" do + io.string.should eql("\nExampleGroup\n") + end end - end - describe "#example_failed" do - describe "where ExampleGroup has no superclasss with a description" do - describe "when having an error" do - it "should push failing spec name and failure number" do - formatter.example_failed( - example_group.it("spec"), - 98, - Reporter::Failure.new("c s", RuntimeError.new) - ) - io.string.should have_example_group_output("- spec (ERROR - 98)\n") + describe "#example_failed" do + describe "where ExampleGroup has no superclasss with a description" do + describe "when having an error" do + it "should push failing spec name and failure number" do + formatter.example_failed( + example_group.it("spec"), + 98, + Spec::Runner::Reporter::Failure.new("g", "c s", RuntimeError.new) + ) + io.string.should have_example_group_output("- spec (FAILED - 98)\n") + end end - end - describe "when having an expectation failure" do - it "should push failing spec name and failure number" do - formatter.example_failed( - example_group.it("spec"), - 98, - Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new) - ) - io.string.should have_example_group_output("- spec (FAILED - 98)\n") + describe "when having an expectation failure" do + it "should push failing spec name and failure number" do + formatter.example_failed( + example_group.it("spec"), + 98, + Spec::Runner::Reporter::Failure.new("g", "c s", Spec::Expectations::ExpectationNotMetError.new) + ) + io.string.should have_example_group_output("- spec (FAILED - 98)\n") + end end end - end - describe "where ExampleGroup has two superclasses with a description" do - attr_reader :child_example_group, :grand_child_example_group + describe "where ExampleGroup has two superclasses with a description" do + attr_reader :child_example_group, :grand_child_example_group - def add_example_group - @child_example_group = Class.new(example_group).describe("Child ExampleGroup") - @grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup") - formatter.add_example_group(grand_child_example_group) - end - - describe "when having an error" do - it "should push failing spec name and failure number" do - formatter.example_failed( - example_group.it("spec"), - 98, - Reporter::Failure.new("c s", RuntimeError.new) - ) - io.string.should have_nested_example_group_output("- spec (ERROR - 98)\n") + def example_group_started + @child_example_group = Class.new(example_group).describe("Child ExampleGroup") + @grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup") + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(grand_child_example_group)) end - end - describe "when having an expectation" do - it "should push failing spec name and failure number" do - formatter.example_failed( + describe "when having an error" do + it "should push failing spec name and failure number" do + formatter.example_failed( example_group.it("spec"), 98, - Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new) - ) - io.string.should have_nested_example_group_output("- spec (FAILED - 98)\n") + Spec::Runner::Reporter::Failure.new("g", "c s", RuntimeError.new) + ) + io.string.should have_nested_example_group_output("- spec (FAILED - 98)\n") + end end - end - def have_nested_example_group_output(expected_output) - expected_full_output = "\nExampleGroup Child ExampleGroup GrandChild ExampleGroup\n#{expected_output}" - ::Spec::Matchers::SimpleMatcher.new(expected_full_output) do |actual| - actual == expected_full_output + describe "when having an expectation" do + it "should push failing spec name and failure number" do + formatter.example_failed( + example_group.it("spec"), + 98, + Spec::Runner::Reporter::Failure.new("g", "c s", Spec::Expectations::ExpectationNotMetError.new) + ) + io.string.should have_nested_example_group_output("- spec (FAILED - 98)\n") + end + end + + def have_nested_example_group_output(expected_output) + expected_full_output = "\nExampleGroup Child ExampleGroup GrandChild ExampleGroup\n#{expected_output}" + ::Spec::Matchers::SimpleMatcher.new(expected_full_output) do |actual| + actual == expected_full_output + end end end end - end - describe "#start" do - it "should push nothing on start" do - formatter.start(5) - io.string.should have_example_group_output("") + describe "#start" do + it "should push nothing on start" do + formatter.start(5) + io.string.should have_example_group_output("") + end end - end - describe "#start_dump" do - it "should push nothing on start dump" do - formatter.start_dump - io.string.should have_example_group_output("") + describe "#start_dump" do + it "should push nothing on start dump" do + formatter.start_dump + io.string.should have_example_group_output("") + end end - end - describe "#example_passed" do - it "should push passing spec name" do - formatter.example_passed(example_group.it("spec")) - io.string.should have_example_group_output("- spec\n") + describe "#example_passed" do + it "should push passing spec name" do + formatter.example_passed(example_group.it("spec")) + io.string.should have_example_group_output("- spec\n") + end end - end - describe "#example_pending" do - it "should push pending example name and message" do - formatter.example_pending(example_group.examples.first, 'reason') - io.string.should have_example_group_output("- example (PENDING: reason)\n") - end + describe "#example_pending" do + it "should push pending example name and message" do + formatter.example_pending(example_group.examples.first, 'reason', "#{__FILE__}:#{__LINE__}") + io.string.should have_example_group_output("- example (PENDING: reason)\n") + end - it "should dump pending" do - formatter.example_pending(example_group.examples.first, 'reason') - io.rewind - formatter.dump_pending - io.string.should =~ /Pending\:\nExampleGroup example \(reason\)\n/ + it "should dump pending" do + formatter.example_pending(example_group.examples.first, 'reason', "#{__FILE__}:#{__LINE__}") + io.rewind + formatter.dump_pending + io.string.should =~ /Pending\:\n\nExampleGroup example \(reason\)\n/ + end end - end - def have_example_group_output(expected_output) - expected = "\nExampleGroup\n#{expected_output}" - ::Spec::Matchers::SimpleMatcher.new(expected) do |actual| - actual == expected + def have_example_group_output(expected_output) + expected = "\nExampleGroup\n#{expected_output}" + ::Spec::Matchers::SimpleMatcher.new(expected) do |actual| + actual == expected + end end end end diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/story/html_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/story/html_formatter_spec.rb deleted file mode 100644 index 37fb7c670..000000000 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/story/html_formatter_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../spec_helper.rb' -require 'spec/runner/formatter/story/html_formatter' - -module Spec - module Runner - module Formatter - module Story - describe HtmlFormatter do - before :each do - @out = StringIO.new - @options = mock('options') - @reporter = HtmlFormatter.new(@options, @out) - end - - it "should just be poked at" do - @reporter.run_started(1) - @reporter.story_started('story_title', 'narrative') - - @reporter.scenario_started('story_title', 'succeeded_scenario_name') - @reporter.step_succeeded('given', 'succeded_step', 'one', 'two') - @reporter.scenario_succeeded('story_title', 'succeeded_scenario_name') - - @reporter.scenario_started('story_title', 'pending_scenario_name') - @reporter.step_pending('when', 'pending_step', 'un', 'deux') - @reporter.scenario_pending('story_title', 'pending_scenario_name', 'not done') - - @reporter.scenario_started('story_title', 'failed_scenario_name') - @reporter.step_failed('then', 'failed_step', 'en', 'to') - @reporter.scenario_failed('story_title', 'failed_scenario_name', NameError.new('sup')) - - @reporter.scenario_started('story_title', 'scenario_with_given_scenario_name') - @reporter.found_scenario('given scenario', 'succeeded_scenario_name') - - @reporter.story_ended('story_title', 'narrative') - @reporter.run_ended - end - - it "should create spans for params" do - @reporter.step_succeeded('given', 'a $coloured $animal', 'brown', 'dog') - @out.string.should == " <li class=\"passed\">Given a <span class=\"param\">brown</span> <span class=\"param\">dog</span></li>\n" - end - - it 'should create spanes for params in regexp steps' do - @reporter.step_succeeded :given, /a (pink|blue) (.*)/, 'brown', 'dog' - @out.string.should == " <li class=\"passed\">Given a <span class=\"param\">brown</span> <span class=\"param\">dog</span></li>\n" - end - - it "should create a ul for collected_steps" do - @reporter.collected_steps(['Given a $coloured $animal', 'Given a $n legged eel']) - @out.string.should == (<<-EOF) - <ul id="stock_steps" style="display: none;"> - <li>Given a $coloured $animal</li> - <li>Given a $n legged eel</li> - </ul> -EOF - end - end - end - end - end -end
\ No newline at end of file diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb deleted file mode 100644 index 626ec4628..000000000 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +++ /dev/null @@ -1,439 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../spec_helper.rb' -require 'spec/runner/formatter/story/plain_text_formatter' - -module Spec - module Runner - module Formatter - module Story - describe PlainTextFormatter do - before :each do - # given - @out = StringIO.new - @tweaker = mock('tweaker') - @tweaker.stub!(:tweak_backtrace) - @options = mock('options') - @options.stub!(:colour).and_return(false) - @options.stub!(:backtrace_tweaker).and_return(@tweaker) - @formatter = PlainTextFormatter.new(@options, @out) - end - - it 'should summarize the number of scenarios when the run ends' do - # when - @formatter.run_started(3) - @formatter.scenario_started(nil, nil) - @formatter.scenario_succeeded('story', 'scenario1') - @formatter.scenario_started(nil, nil) - @formatter.scenario_succeeded('story', 'scenario2') - @formatter.scenario_started(nil, nil) - @formatter.scenario_succeeded('story', 'scenario3') - @formatter.run_ended - - # then - @out.string.should include('3 scenarios') - end - - it 'should summarize the number of successful scenarios when the run ends' do - # when - @formatter.run_started(3) - @formatter.scenario_started(nil, nil) - @formatter.scenario_succeeded('story', 'scenario1') - @formatter.scenario_started(nil, nil) - @formatter.scenario_succeeded('story', 'scenario2') - @formatter.scenario_started(nil, nil) - @formatter.scenario_succeeded('story', 'scenario3') - @formatter.run_ended - - # then - @out.string.should include('3 scenarios: 3 succeeded') - end - - it 'should summarize the number of failed scenarios when the run ends' do - # when - @formatter.run_started(3) - @formatter.scenario_started(nil, nil) - @formatter.scenario_succeeded('story', 'scenario1') - @formatter.scenario_started(nil, nil) - @formatter.scenario_failed('story', 'scenario2', exception_from { raise RuntimeError, 'oops' }) - @formatter.scenario_started(nil, nil) - @formatter.scenario_failed('story', 'scenario3', exception_from { raise RuntimeError, 'oops' }) - @formatter.run_ended - - # then - @out.string.should include("3 scenarios: 1 succeeded, 2 failed") - end - - it 'should end cleanly (no characters on the last line) with successes' do - # when - @formatter.run_started(1) - @formatter.scenario_started(nil, nil) - @formatter.scenario_succeeded('story', 'scenario') - @formatter.run_ended - - # then - @out.string.should =~ /\n\z/ - end - - it 'should end cleanly (no characters on the last line) with failures' do - # when - @formatter.run_started(1) - @formatter.scenario_started(nil, nil) - @formatter.scenario_failed('story', 'scenario', exception_from { raise RuntimeError, 'oops' }) - @formatter.run_ended - - # then - @out.string.should =~ /\n\z/ - end - - it 'should end cleanly (no characters on the last line) with pending steps' do - # when - @formatter.run_started(1) - @formatter.scenario_started(nil, nil) - @formatter.step_pending(:then, 'do pend') - @formatter.scenario_pending('story', 'scenario', exception_from { raise RuntimeError, 'oops' }) - @formatter.run_ended - - # then - @out.string.should =~ /\n\z/ - end - - it 'should summarize the number of pending scenarios when the run ends' do - # when - @formatter.run_started(3) - @formatter.scenario_started(nil, nil) - @formatter.scenario_succeeded('story', 'scenario1') - @formatter.scenario_started(nil, nil) - @formatter.scenario_pending('story', 'scenario2', 'message') - @formatter.scenario_started(nil, nil) - @formatter.scenario_pending('story', 'scenario3', 'message') - @formatter.run_ended - - # then - @out.string.should include("3 scenarios: 1 succeeded, 0 failed, 2 pending") - end - - it "should only count the first failure in one scenario" do - # when - @formatter.run_started(3) - @formatter.scenario_started(nil, nil) - @formatter.scenario_succeeded('story', 'scenario1') - @formatter.scenario_started(nil, nil) - @formatter.scenario_failed('story', 'scenario2', exception_from { raise RuntimeError, 'oops' }) - @formatter.scenario_failed('story', 'scenario2', exception_from { raise RuntimeError, 'oops again' }) - @formatter.scenario_started(nil, nil) - @formatter.scenario_failed('story', 'scenario3', exception_from { raise RuntimeError, 'oops' }) - @formatter.run_ended - - # then - @out.string.should include("3 scenarios: 1 succeeded, 2 failed") - end - - it "should only count the first pending in one scenario" do - # when - @formatter.run_started(3) - @formatter.scenario_started(nil, nil) - @formatter.scenario_succeeded('story', 'scenario1') - @formatter.scenario_started(nil, nil) - @formatter.scenario_pending('story', 'scenario2', 'because ...') - @formatter.scenario_pending('story', 'scenario2', 'because ...') - @formatter.scenario_started(nil, nil) - @formatter.scenario_pending('story', 'scenario3', 'because ...') - @formatter.run_ended - - # then - @out.string.should include("3 scenarios: 1 succeeded, 0 failed, 2 pending") - end - - it "should only count a failure before the first pending in one scenario" do - # when - @formatter.run_started(3) - @formatter.scenario_started(nil, nil) - @formatter.scenario_succeeded('story', 'scenario1') - @formatter.scenario_started(nil, nil) - @formatter.scenario_pending('story', 'scenario2', exception_from { raise RuntimeError, 'oops' }) - @formatter.scenario_failed('story', 'scenario2', exception_from { raise RuntimeError, 'oops again' }) - @formatter.scenario_started(nil, nil) - @formatter.scenario_failed('story', 'scenario3', exception_from { raise RuntimeError, 'oops' }) - @formatter.run_ended - - # then - @out.string.should include("3 scenarios: 1 succeeded, 1 failed, 1 pending") - end - - it 'should produce details of the first failure each failed scenario when the run ends' do - # when - @formatter.run_started(3) - @formatter.scenario_started(nil, nil) - @formatter.scenario_succeeded('story', 'scenario1') - @formatter.scenario_started(nil, nil) - @formatter.scenario_failed('story', 'scenario2', exception_from { raise RuntimeError, 'oops2' }) - @formatter.scenario_failed('story', 'scenario2', exception_from { raise RuntimeError, 'oops2 - this one should not appear' }) - @formatter.scenario_started(nil, nil) - @formatter.scenario_failed('story', 'scenario3', exception_from { raise RuntimeError, 'oops3' }) - @formatter.run_ended - - # then - @out.string.should include("FAILURES:\n") - @out.string.should include("1) story (scenario2) FAILED") - @out.string.should include("RuntimeError: oops2") - @out.string.should_not include("RuntimeError: oops2 - this one should not appear") - @out.string.should include("2) story (scenario3) FAILED") - @out.string.should include("RuntimeError: oops3") - end - - it 'should produce details of each pending step when the run ends' do - # when - @formatter.run_started(2) - @formatter.story_started('story 1', 'narrative') - @formatter.scenario_started('story 1', 'scenario 1') - @formatter.step_pending(:given, 'todo 1', []) - @formatter.story_started('story 2', 'narrative') - @formatter.scenario_started('story 2', 'scenario 2') - @formatter.step_pending(:given, 'todo 2', []) - @formatter.run_ended - - # then - @out.string.should include("Pending Steps:\n") - @out.string.should include("1) story 1 (scenario 1): todo 1") - @out.string.should include("2) story 2 (scenario 2): todo 2") - end - - it 'should document a story title and narrative' do - # when - @formatter.story_started 'story', 'narrative' - - # then - @out.string.should include("Story: story\n\n narrative") - end - - it 'should document a scenario name' do - # when - @formatter.scenario_started 'story', 'scenario' - - # then - @out.string.should include("\n\n Scenario: scenario") - end - - it 'should document a step by sentence-casing its name' do - # when - @formatter.step_succeeded :given, 'a context' - @formatter.step_succeeded :when, 'an event' - @formatter.step_succeeded :then, 'an outcome' - - # then - @out.string.should include("\n\n Given a context\n\n When an event\n\n Then an outcome") - end - - it 'should document additional givens using And' do - # when - @formatter.step_succeeded :given, 'step 1' - @formatter.step_succeeded :given, 'step 2' - @formatter.step_succeeded :given, 'step 3' - - # then - @out.string.should include(" Given step 1\n And step 2\n And step 3") - end - - it 'should document additional events using And' do - # when - @formatter.step_succeeded :when, 'step 1' - @formatter.step_succeeded :when, 'step 2' - @formatter.step_succeeded :when, 'step 3' - - # then - @out.string.should include(" When step 1\n And step 2\n And step 3") - end - - it 'should document additional outcomes using And' do - # when - @formatter.step_succeeded :then, 'step 1' - @formatter.step_succeeded :then, 'step 2' - @formatter.step_succeeded :then, 'step 3' - - # then - @out.string.should include(" Then step 1\n And step 2\n And step 3") - end - - it 'should document a GivenScenario followed by a Given using And' do - # when - @formatter.step_succeeded :'given scenario', 'a scenario' - @formatter.step_succeeded :given, 'a context' - - # then - @out.string.should include(" Given scenario a scenario\n And a context") - end - - it 'should document steps with replaced params' do - @formatter.step_succeeded :given, 'a $coloured dog with $n legs', 'pink', 21 - @out.string.should include(" Given a pink dog with 21 legs") - end - - it 'should document steps that include dollar signs ($)' do - @formatter.step_succeeded :given, 'kicks that cost $$amount', 50 - @out.string.should include("Given kicks that cost $50") - end - - it 'should document regexp steps with replaced params' do - @formatter.step_succeeded :given, /a (pink|blue) dog with (.*) legs/, 'pink', 21 - @out.string.should include(" Given a pink dog with 21 legs") - end - - it 'should document regex steps that include dollar signs ($)' do - @formatter.step_succeeded :given, /kicks that cost \$(\d+)/, 50 - @out.string.should include("Given kicks that cost $50") - end - - it "should append PENDING for the first pending step" do - @formatter.scenario_started('','') - @formatter.step_pending(:given, 'a context') - - @out.string.should include('Given a context (PENDING)') - end - - it "should append PENDING for pending after already pending" do - @formatter.scenario_started('','') - @formatter.step_pending(:given, 'a context') - @formatter.step_pending(:when, 'I say hey') - - @out.string.should include('When I say hey (PENDING)') - end - - it "should append FAILED for the first failiure" do - @formatter.scenario_started('','') - @formatter.step_failed(:given, 'a context') - - @out.string.should include('Given a context (FAILED)') - end - - it "should append SKIPPED for the second failiure" do - @formatter.scenario_started('','') - @formatter.step_failed(:given, 'a context') - @formatter.step_failed(:when, 'I say hey') - - @out.string.should include('When I say hey (SKIPPED)') - end - - it "should append SKIPPED for a failure after PENDING" do - @formatter.scenario_started('','') - @formatter.step_pending(:given, 'a context') - @formatter.step_failed(:when, 'I say hey') - - @out.string.should include('When I say hey (SKIPPED)') - end - - it "should print steps which succeeded in green" do - @out.stub!(:tty?).and_return(true) - @options.stub!(:colour).and_return(true) - - @formatter.scenario_started('','') - @formatter.step_succeeded(:given, 'a context') - - @out.string.should =~ /\e\[32m[\n\s]+Given a context\e\[0m/m - end - - it "should print failed steps in red" do - @out.stub!(:tty?).and_return(true) - @options.stub!(:colour).and_return(true) - - @formatter.scenario_started('','') - @formatter.step_failed(:given, 'a context') - - @out.string.should =~ /\e\[31m[\n\s]+Given a context\e\[0m/m - end - - it "should print ' (FAILED)' in red" do - @out.stub!(:tty?).and_return(true) - @options.stub!(:colour).and_return(true) - - @formatter.scenario_started('','') - @formatter.step_failed(:given, 'a context') - - @out.string.should =~ /\e\[31m \(FAILED\)\e\[0m/ - end - - it "should print pending steps in yellow" do - @out.stub!(:tty?).and_return(true) - @options.stub!(:colour).and_return(true) - - @formatter.scenario_started('','') - @formatter.step_pending(:given, 'a context') - - @out.string.should =~ /\e\[33m[\n\s]+Given a context\e\[0m/m - end - - it "should print ' (PENDING)' in yellow" do - @out.stub!(:tty?).and_return(true) - @options.stub!(:colour).and_return(true) - - @formatter.scenario_started('','') - @formatter.step_pending(:given, 'a context') - - @out.string.should =~ /\e\[33m \(PENDING\)\e\[0m/ - end - - it "should print skipped steps in yellow if the scenario is already pending" do - @out.stub!(:tty?).and_return(true) - @options.stub!(:colour).and_return(true) - - @formatter.scenario_started('','') - @formatter.step_pending(:given, 'a context') - @formatter.step_failed(:when, 'I say hey') - - @out.string.should =~ /\e\[33m[\n\s]+When I say hey\e\[0m/m - end - - it "should print ' (SKIPPED)' in yellow if the scenario is already pending" do - @out.stub!(:tty?).and_return(true) - @options.stub!(:colour).and_return(true) - - @formatter.scenario_started('','') - @formatter.step_pending(:given, 'a context') - @formatter.step_failed(:when, 'I say hey') - - @out.string.should =~ /\e\[33m \(SKIPPED\)\e\[0m/ - end - - it "should print skipped steps in red if the scenario has already failed" do - @out.stub!(:tty?).and_return(true) - @options.stub!(:colour).and_return(true) - - @formatter.scenario_started('','') - @formatter.step_failed(:given, 'a context') - @formatter.step_failed(:when, 'I say hey') - - @out.string.should =~ /\e\[31m[\n\s]+When I say hey\e\[0m/m - end - - it "should print ' (SKIPPED)' in red if the scenario has already failed" do - @out.stub!(:tty?).and_return(true) - @options.stub!(:colour).and_return(true) - - @formatter.scenario_started('','') - @formatter.step_failed(:given, 'a context') - @formatter.step_failed(:when, 'I say hey') - - @out.string.should =~ /\e\[31m \(SKIPPED\)\e\[0m/m - end - - it 'should print some white space after each story' do - # when - @formatter.story_ended 'title', 'narrative' - - # then - @out.string.should include("\n\n") - end - - it "should print nothing for collected_steps" do - @formatter.collected_steps(['Given a $coloured $animal', 'Given a $n legged eel']) - @out.string.should == ("") - end - - it "should ignore messages it doesn't care about" do - lambda { - @formatter.this_method_does_not_exist - }.should_not raise_error - end - end - end - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/text_mate_formatted-1.8.4.html b/vendor/plugins/rspec/spec/spec/runner/formatter/text_mate_formatted-1.8.4.html deleted file mode 100644 index 3f263747a..000000000 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/text_mate_formatted-1.8.4.html +++ /dev/null @@ -1,365 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - <title>RSpec results</title> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <meta http-equiv="Expires" content="-1" /> - <meta http-equiv="Pragma" content="no-cache" /> - <style type="text/css"> - body { - margin: 0; - padding: 0; - background: #fff; - font-size: 80%; - } - </style> -</head> -<body> -<div class="rspec-report"> - <script type="text/javascript"> - // <![CDATA[ -function moveProgressBar(percentDone) { - document.getElementById("rspec-header").style.width = percentDone +"%"; -} -function makeRed(element_id) { - document.getElementById(element_id).style.background = '#C40D0D'; - document.getElementById(element_id).style.color = '#FFFFFF'; -} - -function makeYellow(element_id) { - if (element_id == "rspec-header" && document.getElementById(element_id).style.background != '#C40D0D') - { - document.getElementById(element_id).style.background = '#FAF834'; - document.getElementById(element_id).style.color = '#000000'; - } - else - { - document.getElementById(element_id).style.background = '#FAF834'; - document.getElementById(element_id).style.color = '#000000'; - } -} - - // ]]> - </script> - <style type="text/css"> -#rspec-header { - background: #65C400; color: #fff; -} - -.rspec-report h1 { - margin: 0px 10px 0px 10px; - padding: 10px; - font-family: "Lucida Grande", Helvetica, sans-serif; - font-size: 1.8em; -} - -#summary { - margin: 0; padding: 5px 10px; - font-family: "Lucida Grande", Helvetica, sans-serif; - text-align: right; - position: absolute; - top: 0px; - right: 0px; -} - -#summary p { - margin: 0 0 0 2px; -} - -#summary #totals { - font-size: 1.2em; -} - -.example_group { - margin: 0 10px 5px; - background: #fff; -} - -dl { - margin: 0; padding: 0 0 5px; - font: normal 11px "Lucida Grande", Helvetica, sans-serif; -} - -dt { - padding: 3px; - background: #65C400; - color: #fff; - font-weight: bold; -} - -dd { - margin: 5px 0 5px 5px; - padding: 3px 3px 3px 18px; -} - -dd.spec.passed { - border-left: 5px solid #65C400; - border-bottom: 1px solid #65C400; - background: #DBFFB4; color: #3D7700; -} - -dd.spec.failed { - border-left: 5px solid #C20000; - border-bottom: 1px solid #C20000; - color: #C20000; background: #FFFBD3; -} - -dd.spec.not_implemented { - border-left: 5px solid #FAF834; - border-bottom: 1px solid #FAF834; - background: #FCFB98; color: #131313; -} - -dd.spec.pending_fixed { - border-left: 5px solid #0000C2; - border-bottom: 1px solid #0000C2; - color: #0000C2; background: #D3FBFF; -} - -.backtrace { - color: #000; - font-size: 12px; -} - -a { - color: #BE5C00; -} - -/* Ruby code, style similar to vibrant ink */ -.ruby { - font-size: 12px; - font-family: monospace; - color: white; - background-color: black; - padding: 0.1em 0 0.2em 0; -} - -.ruby .keyword { color: #FF6600; } -.ruby .constant { color: #339999; } -.ruby .attribute { color: white; } -.ruby .global { color: white; } -.ruby .module { color: white; } -.ruby .class { color: white; } -.ruby .string { color: #66FF00; } -.ruby .ident { color: white; } -.ruby .method { color: #FFCC00; } -.ruby .number { color: white; } -.ruby .char { color: white; } -.ruby .comment { color: #9933CC; } -.ruby .symbol { color: white; } -.ruby .regex { color: #44B4CC; } -.ruby .punct { color: white; } -.ruby .escape { color: white; } -.ruby .interp { color: white; } -.ruby .expr { color: white; } - -.ruby .offending { background-color: gray; } -.ruby .linenum { - width: 75px; - padding: 0.1em 1em 0.2em 0; - color: #000000; - background-color: #FFFBD3; -} - - </style> - -<div id="rspec-header"> - <h1>RSpec Results</h1> - - <div id="summary"> - <p id="totals"> </p> - <p id="duration"> </p> - </div> -</div> - -<div class="results"> -<div class="example_group"> - <dl> - <dt id="example_group_1">Mocker</dt> - <script type="text/javascript">moveProgressBar('5.8');</script> - <dd class="spec passed"><span class="passed_spec_name">should be able to call mock()</span></dd> - <script type="text/javascript">makeRed('rspec-header');</script> - <script type="text/javascript">makeRed('example_group_1');</script> - <script type="text/javascript">moveProgressBar('11.7');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should fail when expected message not received</span> - <div class="failure" id="failure_1"> - <div class="message"><pre>Mock 'poke me' expected :poke with (any args) once, but received it 0 times</pre></div> - <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/failing_examples/mocking_example.rb&line=13">./failing_examples/mocking_example.rb:13</a> -<a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=52">./spec/spec/runner/formatter/spec_mate_formatter_spec.rb:52</a> -<a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=48">./spec/spec/runner/formatter/spec_mate_formatter_spec.rb:48</a> </pre></div> - <pre class="ruby"><code><span class="linenum">11</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">should fail when expected message not received</span><span class="punct">"</span> <span class="keyword">do</span> -<span class="linenum">12</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">poke me</span><span class="punct">")</span> -<span class="offending"><span class="linenum">13</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:poke</span><span class="punct">)</span></span> -<span class="linenum">14</span> <span class="keyword">end</span> -<span class="linenum">15</span> </code></pre> - </div> - </dd> - <script type="text/javascript">moveProgressBar('17.6');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should fail when messages are received out of order</span> - <div class="failure" id="failure_2"> - <div class="message"><pre>Mock 'one two three' received :three out of order</pre></div> - <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/failing_examples/mocking_example.rb&line=22">./failing_examples/mocking_example.rb:22</a> -<a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=52">./spec/spec/runner/formatter/spec_mate_formatter_spec.rb:52</a> -<a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=48">./spec/spec/runner/formatter/spec_mate_formatter_spec.rb:48</a> </pre></div> - <pre class="ruby"><code><span class="linenum">20</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:three</span><span class="punct">).</span><span class="ident">ordered</span> -<span class="linenum">21</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">one</span> -<span class="offending"><span class="linenum">22</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">three</span></span> -<span class="linenum">23</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">two</span> -<span class="linenum">24</span> <span class="keyword">end</span></code></pre> - </div> - </dd> - <script type="text/javascript">moveProgressBar('23.5');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should get yelled at when sending unexpected messages</span> - <div class="failure" id="failure_3"> - <div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (any args) 0 times, but received it once</pre></div> - <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/failing_examples/mocking_example.rb&line=28">./failing_examples/mocking_example.rb:28</a> -<a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=52">./spec/spec/runner/formatter/spec_mate_formatter_spec.rb:52</a> -<a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=48">./spec/spec/runner/formatter/spec_mate_formatter_spec.rb:48</a> </pre></div> - <pre class="ruby"><code><span class="linenum">26</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">should get yelled at when sending unexpected messages</span><span class="punct">"</span> <span class="keyword">do</span> -<span class="linenum">27</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">don't talk to me</span><span class="punct">")</span> -<span class="offending"><span class="linenum">28</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span></span> -<span class="linenum">29</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span> -<span class="linenum">30</span> <span class="keyword">end</span></code></pre> - </div> - </dd> - <script type="text/javascript">moveProgressBar('29.4');</script> - <dd class="spec pending_fixed"> - <span class="failed_spec_name">has a bug we need to fix</span> - <div class="failure" id="failure_4"> - <div class="message"><pre>Expected pending 'here is the bug' to fail. No Error was raised.</pre></div> - <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/failing_examples/mocking_example.rb&line=33">./failing_examples/mocking_example.rb:33</a> -<a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=52">./spec/spec/runner/formatter/spec_mate_formatter_spec.rb:52</a> -<a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=48">./spec/spec/runner/formatter/spec_mate_formatter_spec.rb:48</a> </pre></div> - <pre class="ruby"><code><span class="linenum">31</span> -<span class="linenum">32</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">has a bug we need to fix</span><span class="punct">"</span> <span class="keyword">do</span> -<span class="offending"><span class="linenum">33</span> <span class="ident">pending</span> <span class="punct">"</span><span class="string">here is the bug</span><span class="punct">"</span> <span class="keyword">do</span></span> -<span class="linenum">34</span> <span class="comment"># Actually, no. It's fixed. This will fail because it passes :-)</span> -<span class="linenum">35</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">Bug</span><span class="punct">")</span></code></pre> - </div> - </dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_2">Running specs with --diff</dt> - <script type="text/javascript">makeRed('example_group_2');</script> - <script type="text/javascript">moveProgressBar('35.2');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should print diff of different strings</span> - <div class="failure" id="failure_5"> - <div class="message"><pre>expected: "RSpec is a\nbehaviour driven development\nframework for Ruby\n", - got: "RSpec is a\nbehavior driven development\nframework for Ruby\n" (using ==) -Diff: -@@ -1,4 +1,4 @@ - RSpec is a --behavior driven development -+behaviour driven development - framework for Ruby -</pre></div> - <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/failing_examples/diffing_spec.rb&line=13">./failing_examples/diffing_spec.rb:13</a> -<a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=52">./spec/spec/runner/formatter/spec_mate_formatter_spec.rb:52</a> -<a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=48">./spec/spec/runner/formatter/spec_mate_formatter_spec.rb:48</a> </pre></div> - <pre class="ruby"><code><span class="linenum">11</span><span class="ident">framework</span> <span class="keyword">for</span> <span class="constant">Ruby</span> -<span class="linenum">12</span><span class="constant">EOF</span> -<span class="offending"><span class="linenum">13</span> <span class="ident">usa</span><span class="punct">.</span><span class="ident">should</span> <span class="punct">==</span> <span class="ident">uk</span></span> -<span class="linenum">14</span> <span class="keyword">end</span></code></pre> - </div> - </dd> - <script type="text/javascript">moveProgressBar('41.1');</script> - <dd class="spec failed"> - <span class="failed_spec_name">should print diff of different objects' pretty representation</span> - <div class="failure" id="failure_6"> - <div class="message"><pre>expected <Animal -name=bob, -species=tortoise -> -, got <Animal -name=bob, -species=giraffe -> - (using .eql?) -Diff: -@@ -1,5 +1,5 @@ - <Animal - name=bob, --species=giraffe -+species=tortoise - > -</pre></div> - <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/failing_examples/diffing_spec.rb&line=34">./failing_examples/diffing_spec.rb:34</a> -<a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=52">./spec/spec/runner/formatter/spec_mate_formatter_spec.rb:52</a> -<a href="txmt://open?url=file:///Users/aslakhellesoy/scm/rspec/trunk/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=48">./spec/spec/runner/formatter/spec_mate_formatter_spec.rb:48</a> </pre></div> - <pre class="ruby"><code><span class="linenum">32</span> <span class="ident">expected</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">"</span><span class="string">bob</span><span class="punct">",</span> <span class="punct">"</span><span class="string">giraffe</span><span class="punct">"</span> -<span class="linenum">33</span> <span class="ident">actual</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">"</span><span class="string">bob</span><span class="punct">",</span> <span class="punct">"</span><span class="string">tortoise</span><span class="punct">"</span> -<span class="offending"><span class="linenum">34</span> <span class="ident">expected</span><span class="punct">.</span><span class="ident">should</span> <span class="ident">eql</span><span class="punct">(</span><span class="ident">actual</span><span class="punct">)</span></span> -<span class="linenum">35</span> <span class="keyword">end</span> -<span class="linenum">36</span><span class="keyword">end</span></code></pre> - </div> - </dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_3">A consumer of a stub</dt> - <script type="text/javascript">moveProgressBar('47.0');</script> - <dd class="spec passed"><span class="passed_spec_name">should be able to stub methods on any Object</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_4">A stubbed method on a class</dt> - <script type="text/javascript">moveProgressBar('52.9');</script> - <dd class="spec passed"><span class="passed_spec_name">should return the stubbed value</span></dd> - <script type="text/javascript">moveProgressBar('58.8');</script> - <dd class="spec passed"><span class="passed_spec_name">should revert to the original method after each spec</span></dd> - <script type="text/javascript">moveProgressBar('64.7');</script> - <dd class="spec passed"><span class="passed_spec_name">can stub! and mock the same message</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_5">A mock</dt> - <script type="text/javascript">moveProgressBar('70.5');</script> - <dd class="spec passed"><span class="passed_spec_name">can stub!</span></dd> - <script type="text/javascript">moveProgressBar('76.4');</script> - <dd class="spec passed"><span class="passed_spec_name">can stub! and mock</span></dd> - <script type="text/javascript">moveProgressBar('82.3');</script> - <dd class="spec passed"><span class="passed_spec_name">can stub! and mock the same message</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_6">pending example (using pending method)</dt> - <script type="text/javascript">makeYellow('example_group_6');</script> - <script type="text/javascript">moveProgressBar('88.2');</script> - <dd class="spec not_implemented"><span class="not_implemented_spec_name">should be reported as "PENDING: for some reason" (PENDING: for some reason)</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_7">pending example (with no block)</dt> - <script type="text/javascript">makeYellow('example_group_7');</script> - <script type="text/javascript">moveProgressBar('94.1');</script> - <dd class="spec not_implemented"><span class="not_implemented_spec_name">should be reported as "PENDING: Not Yet Implemented" (PENDING: Not Yet Implemented)</span></dd> - </dl> -</div> -<div class="example_group"> - <dl> - <dt id="example_group_8">pending example (with block for pending)</dt> - <script type="text/javascript">makeYellow('example_group_8');</script> - <script type="text/javascript">moveProgressBar('100.0');</script> - <dd class="spec not_implemented"><span class="not_implemented_spec_name">should have a failing block, passed to pending, reported as "PENDING: for some reason" (PENDING: for some reason)</span></dd> - </dl> -</div> -<script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>x seconds</strong>";</script> -<script type="text/javascript">document.getElementById('totals').innerHTML = "17 examples, 6 failures, 3 pending";</script> -</div> -</div> -</body> -</html> diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html b/vendor/plugins/rspec/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html index 60f8d1e2e..54d761901 100644 --- a/vendor/plugins/rspec/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +++ b/vendor/plugins/rspec/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html @@ -16,9 +16,6 @@ font-size: 80%; } </style> -</head> -<body> -<div class="rspec-report"> <script type="text/javascript"> // <![CDATA[ function moveProgressBar(percentDone) { @@ -46,7 +43,7 @@ function makeYellow(element_id) { </script> <style type="text/css"> #rspec-header { - background: #65C400; color: #fff; + background: #65C400; color: #fff; height: 4em; } .rspec-report h1 { @@ -54,15 +51,16 @@ function makeYellow(element_id) { padding: 10px; font-family: "Lucida Grande", Helvetica, sans-serif; font-size: 1.8em; + position: absolute; } #summary { margin: 0; padding: 5px 10px; font-family: "Lucida Grande", Helvetica, sans-serif; text-align: right; - position: absolute; top: 0px; right: 0px; + float:right; } #summary p { @@ -165,9 +163,14 @@ a { } </style> +</head> +<body> +<div class="rspec-report"> <div id="rspec-header"> - <h1>RSpec Results</h1> + <div id="label"> + <h1>RSpec Code Examples</h1> + </div> <div id="summary"> <p id="totals"> </p> @@ -187,47 +190,47 @@ a { <dd class="spec failed"> <span class="failed_spec_name">should fail when expected message not received</span> <div class="failure" id="failure_1"> - <div class="message"><pre>Mock 'poke me' expected :poke with (any args) once, but received it 0 times</pre></div> - <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/mocking_example.rb&line=13">./failing_examples/mocking_example.rb:13</a> -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a> -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir' -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div> - <pre class="ruby"><code><span class="linenum">11</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">should fail when expected message not received</span><span class="punct">"</span> <span class="keyword">do</span> -<span class="linenum">12</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">poke me</span><span class="punct">")</span> -<span class="offending"><span class="linenum">13</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:poke</span><span class="punct">)</span></span> -<span class="linenum">14</span> <span class="keyword">end</span> -<span class="linenum">15</span> </code></pre> + <div class="message"><pre>Mock "poke me" expected :poke with (any args) once, but received it 0 times</pre></div> + <div class="backtrace"><pre><a href="txmt://open?url=file://./examples/failing/mocking_example.rb&line=11">./examples/failing/mocking_example.rb:11</a> +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=49">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:49</a> +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=45">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:45</a> :in `chdir' +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=45">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:45</a> </pre></div> + <pre class="ruby"><code><span class="linenum">9</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">should fail when expected message not received</span><span class="punct">"</span> <span class="keyword">do</span> +<span class="linenum">10</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">poke me</span><span class="punct">")</span> +<span class="offending"><span class="linenum">11</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:poke</span><span class="punct">)</span></span> +<span class="linenum">12</span> <span class="keyword">end</span> +<span class="linenum">13</span> </code></pre> </div> </dd> <script type="text/javascript">moveProgressBar('17.6');</script> <dd class="spec failed"> <span class="failed_spec_name">should fail when messages are received out of order</span> <div class="failure" id="failure_2"> - <div class="message"><pre>Mock 'one two three' received :three out of order</pre></div> - <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/mocking_example.rb&line=22">./failing_examples/mocking_example.rb:22</a> -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a> -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir' -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div> - <pre class="ruby"><code><span class="linenum">20</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:three</span><span class="punct">).</span><span class="ident">ordered</span> -<span class="linenum">21</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">one</span> -<span class="offending"><span class="linenum">22</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">three</span></span> -<span class="linenum">23</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">two</span> -<span class="linenum">24</span> <span class="keyword">end</span></code></pre> + <div class="message"><pre>Mock "one two three" received :three out of order</pre></div> + <div class="backtrace"><pre><a href="txmt://open?url=file://./examples/failing/mocking_example.rb&line=20">./examples/failing/mocking_example.rb:20</a> +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=49">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:49</a> +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=45">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:45</a> :in `chdir' +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=45">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:45</a> </pre></div> + <pre class="ruby"><code><span class="linenum">18</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:three</span><span class="punct">).</span><span class="ident">ordered</span> +<span class="linenum">19</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">one</span> +<span class="offending"><span class="linenum">20</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">three</span></span> +<span class="linenum">21</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">two</span> +<span class="linenum">22</span> <span class="keyword">end</span></code></pre> </div> </dd> <script type="text/javascript">moveProgressBar('23.5');</script> <dd class="spec failed"> <span class="failed_spec_name">should get yelled at when sending unexpected messages</span> <div class="failure" id="failure_3"> - <div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (no args) 0 times, but received it once</pre></div> - <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/mocking_example.rb&line=29">./failing_examples/mocking_example.rb:29</a> -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a> -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir' -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div> - <pre class="ruby"><code><span class="linenum">27</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">don't talk to me</span><span class="punct">")</span> -<span class="linenum">28</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span> -<span class="offending"><span class="linenum">29</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span></span> -<span class="linenum">30</span> <span class="keyword">end</span></code></pre> + <div class="message"><pre>Mock "don't talk to me" expected :any_message_at_all with (no args) 0 times, but received it once</pre></div> + <div class="backtrace"><pre><a href="txmt://open?url=file://./examples/failing/mocking_example.rb&line=27">./examples/failing/mocking_example.rb:27</a> +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=49">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:49</a> +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=45">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:45</a> :in `chdir' +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=45">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:45</a> </pre></div> + <pre class="ruby"><code><span class="linenum">25</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">don't talk to me</span><span class="punct">")</span> +<span class="linenum">26</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span> +<span class="offending"><span class="linenum">27</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span></span> +<span class="linenum">28</span> <span class="keyword">end</span></code></pre> </div> </dd> <script type="text/javascript">moveProgressBar('29.4');</script> @@ -235,15 +238,15 @@ a { <span class="failed_spec_name">has a bug we need to fix</span> <div class="failure" id="failure_4"> <div class="message"><pre>Expected pending 'here is the bug' to fail. No Error was raised.</pre></div> - <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/mocking_example.rb&line=33">./failing_examples/mocking_example.rb:33</a> -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a> -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir' -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div> - <pre class="ruby"><code><span class="linenum">31</span> -<span class="linenum">32</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">has a bug we need to fix</span><span class="punct">"</span> <span class="keyword">do</span> -<span class="offending"><span class="linenum">33</span> <span class="ident">pending</span> <span class="punct">"</span><span class="string">here is the bug</span><span class="punct">"</span> <span class="keyword">do</span></span> -<span class="linenum">34</span> <span class="comment"># Actually, no. It's fixed. This will fail because it passes :-)</span> -<span class="linenum">35</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">Bug</span><span class="punct">")</span></code></pre> + <div class="backtrace"><pre><a href="txmt://open?url=file://./examples/failing/mocking_example.rb&line=31">./examples/failing/mocking_example.rb:31</a> +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=49">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:49</a> +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=45">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:45</a> :in `chdir' +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=45">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:45</a> </pre></div> + <pre class="ruby"><code><span class="linenum">29</span> +<span class="linenum">30</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">has a bug we need to fix</span><span class="punct">"</span> <span class="keyword">do</span> +<span class="offending"><span class="linenum">31</span> <span class="ident">pending</span> <span class="punct">"</span><span class="string">here is the bug</span><span class="punct">"</span> <span class="keyword">do</span></span> +<span class="linenum">32</span> <span class="comment"># Actually, no. It's fixed. This will fail because it passes :-)</span> +<span class="linenum">33</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">Bug</span><span class="punct">")</span></code></pre> </div> </dd> </dl> @@ -258,17 +261,18 @@ a { <div class="failure" id="failure_5"> <div class="message"><pre>expected: "RSpec is a\nbehaviour driven development\nframework for Ruby\n", got: "RSpec is a\nbehavior driven development\nframework for Ruby\n" (using ==) -Diff: + + Diff: @@ -1,4 +1,4 @@ RSpec is a -behaviour driven development +behavior driven development framework for Ruby </pre></div> - <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/diffing_spec.rb&line=13">./failing_examples/diffing_spec.rb:13</a> -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a> -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir' -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div> + <div class="backtrace"><pre><a href="txmt://open?url=file://./examples/failing/diffing_spec.rb&line=13">./examples/failing/diffing_spec.rb:13</a> +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=49">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:49</a> +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=45">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:45</a> :in `chdir' +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=45">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:45</a> </pre></div> <pre class="ruby"><code><span class="linenum">11</span><span class="ident">framework</span> <span class="keyword">for</span> <span class="constant">Ruby</span> <span class="linenum">12</span><span class="constant">EOF</span> <span class="offending"><span class="linenum">13</span> <span class="ident">usa</span><span class="punct">.</span><span class="ident">should</span> <span class="punct">==</span> <span class="ident">uk</span></span> @@ -279,27 +283,24 @@ Diff: <dd class="spec failed"> <span class="failed_spec_name">should print diff of different objects' pretty representation</span> <div class="failure" id="failure_6"> - <div class="message"><pre>expected <Animal + <div class="message"><pre> +expected <Animal name=bob, species=tortoise > -, got <Animal + + got <Animal name=bob, species=giraffe > - (using .eql?) -Diff: -@@ -1,5 +1,5 @@ - <Animal - name=bob, --species=tortoise -+species=giraffe - > + + +(compared using eql?) </pre></div> - <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/diffing_spec.rb&line=34">./failing_examples/diffing_spec.rb:34</a> -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a> -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir' -<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div> + <div class="backtrace"><pre><a href="txmt://open?url=file://./examples/failing/diffing_spec.rb&line=34">./examples/failing/diffing_spec.rb:34</a> +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=49">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:49</a> +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=45">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:45</a> :in `chdir' +<a href="txmt://open?url=file://./spec/spec/runner/formatter/text_mate_formatter_spec.rb&line=45">./spec/spec/runner/formatter/text_mate_formatter_spec.rb:45</a> </pre></div> <pre class="ruby"><code><span class="linenum">32</span> <span class="ident">expected</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">"</span><span class="string">bob</span><span class="punct">",</span> <span class="punct">"</span><span class="string">giraffe</span><span class="punct">"</span> <span class="linenum">33</span> <span class="ident">actual</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">"</span><span class="string">bob</span><span class="punct">",</span> <span class="punct">"</span><span class="string">tortoise</span><span class="punct">"</span> <span class="offending"><span class="linenum">34</span> <span class="ident">expected</span><span class="punct">.</span><span class="ident">should</span> <span class="ident">eql</span><span class="punct">(</span><span class="ident">actual</span><span class="punct">)</span></span> diff --git a/vendor/plugins/rspec/spec/spec/runner/heckle_runner_spec.rb b/vendor/plugins/rspec/spec/spec/runner/heckle_runner_spec.rb index 539d908c2..287ff856a 100644 --- a/vendor/plugins/rspec/spec/spec/runner/heckle_runner_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/heckle_runner_spec.rb @@ -1,5 +1,5 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' -unless [/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM} +require 'spec_helper' +unless [/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM} || Spec::Ruby.version.to_f == 1.9 require 'spec/runner/heckle_runner' module Foo @@ -21,18 +21,18 @@ unless [/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM} end it "should heckle all methods in all classes in a module" do - @heckle_class.should_receive(:new).with("Foo::Bar", "one", rspec_options).and_return(@heckle) - @heckle_class.should_receive(:new).with("Foo::Bar", "two", rspec_options).and_return(@heckle) - @heckle_class.should_receive(:new).with("Foo::Zap", "three", rspec_options).and_return(@heckle) - @heckle_class.should_receive(:new).with("Foo::Zap", "four", rspec_options).and_return(@heckle) + @heckle_class.should_receive(:new).with("Foo::Bar", "one", Spec::Runner.options).and_return(@heckle) + @heckle_class.should_receive(:new).with("Foo::Bar", "two", Spec::Runner.options).and_return(@heckle) + @heckle_class.should_receive(:new).with("Foo::Zap", "three", Spec::Runner.options).and_return(@heckle) + @heckle_class.should_receive(:new).with("Foo::Zap", "four", Spec::Runner.options).and_return(@heckle) heckle_runner = Spec::Runner::HeckleRunner.new("Foo", @heckle_class) heckle_runner.heckle_with end it "should heckle all methods in a class" do - @heckle_class.should_receive(:new).with("Foo::Bar", "one", rspec_options).and_return(@heckle) - @heckle_class.should_receive(:new).with("Foo::Bar", "two", rspec_options).and_return(@heckle) + @heckle_class.should_receive(:new).with("Foo::Bar", "one", Spec::Runner.options).and_return(@heckle) + @heckle_class.should_receive(:new).with("Foo::Bar", "two", Spec::Runner.options).and_return(@heckle) heckle_runner = Spec::Runner::HeckleRunner.new("Foo::Bar", @heckle_class) heckle_runner.heckle_with @@ -46,14 +46,14 @@ unless [/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM} end it "should heckle specific method in a class (with #)" do - @heckle_class.should_receive(:new).with("Foo::Bar", "two", rspec_options).and_return(@heckle) + @heckle_class.should_receive(:new).with("Foo::Bar", "two", Spec::Runner.options).and_return(@heckle) heckle_runner = Spec::Runner::HeckleRunner.new("Foo::Bar#two", @heckle_class) heckle_runner.heckle_with end it "should heckle specific method in a class (with .)" do - @heckle_class.should_receive(:new).with("Foo::Bar", "two", rspec_options).and_return(@heckle) + @heckle_class.should_receive(:new).with("Foo::Bar", "two", Spec::Runner.options).and_return(@heckle) heckle_runner = Spec::Runner::HeckleRunner.new("Foo::Bar.two", @heckle_class) heckle_runner.heckle_with diff --git a/vendor/plugins/rspec/spec/spec/runner/heckler_spec.rb b/vendor/plugins/rspec/spec/spec/runner/heckler_spec.rb index 7cf6606ec..00869df6e 100644 --- a/vendor/plugins/rspec/spec/spec/runner/heckler_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/heckler_spec.rb @@ -1,13 +1,20 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' -unless [/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM} - require 'spec/runner/heckle_runner' +if Spec::Ruby.version.to_f < 1.9 + require 'spec_helper' + unless [/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM} + require 'spec/runner/heckle_runner' - describe "Heckler" do - it "should run examples on tests_pass?" do - options = Spec::Runner::Options.new(StringIO.new, StringIO.new) - options.should_receive(:run_examples).with().and_return(&options.method(:run_examples)) - heckler = Spec::Runner::Heckler.new('Array', 'push', options) - heckler.tests_pass? + describe "Heckler" do + it "should run examples on tests_pass?" do + sub = Class.new(Spec::Runner::Heckler) do + def initialize(klass_name, method_name, rspec_options) + @rspec_options = rspec_options + end + end + opts = mock('options') + opts.should_receive(:run_examples).and_return(true) + heckler = sub.new('klass','method',opts) + heckler.tests_pass? + end end end end diff --git a/vendor/plugins/rspec/spec/spec/runner/noisy_backtrace_tweaker_spec.rb b/vendor/plugins/rspec/spec/spec/runner/noisy_backtrace_tweaker_spec.rb index e097f2ec0..13b79432c 100644 --- a/vendor/plugins/rspec/spec/spec/runner/noisy_backtrace_tweaker_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/noisy_backtrace_tweaker_spec.rb @@ -1,14 +1,26 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Runner - describe "NoisyBacktraceTweaker" do + describe NoisyBacktraceTweaker do before(:each) do @error = RuntimeError.new @tweaker = NoisyBacktraceTweaker.new end - - it "should leave anything in lib spec dir" do + + it "gracefully handles nil backtrace" do + lambda do + @tweaker.tweak_backtrace(@error) + end.should_not raise_error + end + + it "cleans up double slashes" do + @error.set_backtrace(["/a//b/c//d.rb"]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should include("/a/b/c/d.rb") + end + + it "preserves lines in lib/spec" do ["expectations", "mocks", "runner", "stubs"].each do |child| @error.set_backtrace(["/lib/spec/#{child}/anything.rb"]) @tweaker.tweak_backtrace(@error) @@ -16,30 +28,24 @@ module Spec end end - it "should leave anything in spec dir" do + it "preserves lines in spec/" do @error.set_backtrace(["/lib/spec/expectations/anything.rb"]) @tweaker.tweak_backtrace(@error) @error.backtrace.should_not be_empty end - it "should leave bin spec" do + it "preserves lines in bin/spec" do @error.set_backtrace(["bin/spec:"]) @tweaker.tweak_backtrace(@error) @error.backtrace.should_not be_empty end - it "should not barf on nil backtrace" do - lambda do - @tweaker.tweak_backtrace(@error) - end.should_not raise_error - end - - it "should clean up double slashes" do - @error.set_backtrace(["/a//b/c//d.rb"]) + it "ignores custom patterns" do + @tweaker.ignore_patterns(/custom_pattern/) + @error.set_backtrace(["custom_pattern"]) @tweaker.tweak_backtrace(@error) - @error.backtrace.should include("/a/b/c/d.rb") + @error.backtrace.should_not be_empty end - end end end diff --git a/vendor/plugins/rspec/spec/spec/runner/option_parser_spec.rb b/vendor/plugins/rspec/spec/spec/runner/option_parser_spec.rb index 69212ff1b..a516bc686 100644 --- a/vendor/plugins/rspec/spec/spec/runner/option_parser_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/option_parser_spec.rb @@ -1,7 +1,9 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' -require 'fileutils' +require 'spec_helper' +require 'spec/runner/resources/custom_example_group_runner' +require 'fakefs/safe' +require 'fakefs/spec_helpers' -describe "OptionParser" do +describe "OptionParser" do before(:each) do @out = StringIO.new @err = StringIO.new @@ -13,11 +15,55 @@ describe "OptionParser" do @parser.options end + # FIXME - this entire file should run w/ fakefs + describe "with fakefs" do + extend FakeFS::SpecHelpers + use_fakefs + + it "should not use colour by default" do + options = parse([]) + options.colour.should == false + end + + it "should use progress bar formatter by default" do + options = parse([]) + options.formatters[0].class.should equal(Spec::Runner::Formatter::ProgressBarFormatter) + end + end + + it "should leave the submitted argv alone" do + args = ["--pattern", "foo"] + @parser.order!(args) + args.should == ["--pattern", "foo"] + end + it "should accept files to include" do options = parse(["--pattern", "foo"]) options.filename_pattern.should == "foo" end + it "should accept debugger option" do + options = parse(["--debugger"]) + options.debug.should be_true + end + + it "should accept -u form of debugger option" do + options = parse(["-u"]) + options.debug.should be_true + end + + it "should turn off the debugger option if drb is specified later" do + @parser.stub!(:parse_drb).with(no_args).and_return(true) + options = parse(["-u", "--drb"]) + options.debug.should be_false + end + + it "should turn off the debugger option if drb is specified first" do + @parser.stub!(:parse_drb).with(no_args).and_return(true) + options = parse(["--drb", "-u"]) + options.debug.should be_false + end + it "should accept dry run option" do options = parse(["--dry-run"]) options.dry_run.should be_true @@ -46,23 +92,24 @@ describe "OptionParser" do options.verbose.should be_nil end - it "should not use colour by default" do + it "should print help to stdout if no args and spec_comand?" do + Spec::Runner::OptionParser.stub!(:spec_command?).and_return(true) options = parse([]) - options.colour.should == false + @out.rewind + @out.read.should match(/Usage: spec \(FILE\(:LINE\)\?\|DIRECTORY\|GLOB\)\+ \[options\]/m) end - - it "should print help to stdout if no args" do - pending 'A regression since 1.0.8' do - options = parse([]) - @out.rewind - @out.read.should match(/Usage: spec \(FILE\|DIRECTORY\|GLOB\)\+ \[options\]/m) - end + + it "should not print help to stdout if no args and NOT spec_command?" do + Spec::Runner::OptionParser.stub!(:spec_command?).and_return(false) + options = parse([]) + @out.rewind + @out.read.should == "" end it "should print help to stdout" do options = parse(["--help"]) @out.rewind - @out.read.should match(/Usage: spec \(FILE\|DIRECTORY\|GLOB\)\+ \[options\]/m) + @out.read.should match(/Usage: spec \(FILE\(:LINE\)\?\|DIRECTORY\|GLOB\)\+ \[options\]/m) end it "should print instructions about how to require missing formatter" do @@ -76,7 +123,7 @@ describe "OptionParser" do it "should print version to stdout" do options = parse(["--version"]) @out.rewind - @out.read.should match(/RSpec-\d+\.\d+\.\d+.*\(build \d+\) - BDD for Ruby\nhttp:\/\/rspec.rubyforge.org\/\n/n) + @out.read.should match(/rspec \d+\.\d+\.\d+/n) end it "should require file when require specified" do @@ -132,26 +179,26 @@ describe "OptionParser" do options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter) end - it "should use html story formatter when format is h" do - options = parse(["--format", "h"]) - options.story_formatters[0].class.should equal(Spec::Runner::Formatter::Story::HtmlFormatter) - end - it "should use html formatter when format is html" do options = parse(["--format", "html"]) options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter) end - it "should use html story formatter when format is html" do - options = parse(["--format", "html"]) - options.story_formatters[0].class.should equal(Spec::Runner::Formatter::Story::HtmlFormatter) + it "should use silent formatter when format is s" do + options = parse(["--format", "l"]) + options.formatters[0].class.should equal(Spec::Runner::Formatter::SilentFormatter) + end + + it "should use silent formatter when format is silent" do + options = parse(["--format", "silent"]) + options.formatters[0].class.should equal(Spec::Runner::Formatter::SilentFormatter) end it "should use html formatter with explicit output when format is html:test.html" do FileUtils.rm 'test.html' if File.exist?('test.html') options = parse(["--format", "html:test.html"]) options.formatters # creates the file - File.should be_exist('test.html') + File.should exist('test.html') options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter) options.formatters[0].close FileUtils.rm 'test.html' @@ -172,11 +219,6 @@ describe "OptionParser" do options.backtrace_tweaker.should be_instance_of(Spec::Runner::QuietBacktraceTweaker) end - it "should use progress bar formatter by default" do - options = parse([]) - options.formatters[0].class.should equal(Spec::Runner::Formatter::ProgressBarFormatter) - end - it "should use specdoc formatter when format is s" do options = parse(["--format", "s"]) options.formatters[0].class.should equal(Spec::Runner::Formatter::SpecdocFormatter) @@ -231,63 +273,116 @@ describe "OptionParser" do describe "when attempting a focussed spec" do attr_reader :file, :dir - before do - @original_rspec_options = $rspec_options - @file = "#{File.dirname(__FILE__)}/spec_parser/spec_parser_fixture.rb" + before(:each) do + @original_rspec_options = Spec::Runner.options + @file = "#{File.dirname(__FILE__)}/line_number_query/line_number_query_fixture.rb" @dir = File.dirname(file) end - after do - $rspec_options = @original_rspec_options + after(:each) do + Spec::Runner.use @original_rspec_options end def parse(args) options = super - $rspec_options = options + Spec::Runner.use options options.filename_pattern = "*_fixture.rb" options end - - it "should support --line to identify spec" do - options = parse([file, "--line", "13"]) - options.line_number.should == 13 - options.examples.should be_empty - options.run_examples - options.examples.should eql(["d"]) - end - - it "should fail with error message if file is dir along with --line" do - options = parse([dir, "--line", "169"]) - options.line_number.should == 169 - options.run_examples - @err.string.should match(/You must specify one file, not a directory when using the --line option/n) - end - - it "should fail with error message if file does not exist along with --line" do - options = parse(["some file", "--line", "169"]) - proc do + + describe 'with the --line flag' do + it "should correctly identify the spec" do + options = parse([file, "--line", "13"]) + options.line_number.should == 13 + options.examples.should be_empty options.run_examples - end.should raise_error - end - - it "should fail with error message if more than one files are specified along with --line" do - options = parse([file, file, "--line", "169"]) - options.run_examples - @err.string.should match(/Only one file can be specified when using the --line option/n) + options.examples.should eql(["d"]) + end + + it "should fail with error message if specified file is a dir" do + options = parse([dir, "--line", "169"]) + options.line_number.should == 169 + options.run_examples + @err.string.should match(/You must specify one file, not a directory when providing a line number/n) + end + + + it "should fail with error message if file does not exist" do + options = parse(["some file", "--line", "169"]) + proc do + options.run_examples + end.should raise_error + end + + it "should fail with error message if more than one files are specified" do + options = parse([file, file, "--line", "169"]) + options.run_examples + @err.string.should match(/Only one file can be specified when providing a line number/n) + end + + it "should fail with error message if using simultaneously with --example" do + options = parse([file, "--example", "some example", "--line", "169"]) + options.run_examples + @err.string.should match(/You cannot use --example and specify a line number/n) + end end - - it "should fail with error message if --example and --line are used simultaneously" do - options = parse([file, "--example", "some example", "--line", "169"]) - options.run_examples - @err.string.should match(/You cannot use both --line and --example/n) + + describe 'with the colon syntax (filename:LINE_NUMBER)' do + + it "should strip the line number from the file name" do + options = parse(["#{file}:13"]) + options.files.should include(file) + end + + it "should correctly identify the spec" do + options = parse(["#{file}:13"]) + options.line_number.should == 13 + options.examples.should be_empty + options.run_examples + options.examples.should eql(["d"]) + end + + it "should fail with error message if specified file is a dir" do + options = parse(["#{dir}:169"]) + options.line_number.should == 169 + options.run_examples + @err.string.should match(/You must specify one file, not a directory when providing a line number/n) + end + + + it "should fail with error message if file does not exist" do + options = parse(["some file:169"]) + proc do + options.run_examples + end.should raise_error + end + + it "should fail with error message if more than one files are specified" do + options = parse([file, "#{file}:169"]) + options.run_examples + @err.string.should match(/Only one file can be specified when providing a line number/n) + end + + it "should fail with error message if using simultaneously with --example" do + options = parse(["#{file}:169", "--example", "some example"]) + options.run_examples + @err.string.should match(/You cannot use --example and specify a line number/n) + end end + end if [/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM} it "should barf when --heckle is specified (and platform is windows)" do lambda do options = parse(["--heckle", "Spec"]) - end.should raise_error(StandardError, "Heckle not supported on Windows") + end.should raise_error(StandardError, /Heckle is not supported/) + end + elsif Spec::Ruby.version.to_f == 1.9 + it "should barf when --heckle is specified (and platform is Ruby 1.9)" do + lambda do + options = parse(["--heckle", "Spec"]) + end.should raise_error(StandardError, /Heckle is not supported/) end else it "should heckle when --heckle is specified (and platform is not windows)" do @@ -308,11 +403,36 @@ describe "OptionParser" do end it "should run parse drb after parsing options" do - @parser.stub!(:parse_drb) - @parser.should_receive(:parse_drb).with(["--drb"]).and_return(true) + @parser.should_receive(:parse_drb).with(no_args).and_return(true) options = parse(["--options", File.dirname(__FILE__) + "/spec_drb.opts"]) end + it "should send all the arguments other than --drb back to the parser after parsing options" do + Spec::Runner::DrbCommandLine.should_receive(:run).and_return do |options| + options.argv.should == ["example_file.rb", "--colour"] + end + options = parse(["example_file.rb", "--options", File.dirname(__FILE__) + "/spec_drb.opts"]) + end + + it "runs specs locally if no drb is running when --drb is specified" do + Spec::Runner::DrbCommandLine.should_receive(:run).and_return(false) + options = parse(["example_file.rb", "--options", File.dirname(__FILE__) + "/spec_drb.opts"]) + options.__send__(:examples_should_be_run?).should be_true + end + + it "says its running specs locally if no drb is running when --drb is specified" do + Spec::Runner::DrbCommandLine.should_receive(:run).and_return(false) + options = parse(["example_file.rb", "--options", File.dirname(__FILE__) + "/spec_drb.opts"]) + options.error_stream.rewind + options.error_stream.string.should =~ /Running specs locally/ + end + + it "does not run specs locally if drb is running when --drb is specified" do + Spec::Runner::DrbCommandLine.should_receive(:run).and_return(true) + options = parse(["example_file.rb", "--options", File.dirname(__FILE__) + "/spec_drb.opts"]) + options.__send__(:examples_should_be_run?).should be_false + end + it "should read spaced and multi-line options from file when --options is specified" do options = parse(["--options", File.dirname(__FILE__) + "/spec_spaced.opts"]) options.diff_format.should_not be_nil @@ -391,4 +511,35 @@ describe "OptionParser" do options = parse(["--runner", "Custom::ExampleGroupRunner:something"]) options.run_examples end + + it "sets options.autospec to true with --autospec" do + options = parse(["--autospec"]) + options.autospec.should be(true) + end + + describe "implicitly loading spec/spec.opts" do + extend FakeFS::SpecHelpers + use_fakefs + it "uses spec/spec.opts if present" do + File.open('spec/spec.opts', 'w') { |f| f.write "--colour" } + options = parse(['ignore.rb']) + options.colour.should be(true) + end + + it "does not try to load spec/spec.opts if not present" do + FileUtils.rm 'spec/spec.opts' + options = parse(['ignore.rb']) + options.colour.should be(false) + end + + it "uses specified opts if supplied" do + options = nil + File.open("spec/spec.opts",'w') { |f| f.write "" } + File.open("spec/alternate.opts",'w') { |f| f.write "--colour" } + options = parse(['-O','spec/alternate.opts']) + options.colour.should be(true) + end + end + + end diff --git a/vendor/plugins/rspec/spec/spec/runner/options_spec.rb b/vendor/plugins/rspec/spec/spec/runner/options_spec.rb index a64356b8c..bb1e0e8c3 100644 --- a/vendor/plugins/rspec/spec/spec/runner/options_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/options_spec.rb @@ -1,4 +1,5 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' +require 'spec/runner/resources/custom_example_group_runner' module Spec module Runner @@ -7,32 +8,45 @@ module Spec @err = StringIO.new('') @out = StringIO.new('') @options = Options.new(@err, @out) + + before_suite_parts = [] + after_suite_parts = [] + @options.stub!(:before_suite_parts).and_return(before_suite_parts) + @options.stub!(:after_suite_parts).and_return(after_suite_parts) end after(:each) do Spec::Expectations.differ = nil end + + describe "#require_ruby_debug" do + it "should require ruby-debug" do + @options.stub!(:require) + @options.should_receive(:require).with("ruby-debug") + @options.require_ruby_debug + end + end describe "#examples" do it "should default to empty array" do @options.examples.should == [] end end - + describe "#include_pattern" do it "should default to '**/*_spec.rb'" do @options.filename_pattern.should == "**/*_spec.rb" end end - + describe "#files_to_load" do - + it "should load files not following pattern if named explicitly" do file = File.expand_path(File.dirname(__FILE__) + "/resources/a_bar.rb") @options.files << file @options.files_to_load.should include(file) end - + describe "with default --pattern" do it "should load files named _spec.rb" do dir = File.expand_path(File.dirname(__FILE__) + "/resources/") @@ -40,33 +54,33 @@ module Spec @options.files_to_load.should == ["#{dir}/a_spec.rb"] end end - + describe "with explicit pattern (single)" do before(:each) do @options.filename_pattern = "**/*_foo.rb" end - + it "should load files following pattern" do file = File.expand_path(File.dirname(__FILE__) + "/resources/a_foo.rb") @options.files << file @options.files_to_load.should include(file) end - + it "should load files in directories following pattern" do dir = File.expand_path(File.dirname(__FILE__) + "/resources") @options.files << dir @options.files_to_load.should include("#{dir}/a_foo.rb") end - + it "should not load files in directories not following pattern" do dir = File.expand_path(File.dirname(__FILE__) + "/resources") @options.files << dir @options.files_to_load.should_not include("#{dir}/a_bar.rb") end end - + describe "with explicit pattern (comma,separated,values)" do - + before(:each) do @options.filename_pattern = "**/*_foo.rb,**/*_bar.rb" end @@ -77,22 +91,28 @@ module Spec @options.files_to_load.should include("#{dir}/a_foo.rb") @options.files_to_load.should include("#{dir}/a_bar.rb") end - + it "should support comma separated values with spaces" do dir = File.expand_path(File.dirname(__FILE__) + "/resources") @options.files << dir @options.files_to_load.should include("#{dir}/a_foo.rb") @options.files_to_load.should include("#{dir}/a_bar.rb") end - + end - + end describe "#backtrace_tweaker" do it "should default to QuietBacktraceTweaker" do @options.backtrace_tweaker.class.should == QuietBacktraceTweaker end + + it "adds custom ignored backtrace patterns" do + Spec::Runner.configuration.stub!(:ignored_backtrace_patterns).and_return([/custom_pattern/]) + @options.run_examples + @options.backtrace_tweaker.ignored_patterns.should include(/custom_pattern/) + end end describe "#dry_run" do @@ -101,6 +121,12 @@ module Spec end end + describe "#debug" do + it "should default to false" do + @options.debug.should == false + end + end + describe "#context_lines" do it "should default to 3" do @options.context_lines.should == 3 @@ -209,10 +235,26 @@ module Spec end end + describe "debug option specified" do + it "should cause ruby_debug to be required and do nothing" do + @options.debug = true + @options.should_receive(:require_ruby_debug) + @options.run_examples.should be_true + end + end + + describe "debug option not specified" do + it "should not cause ruby_debug to be required" do + @options.debug = false + @options.should_not_receive(:require_ruby_debug) + @options.run_examples.should be_true + end + end + describe "#load_class" do it "should raise error when not class name" do lambda do - @options.send(:load_class, 'foo', 'fruit', '--food') + @options.__send__(:load_class, 'foo', 'fruit', '--food') end.should raise_error('"foo" is not a valid class name') end end @@ -224,8 +266,23 @@ module Spec end end + describe "#number_of_examples" do + context "when --example is parsed" do + it "provides the number of examples parsed instead of the total number of examples collected" do + @example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do + it "uses this example_group 1" do; end + it "uses this example_group 2" do; end + it "uses this example_group 3" do; end + end + @options.add_example_group @example_group + @options.parse_example("an example") + @options.number_of_examples.should == 1 + end + end + end + describe "#add_example_group affecting passed in example_group" do - it "runs all examples when options.examples is nil" do + it "runs all examples when options.examples is empty" do example_1_has_run = false example_2_has_run = false @example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do @@ -237,7 +294,7 @@ module Spec end end - @options.examples = nil + @options.examples.clear @options.add_example_group @example_group @options.run_examples @@ -257,8 +314,6 @@ module Spec end end - @options.examples = [] - @options.add_example_group @example_group @options.run_examples example_1_has_run.should be_true @@ -293,6 +348,40 @@ module Spec end describe "#run_examples" do + describe "with global predicate matchers" do + it "defines global predicate matcher methods on ExampleMethods" do + Spec::Runner.configuration.stub!(:predicate_matchers).and_return({:this => :that?}) + group = Class.new(::Spec::Example::ExampleGroupDouble).describe("Some Examples") + example = group.new(::Spec::Example::ExampleProxy.new) + + @options.run_examples + example.this + end + + after(:each) do + Spec::Example::ExampleMethods.class_eval "undef :this" + end + end + + describe "with a mock framework defined as a Symbol" do + it "includes Spec::Adapters::MockFramework" do + Spec::Runner.configuration.stub!(:mock_framework).and_return('spec/adapters/mock_frameworks/rspec') + + Spec::Example::ExampleMethods.should_receive(:include).with(Spec::Adapters::MockFramework) + + @options.run_examples + end + end + + describe "with a mock framework defined as a Module" do + it "includes the module in ExampleMethods" do + mod = Module.new + Spec::Runner.configuration.stub!(:mock_framework).and_return(mod) + Spec::Example::ExampleMethods.should_receive(:include).with(mod) + @options.run_examples + end + end + describe "when not given a custom runner" do it "should use the standard" do runner = ::Spec::Runner::ExampleGroupRunner.new(@options) @@ -355,14 +444,14 @@ module Spec @options.after_suite_parts << lambda do |success| success_result = success end - + @options.run_examples success_result.should be_true end end describe "and the suite fails" do - before do + before(:each) do @example_group.should_receive(:run).and_return(false) end @@ -382,12 +471,12 @@ module Spec @heckle_runner_mock = mock("HeckleRunner") @options.heckle_runner = @heckle_runner_mock end - + it "should heckle" do @heckle_runner_mock.should_receive(:heckle_with) @options.run_examples end - + it "shouldn't heckle recursively" do heckled = false @heckle_runner_mock.should_receive(:heckle_with) { @@ -445,6 +534,14 @@ module Spec end end end + + describe "#add_dir_from_project_root_to_load_path" do + it "handles nil gracefully" do + load_path = double().as_null_object + @options.stub(:project_root).and_return(nil) + @options.add_dir_from_project_root_to_load_path(nil,load_path) + end + end end end end diff --git a/vendor/plugins/rspec/spec/spec/runner/output_one_time_fixture.rb b/vendor/plugins/rspec/spec/spec/runner/output_one_time_fixture.rb index 444730dc3..8a3a9fc72 100644 --- a/vendor/plugins/rspec/spec/spec/runner/output_one_time_fixture.rb +++ b/vendor/plugins/rspec/spec/spec/runner/output_one_time_fixture.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' describe "Running an Example" do it "should not output twice" do diff --git a/vendor/plugins/rspec/spec/spec/runner/output_one_time_fixture_runner.rb b/vendor/plugins/rspec/spec/spec/runner/output_one_time_fixture_runner.rb index a0e61316e..b6b3761e4 100644 --- a/vendor/plugins/rspec/spec/spec/runner/output_one_time_fixture_runner.rb +++ b/vendor/plugins/rspec/spec/spec/runner/output_one_time_fixture_runner.rb @@ -1,8 +1,7 @@ -dir = File.dirname(__FILE__) -require "#{dir}/../../spec_helper" +require "spec_helper" -triggering_double_output = rspec_options +triggering_double_output = Spec::Runner.options options = Spec::Runner::OptionParser.parse( - ["#{dir}/output_one_time_fixture.rb"], $stderr, $stdout + [File.dirname(__FILE__) + "/output_one_time_fixture.rb"], $stderr, $stdout ) Spec::Runner::CommandLine.run(options) diff --git a/vendor/plugins/rspec/spec/spec/runner/output_one_time_spec.rb b/vendor/plugins/rspec/spec/spec/runner/output_one_time_spec.rb index 8f67a380a..c91bb0ffb 100644 --- a/vendor/plugins/rspec/spec/spec/runner/output_one_time_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/output_one_time_spec.rb @@ -1,15 +1,14 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' +require 'ruby_forker' module Spec module Runner describe CommandLine do + include RubyForker it "should not output twice" do - dir = File.dirname(__FILE__) - Dir.chdir("#{dir}/../../..") do - output =`ruby #{dir}/output_one_time_fixture_runner.rb` - output.should include("1 example, 0 failures") - output.should_not include("0 examples, 0 failures") - end + output = ruby "-Ilib bin/spec spec/spec/runner/output_one_time_fixture_runner.rb" + output.should include("1 example, 0 failures") + output.should_not include("0 examples, 0 failures") end end end diff --git a/vendor/plugins/rspec/spec/spec/runner/quiet_backtrace_tweaker_spec.rb b/vendor/plugins/rspec/spec/spec/runner/quiet_backtrace_tweaker_spec.rb index e47b6c735..30eaa7363 100644 --- a/vendor/plugins/rspec/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/quiet_backtrace_tweaker_spec.rb @@ -1,55 +1,104 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Runner - describe "QuietBacktraceTweaker" do + describe QuietBacktraceTweaker do before(:each) do @error = RuntimeError.new @tweaker = QuietBacktraceTweaker.new end - it "should not barf on nil backtrace" do + it "gracefully handles nil backtrace" do lambda do @tweaker.tweak_backtrace(@error) end.should_not raise_error end - it "should remove anything from textmate ruby bundle" do + it "gracefully handle backtraces with newlines" do + @error.set_backtrace(["we like\nbin/spec:\nnewlines"]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should include("we like\nnewlines") + end + + it "cleans up double slashes" do + @error.set_backtrace(["/a//b/c//d.rb"]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should include("/a/b/c/d.rb") + end + + it "preserves lines from textmate ruby bundle" do @error.set_backtrace(["/Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/tmruby.rb:147"]) @tweaker.tweak_backtrace(@error) @error.backtrace.should be_empty end - it "should remove anything in lib spec dir" do + it "removes lines in lib/spec" do ["expectations", "mocks", "runner"].each do |child| element="/lib/spec/#{child}/anything.rb" @error.set_backtrace([element]) @tweaker.tweak_backtrace(@error) - unless (@error.backtrace.empty?) - raise("Should have tweaked away '#{element}'") - end + @error.backtrace.should be_empty, "Should have removed line with '#{element}'" end end - it "should remove mock_frameworks/rspec" do + it "removes lines in bin/spec" do + @error.set_backtrace(["bin/spec:"]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should be_empty + end + + it "removes lines in mock_frameworks/rspec" do element = "mock_frameworks/rspec" @error.set_backtrace([element]) @tweaker.tweak_backtrace(@error) - unless (@error.backtrace.empty?) - raise("Should have tweaked away '#{element}'") - end + @error.backtrace.should be_empty, "Should have removed line with '#{element}'" end - it "should remove bin spec" do - @error.set_backtrace(["bin/spec:"]) + it "removes custom patterns" do + element = "/vendor/lib/custom_pattern/" + @tweaker.ignore_patterns /custom_pattern/ + @error.set_backtrace([element]) @tweaker.tweak_backtrace(@error) - @error.backtrace.should be_empty + @error.backtrace.should be_empty, "Should have removed line with '#{element}'" end - - it "should clean up double slashes" do - @error.set_backtrace(["/a//b/c//d.rb"]) + + it "removes custom patterns added as a string" do + element = "/vendor/lib/custom_pattern/" + @tweaker.ignore_patterns "custom_pattern" + @error.set_backtrace([element]) @tweaker.tweak_backtrace(@error) - @error.backtrace.should include("/a/b/c/d.rb") + @error.backtrace.should be_empty, "Should have removed line with '#{element}'" + end + + it "removes lines in mock_frameworks/rspec" do + element = "mock_frameworks/rspec" + @error.set_backtrace([element]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should be_empty, "Should have removed line with '#{element}'" + end + + it "removes lines in rspec gem" do + ["/rspec-1.2.3/lib/spec.rb","/rspec-1.2.3/lib/spec/anything.rb","bin/spec:123"].each do |element| + @error.set_backtrace([element]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should be_empty, "Should have removed line with '#{element}'" + end + end + + it "removes lines in pre-release rspec gems" do + ["/rspec-1.2.3.a1.gem/lib/spec.rb","/rspec-1.2.3.b1.gem/lib/spec.rb","/rspec-1.2.3.rc1.gem/lib/spec.rb"].each do |element| + @error.set_backtrace([element]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should be_empty, "Should have removed line with '#{element}'" + end + end + + it "removes lines in spork gem" do + ["/spork-1.2.3/lib/spec.rb","/spork-1.2.3/lib/spec/anything.rb","bin/spork:123"].each do |element| + @error.set_backtrace([element]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should be_empty, "Should have removed line with '#{element}'" + end end end end diff --git a/vendor/plugins/rspec/spec/spec/runner/reporter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/reporter_spec.rb index b02a4cf6f..556387dc7 100644 --- a/vendor/plugins/rspec/spec/spec/runner/reporter_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner/reporter_spec.rb @@ -1,9 +1,9 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' +require 'spec_helper' module Spec module Runner describe Reporter do - attr_reader :formatter_output, :options, :backtrace_tweaker, :formatter, :reporter, :example_group + attr_reader :formatter_output, :options, :backtrace_tweaker, :formatter, :reporter, :example_group, :example_group_proxy, :example_proxy before(:each) do @formatter_output = StringIO.new @options = Options.new(StringIO.new, StringIO.new) @@ -13,15 +13,17 @@ module Spec options.formatters << formatter @reporter = Reporter.new(options) @example_group = create_example_group("example_group") - reporter.add_example_group example_group + @example_group_proxy = Spec::Example::ExampleGroupProxy.new(@example_group) + @example_proxy = Spec::Example::ExampleProxy.new + example_group.notify(reporter) end def failure - Mocks::DuckTypeArgConstraint.new(:header, :exception) + Mocks::ArgumentMatchers::DuckTypeMatcher.new(:header, :exception) end - def create_example_group(description_text) - example_group = Spec::Example::ExampleGroup.describe(description_text) do + def create_example_group(text) + example_group = Spec::Example::ExampleGroup.describe(text) do it "should do something" do end end @@ -31,55 +33,59 @@ module Spec it "should assign itself as the reporter to options" do options.reporter.should equal(@reporter) end - + it "should tell formatter when example_group is added" do - formatter.should_receive(:add_example_group).with(example_group) - reporter.add_example_group(example_group) + formatter.should_receive(:example_group_started).with(example_group_proxy) + example_group.notify(reporter) end - + it "should handle multiple example_groups with same name" do - formatter.should_receive(:add_example_group).exactly(3).times + formatter.should_receive(:example_group_started).exactly(3).times formatter.should_receive(:example_started).exactly(3).times formatter.should_receive(:example_passed).exactly(3).times formatter.should_receive(:start_dump) formatter.should_receive(:dump_pending) formatter.should_receive(:close).with(no_args) formatter.should_receive(:dump_summary).with(anything(), 3, 0, 0) - reporter.add_example_group(create_example_group("example_group")) - reporter.example_started("spec 1") - reporter.example_finished("spec 1") - reporter.add_example_group(create_example_group("example_group")) - reporter.example_started("spec 2") - reporter.example_finished("spec 2") - reporter.add_example_group(create_example_group("example_group")) - reporter.example_started("spec 3") - reporter.example_finished("spec 3") + create_example_group("example_group").notify(reporter) + reporter.example_started(description_of("spec 1")) + reporter.example_finished(description_of("spec 1")) + create_example_group("example_group").notify(reporter) + reporter.example_started(description_of("spec 2")) + reporter.example_finished(description_of("spec 2")) + create_example_group("example_group").notify(reporter) + reporter.example_started(description_of("spec 3")) + reporter.example_finished(description_of("spec 3")) reporter.dump end + + def description_of(example) + ::Spec::Example::ExampleProxy.new(String === example ? example : example.description) + end it "should handle multiple examples with the same name" do error=RuntimeError.new - passing = ExampleGroup.new("example") - failing = ExampleGroup.new("example") - - formatter.should_receive(:add_example_group).exactly(2).times - formatter.should_receive(:example_passed).with(passing).exactly(2).times - formatter.should_receive(:example_failed).with(failing, 1, failure) - formatter.should_receive(:example_failed).with(failing, 2, failure) - formatter.should_receive(:dump_failure).exactly(2).times + passing = ::Spec::Example::ExampleGroupDouble.new(example_proxy) + failing = ::Spec::Example::ExampleGroupDouble.new(example_proxy) + + formatter.should_receive(:example_group_started).exactly(2).times + formatter.should_receive(:example_passed).with(description_of(passing)).exactly(2).times + formatter.should_receive(:example_failed).with(description_of(failing), 1, failure) + formatter.should_receive(:example_failed).with(description_of(failing), 2, failure) + formatter.should_receive(:dump_failure).exactly(2).times formatter.should_receive(:start_dump) formatter.should_receive(:dump_pending) formatter.should_receive(:close).with(no_args) formatter.should_receive(:dump_summary).with(anything(), 4, 2, 0) backtrace_tweaker.should_receive(:tweak_backtrace).twice - reporter.add_example_group(create_example_group("example_group")) - reporter.example_finished(passing) - reporter.example_finished(failing, error) + create_example_group("example_group").notify(reporter) + reporter.example_finished(description_of(passing)) + reporter.example_finished(description_of(failing), error) - reporter.add_example_group(create_example_group("example_group")) - reporter.example_finished(passing) - reporter.example_finished(failing, error) + create_example_group("example_group").notify(reporter) + reporter.example_finished(description_of(passing)) + reporter.example_finished(description_of(failing), error) reporter.dump end @@ -90,7 +96,7 @@ module Spec formatter.should_receive(:close).with(no_args) reporter.dump end - + it "should push time to formatter" do formatter.should_receive(:start).with(5) formatter.should_receive(:start_dump) @@ -103,88 +109,134 @@ module Spec reporter.end reporter.dump end - - describe Reporter, "reporting one passing example" do + + describe "reporting one passing example" do it "should tell formatter example passed" do formatter.should_receive(:example_passed) - reporter.example_finished("example") + reporter.example_finished(description_of("example")) end - + it "should not delegate to backtrace tweaker" do formatter.should_receive(:example_passed) backtrace_tweaker.should_not_receive(:tweak_backtrace) - reporter.example_finished("example") + reporter.example_finished(description_of("example")) end - + it "should account for passing example in stats" do formatter.should_receive(:example_passed) formatter.should_receive(:start_dump) formatter.should_receive(:dump_pending) formatter.should_receive(:dump_summary).with(anything(), 1, 0, 0) formatter.should_receive(:close).with(no_args) - reporter.example_finished("example") + reporter.example_finished(description_of("example")) reporter.dump end end - - describe Reporter, "reporting one failing example" do + + describe "reporting one failing example" do it "should tell formatter that example failed" do example = example_group.it("should do something") {} formatter.should_receive(:example_failed) - reporter.example_finished(example, RuntimeError.new) + reporter.example_finished(description_of(example), RuntimeError.new) end - + it "should delegate to backtrace tweaker" do formatter.should_receive(:example_failed) backtrace_tweaker.should_receive(:tweak_backtrace) - reporter.example_finished(ExampleGroup.new("example"), RuntimeError.new) + reporter.example_finished(example_proxy, RuntimeError.new) end - + it "should account for failing example in stats" do - example = ExampleGroup.new("example") - formatter.should_receive(:example_failed).with(example, 1, failure) + example = ::Spec::Example::ExampleGroupDouble.new(example_proxy) + formatter.should_receive(:example_failed).with(description_of(example), 1, failure) formatter.should_receive(:start_dump) formatter.should_receive(:dump_pending) formatter.should_receive(:dump_failure).with(1, anything()) formatter.should_receive(:dump_summary).with(anything(), 1, 1, 0) formatter.should_receive(:close).with(no_args) - reporter.example_finished(example, RuntimeError.new) + reporter.example_finished(description_of(example), RuntimeError.new) reporter.dump end - + end - - describe Reporter, "reporting one pending example (ExamplePendingError)" do + + describe "reporting one pending example (ExamplePendingError)" do + before :each do + @pending_error = Spec::Example::ExamplePendingError.new("reason") + end + it "should tell formatter example is pending" do - example = ExampleGroup.new("example") - formatter.should_receive(:example_pending).with(example, "reason") - formatter.should_receive(:add_example_group).with(example_group) - reporter.add_example_group(example_group) - reporter.example_finished(example, Spec::Example::ExamplePendingError.new("reason")) + example = ExampleGroup.new(example_proxy) + formatter.should_receive(:example_pending).with(description_of(example), "reason") + formatter.should_receive(:example_group_started).with(example_group_proxy) + example_group.notify(reporter) + reporter.example_finished(description_of(example), @pending_error) end - + it "should account for pending example in stats" do - example = ExampleGroup.new("example") - formatter.should_receive(:example_pending).with(example, "reason") + example = ExampleGroup.new(example_proxy) + formatter.should_receive(:example_pending).with(description_of(example), "reason") formatter.should_receive(:start_dump) formatter.should_receive(:dump_pending) formatter.should_receive(:dump_summary).with(anything(), 1, 0, 1) formatter.should_receive(:close).with(no_args) - formatter.should_receive(:add_example_group).with(example_group) - reporter.add_example_group(example_group) - reporter.example_finished(example, Spec::Example::ExamplePendingError.new("reason")) + formatter.should_receive(:example_group_started).with(example_group_proxy) + example_group.notify(reporter) + reporter.example_finished(description_of(example), @pending_error) reporter.dump end + + describe "to formatters which have example_pending's arity of 3 (which is now deprecated)" do + before :each do + Spec.stub!(:warn) + + @deprecated_formatter = Class.new(@formatter.class) do + attr_reader :example_passed_to_method, :message_passed_to_method + + def example_pending(example_passed_to_method, message_passed_to_method, deprecated_pending_location) + @example_passed_to_method = example_passed_to_method + @message_passed_to_method = message_passed_to_method + end + end.new(options, formatter_output) + + options.formatters << @deprecated_formatter + end + + it "should pass the correct example description to the formatter" do + proxy = Spec::Example::ExampleProxy.new("name") + example = ExampleGroup.new(proxy) + example_group.notify(reporter) + reporter.example_finished(description_of(example), @pending_error) + + @deprecated_formatter.example_passed_to_method.should == proxy + end + + it "should pass the correct pending error message to the formatter" do + example = ExampleGroup.new(example_proxy) + example_group.notify(reporter) + reporter.example_finished(description_of(example), @pending_error) + + @deprecated_formatter.message_passed_to_method.should == @pending_error.message + end + + it "should raise a deprecation warning" do + Spec.should_receive(:warn) + + example = ExampleGroup.new(example_proxy) + example_group.notify(reporter) + reporter.example_finished(description_of(example), @pending_error) + end + end end - - describe Reporter, "reporting one pending example (PendingExampleFixedError)" do + + describe "reporting one pending example (PendingExampleFixedError)" do it "should tell formatter pending example is fixed" do formatter.should_receive(:example_failed) do |name, counter, failure| failure.header.should == "'example_group should do something' FIXED" end - formatter.should_receive(:add_example_group).with(example_group) - reporter.add_example_group(example_group) - reporter.example_finished(example_group.examples.first, Spec::Example::PendingExampleFixedError.new("reason")) + formatter.should_receive(:example_group_started).with(example_group_proxy) + example_group.notify(reporter) + reporter.example_finished(description_of(example_group.examples.first), Spec::Example::PendingExampleFixedError.new("reason")) end end end diff --git a/vendor/plugins/rspec/spec/spec/runner/spec_drb.opts b/vendor/plugins/rspec/spec/spec/runner/spec_drb.opts index 091e4c222..61f260b71 100644 --- a/vendor/plugins/rspec/spec/spec/runner/spec_drb.opts +++ b/vendor/plugins/rspec/spec/spec/runner/spec_drb.opts @@ -1 +1,2 @@ +--colour --drb diff --git a/vendor/plugins/rspec/spec/spec/runner/spec_parser/spec_parser_fixture.rb b/vendor/plugins/rspec/spec/spec/runner/spec_parser/spec_parser_fixture.rb deleted file mode 100644 index 14602d934..000000000 --- a/vendor/plugins/rspec/spec/spec/runner/spec_parser/spec_parser_fixture.rb +++ /dev/null @@ -1,70 +0,0 @@ -require File.dirname(__FILE__) + '/../../../spec_helper.rb' - -describe "c" do - - it "1" do - end - - it "2" do - end - -end - -describe "d" do - - it "3" do - end - - it "4" do - end - -end - -class SpecParserSubject -end - -describe SpecParserSubject do - - it "5" do - end - -end - -describe SpecParserSubject, "described" do - - it "6" do - end - -end - -describe SpecParserSubject, "described", :something => :something_else do - - it "7" do - end - -end - -describe "described", :something => :something_else do - - it "8" do - end - -end - -describe "e" do - - it "9" do - end - - it "10" do - end - - describe "f" do - it "11" do - end - - it "12" do - end - end - -end diff --git a/vendor/plugins/rspec/spec/spec/runner/spec_parser_spec.rb b/vendor/plugins/rspec/spec/spec/runner/spec_parser_spec.rb deleted file mode 100644 index 7204ba3e6..000000000 --- a/vendor/plugins/rspec/spec/spec/runner/spec_parser_spec.rb +++ /dev/null @@ -1,85 +0,0 @@ -require File.dirname(__FILE__) + '/../../spec_helper.rb' - -describe "SpecParser" do - attr_reader :parser, :file - before(:each) do - @original_rspec_options = $rspec_options - $rspec_options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new) - @parser = Spec::Runner::SpecParser.new - @file = "#{File.dirname(__FILE__)}/spec_parser/spec_parser_fixture.rb" - load file - end - - after do - $rspec_options = @original_rspec_options - end - - it "should find spec name for 'specify' at same line" do - parser.spec_name_for(file, 5).should == "c 1" - end - - it "should find spec name for 'specify' at end of spec line" do - parser.spec_name_for(file, 6).should == "c 1" - end - - it "should find context for 'context' above all specs" do - parser.spec_name_for(file, 4).should == "c" - end - - it "should find spec name for 'it' at same line" do - parser.spec_name_for(file, 15).should == "d 3" - end - - it "should find spec name for 'it' at end of spec line" do - parser.spec_name_for(file, 16).should == "d 3" - end - - it "should find context for 'describe' above all specs" do - parser.spec_name_for(file, 14).should == "d" - end - - it "should find nearest example name between examples" do - parser.spec_name_for(file, 7).should == "c 1" - end - - it "should find nothing outside a context" do - parser.spec_name_for(file, 2).should be_nil - end - - it "should find context name for type" do - parser.spec_name_for(file, 26).should == "SpecParserSubject" - end - - it "should find context and spec name for type" do - parser.spec_name_for(file, 28).should == "SpecParserSubject 5" - end - - it "should find context and description for type" do - parser.spec_name_for(file, 33).should == "SpecParserSubject described" - end - - it "should find context and description and example for type" do - parser.spec_name_for(file, 36).should == "SpecParserSubject described 6" - end - - it "should find context and description for type with modifications" do - parser.spec_name_for(file, 40).should == "SpecParserSubject described" - end - - it "should find context and described and example for type with modifications" do - parser.spec_name_for(file, 43).should == "SpecParserSubject described 7" - end - - it "should find example group" do - parser.spec_name_for(file, 47).should == "described" - end - - it "should find example" do - parser.spec_name_for(file, 50).should == "described 8" - end - - it "should find nested example" do - parser.spec_name_for(file, 63).should == "e f 11" - end - -end diff --git a/vendor/plugins/rspec/spec/spec/runner_spec.rb b/vendor/plugins/rspec/spec/spec/runner_spec.rb index d75e66111..3b55be7a7 100644 --- a/vendor/plugins/rspec/spec/spec/runner_spec.rb +++ b/vendor/plugins/rspec/spec/spec/runner_spec.rb @@ -1,11 +1,13 @@ -require File.dirname(__FILE__) + '/../spec_helper.rb' +require 'spec_helper' module Spec - describe Runner, ".configure" do - it "should yield global configuration" do - Spec::Runner.configure do |config| - config.should equal(Spec::Runner.configuration) + describe Runner do + describe ".configure" do + it "should yield global configuration" do + Spec::Runner.configure do |config| + config.should equal(Spec::Runner.configuration) + end end end end -end
\ No newline at end of file +end diff --git a/vendor/plugins/rspec/spec/spec/spec_classes.rb b/vendor/plugins/rspec/spec/spec/spec_classes.rb deleted file mode 100644 index c8900a789..000000000 --- a/vendor/plugins/rspec/spec/spec/spec_classes.rb +++ /dev/null @@ -1,133 +0,0 @@ -# This file contains various classes used by the specs. -module Spec - module Expectations - class Person - attr_reader :name - def initialize name - @name = name - end - def == other - return @name == other.name - end - end - - class ClassWithMultiWordPredicate - def multi_word_predicate? - true - end - end - - module Helper - class CollectionWithSizeMethod - def initialize; @list = []; end - def size; @list.size; end - def push(item); @list.push(item); end - end - - class CollectionWithLengthMethod - def initialize; @list = []; end - def length; @list.size; end - def push(item); @list.push(item); end - end - - class CollectionOwner - attr_reader :items_in_collection_with_size_method, :items_in_collection_with_length_method - - def initialize - @items_in_collection_with_size_method = CollectionWithSizeMethod.new - @items_in_collection_with_length_method = CollectionWithLengthMethod.new - end - - def add_to_collection_with_size_method(item) - @items_in_collection_with_size_method.push(item) - end - - def add_to_collection_with_length_method(item) - @items_in_collection_with_length_method.push(item) - end - - def items_for(arg) - return [1, 2, 3] if arg == 'a' - [1] - end - - def items - @items_in_collection_with_size_method - end - end - - class HandCodedMock - include Spec::Matchers - def initialize(return_val) - @return_val = return_val - @funny_called = false - end - - def funny? - @funny_called = true - @return_val - end - - def hungry?(a, b, c) - a.should equal(1) - b.should equal(2) - c.should equal(3) - @funny_called = true - @return_val - end - - def exists? - @return_val - end - - def multi_word_predicate? - @return_val - end - - def rspec_verify - @funny_called.should be_true - end - end - class ClassWithUnqueriedPredicate - attr_accessor :foo - def initialize(foo) - @foo = foo - end - end - end - end -end - -module Custom - require 'spec/runner/formatter/base_text_formatter' - class Formatter < Spec::Runner::Formatter::BaseTextFormatter - attr_reader :options, :where - - def initialize(options, where) - @options = options - @where = where - end - end - - class BadFormatter < Spec::Runner::Formatter::BaseTextFormatter - attr_reader :where - - def initialize(options, where) - bad_method - end - end - - class Differ - attr_reader :options - def initialize(options) - @options = options - end - - def diff_as_object(target, expected) - "" - end - end -end - -class FakeReporter < Spec::Runner::Reporter -end diff --git a/vendor/plugins/rspec/spec/spec/story/builders.rb b/vendor/plugins/rspec/spec/spec/story/builders.rb deleted file mode 100644 index 77d50d53e..000000000 --- a/vendor/plugins/rspec/spec/spec/story/builders.rb +++ /dev/null @@ -1,46 +0,0 @@ -module Spec - module Story - class StoryBuilder - def initialize - @title = 'a story' - @narrative = 'narrative' - end - - def title(value) - @title = value - self - end - - def narrative(value) - @narrative = value - self - end - - def to_story(&block) - block = lambda {} unless block_given? - Story.new @title, @narrative, &block - end - end - - class ScenarioBuilder - def initialize - @name = 'a scenario' - @story = StoryBuilder.new.to_story - end - - def name(value) - @name = value - self - end - - def story(value) - @story = value - self - end - - def to_scenario(&block) - Scenario.new @story, @name, &block - end - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/story/extensions/main_spec.rb b/vendor/plugins/rspec/spec/spec/story/extensions/main_spec.rb deleted file mode 100644 index acdc341ce..000000000 --- a/vendor/plugins/rspec/spec/spec/story/extensions/main_spec.rb +++ /dev/null @@ -1,161 +0,0 @@ -require File.dirname(__FILE__) + '/../../../spec_helper' - -module Spec - module Story - module Extensions - describe "the main object extended with Main", :shared => true do - before(:each) do - @main = Class.new do; include Main; end - @original_rspec_story_steps, $rspec_story_steps = $rspec_story_steps, nil - end - - after(:each) do - $rspec_story_steps = @original_rspec_story_steps - end - - def have_step(type, name) - return simple_matcher(%[step group containing a #{type} named #{name.inspect}]) do |actual| - Spec::Story::Step === actual.find(type, name) - end - end - end - - describe Main, "#run_story" do - it_should_behave_like "the main object extended with Main" - - it "should create a PlainTextStoryRunner with run_story" do - Spec::Story::Runner::PlainTextStoryRunner.should_receive(:new).and_return(mock("runner", :null_object => true)) - @main.run_story - end - - it "should yield the runner if arity == 1" do - File.should_receive(:read).with("some/path").and_return("Story: foo") - $main_spec_runner = nil - @main.run_story("some/path") do |runner| - $main_spec_runner = runner - end - $main_spec_runner.should be_an_instance_of(Spec::Story::Runner::PlainTextStoryRunner) - end - - it "should run in the runner if arity == 0" do - File.should_receive(:read).with("some/path").and_return("Story: foo") - $main_spec_runner = nil - @main.run_story("some/path") do - $main_spec_runner = self - end - $main_spec_runner.should be_an_instance_of(Spec::Story::Runner::PlainTextStoryRunner) - end - - it "should tell the PlainTextStoryRunner to run with run_story" do - runner = mock("runner") - Spec::Story::Runner::PlainTextStoryRunner.should_receive(:new).and_return(runner) - runner.should_receive(:run) - @main.run_story - end - end - - describe Main, "#steps_for" do - it_should_behave_like "the main object extended with Main" - - it "should have no steps for a non existent key" do - @main.steps_for(:key).find(:given, "foo").should be_nil - end - - it "should create steps for a key" do - $main_spec_invoked = false - @main.steps_for(:key) do - Given("foo") { - $main_spec_invoked = true - } - end - @main.steps_for(:key).find(:given, "foo").perform(Object.new, "foo") - $main_spec_invoked.should be_true - end - - it "should append steps to steps_for a given key" do - @main.steps_for(:key) do - Given("first") {} - end - @main.steps_for(:key) do - Given("second") {} - end - @main.steps_for(:key).should have_step(:given, "first") - @main.steps_for(:key).should have_step(:given, "second") - end - end - - describe Main, "#with_steps_for adding new steps" do - it_should_behave_like "the main object extended with Main" - - it "should result in a group containing pre-existing steps and newly defined steps" do - first_group = @main.steps_for(:key) do - Given("first") {} - end - second_group = @main.with_steps_for(:key) do - Given("second") {} - end - - second_group.should have_step(:given, "first") - second_group.should have_step(:given, "second") - end - - it "should not add its steps to the existing group" do - first_group = @main.steps_for(:key) do - Given("first") {} - end - second_group = @main.with_steps_for(:key) do - Given("second") {} - end - - first_group.should have_step(:given, "first") - first_group.should_not have_step(:given, "second") - end - end - - describe Main, "#with_steps_for running a story" do - it_should_behave_like "the main object extended with Main" - - before(:each) do - @runner = mock("runner") - @runner_step_group = StepGroup.new - @runner.stub!(:steps).and_return(@runner_step_group) - @runner.stub!(:run) - Spec::Story::Runner::PlainTextStoryRunner.stub!(:new).and_return(@runner) - end - - it "should create a PlainTextStoryRunner with a path" do - Spec::Story::Runner::PlainTextStoryRunner.should_receive(:new).with('path/to/file',{}).and_return(@runner) - @main.with_steps_for(:foo) do - run 'path/to/file' - end - end - - it "should create a PlainTextStoryRunner with a path and options" do - Spec::Story::Runner::PlainTextStoryRunner.should_receive(:new).with(anything,{:bar => :baz}).and_return(@runner) - @main.with_steps_for(:foo) do - run 'path/to/file', :bar => :baz - end - end - - it "should pass the group it creates to the runner's steps" do - steps = @main.steps_for(:ice_cream) do - Given("vanilla") {} - end - @main.with_steps_for(:ice_cream) do - run 'foo' - end - @runner_step_group.should have_step(:given, "vanilla") - end - - it "should run a story" do - @runner.should_receive(:run) - Spec::Story::Runner::PlainTextStoryRunner.should_receive(:new).and_return(@runner) - @main.with_steps_for(:foo) do - run 'path/to/file' - end - end - - end - end - end -end
\ No newline at end of file diff --git a/vendor/plugins/rspec/spec/spec/story/extensions_spec.rb b/vendor/plugins/rspec/spec/spec/story/extensions_spec.rb deleted file mode 100644 index 612ddc72f..000000000 --- a/vendor/plugins/rspec/spec/spec/story/extensions_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require File.dirname(__FILE__) + '/story_helper' - -require 'spec/story' - -describe Kernel, "#Story" do - before(:each) do - Kernel.stub!(:at_exit) - end - - it "should delegate to ::Spec::Story::Runner.story_runner" do - ::Spec::Story::Runner.story_runner.should_receive(:Story) - story = Story("title","narrative"){} - end -end diff --git a/vendor/plugins/rspec/spec/spec/story/given_scenario_spec.rb b/vendor/plugins/rspec/spec/spec/story/given_scenario_spec.rb deleted file mode 100644 index a688f88d5..000000000 --- a/vendor/plugins/rspec/spec/spec/story/given_scenario_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require File.dirname(__FILE__) + '/story_helper' - -module Spec - module Story - describe GivenScenario do - it 'should execute a scenario from the current story in its world' do - # given - class MyWorld - attr :scenario_ran - end - instance = World.create(MyWorld) - scenario = ScenarioBuilder.new.to_scenario do - @scenario_ran = true - end - Runner::StoryRunner.should_receive(:scenario_from_current_story).with('scenario name').and_return(scenario) - - step = GivenScenario.new 'scenario name' - - # when - step.perform(instance, nil) - - # then - instance.scenario_ran.should be_true - end - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/story/runner/plain_text_story_runner_spec.rb b/vendor/plugins/rspec/spec/spec/story/runner/plain_text_story_runner_spec.rb deleted file mode 100644 index 91f5f9e9b..000000000 --- a/vendor/plugins/rspec/spec/spec/story/runner/plain_text_story_runner_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -require File.dirname(__FILE__) + '/../story_helper' - -module Spec - module Story - module Runner - describe PlainTextStoryRunner do - before(:each) do - StoryParser.stub!(:new).and_return(@parser = mock("parser")) - @parser.stub!(:parse).and_return([]) - File.stub!(:read).with("path").and_return("this\nand that") - end - - it "should provide access to steps" do - runner = PlainTextStoryRunner.new("path") - - runner.steps do |add| - add.given("baz") {} - end - - runner.steps.find(:given, "baz").should_not be_nil - end - - it "should parse a story file" do - runner = PlainTextStoryRunner.new("path") - during { - runner.run(mock('runner')) - }.expect { - @parser.should_receive(:parse).with(["this", "and that"]) - } - end - - it "should build up a mediator with its own steps and the singleton story_runner" do - @story_runner = mock('story runner', :null_object => true) - - runner = PlainTextStoryRunner.new("path") - - Spec::Story::Runner::StoryMediator.should_receive(:new).with( - runner.steps, @story_runner, {} - ).and_return(mediator = stub("mediator", :run_stories => nil)) - runner.run(@story_runner) - end - - it "should build up a parser with the mediator" do - runner = PlainTextStoryRunner.new("path") - Spec::Story::Runner::StoryMediator.should_receive(:new).and_return(mediator = stub("mediator", :run_stories => nil)) - Spec::Story::Runner::StoryParser.should_receive(:new).with(mediator).and_return(@parser) - runner.run(stub("story_runner")) - end - - it "should tell the mediator to run the stories" do - runner = PlainTextStoryRunner.new("path") - mediator = mock("mediator") - Spec::Story::Runner::StoryMediator.should_receive(:new).and_return(mediator) - mediator.should_receive(:run_stories) - runner.run(mock('runner')) - end - - it "should accept a block instead of a path" do - runner = PlainTextStoryRunner.new do |runner| - runner.load("path/to/story") - end - File.should_receive(:read).with("path/to/story").and_return("this\nand that") - runner.run(mock('runner')) - end - - it "should tell you if you try to run with no path set" do - runner = PlainTextStoryRunner.new - lambda { - runner.run(mock('runner')) - }.should raise_error(RuntimeError, "You must set a path to the file with the story. See the RDoc.") - end - - it "should pass options to the mediator" do - runner = PlainTextStoryRunner.new("path", :foo => :bar) - Spec::Story::Runner::StoryMediator.should_receive(:new). - with(anything, anything, :foo => :bar). - and_return(mediator = stub("mediator", :run_stories => nil)) - runner.run(mock('runner')) - end - - it "should provide access to its options" do - runner = PlainTextStoryRunner.new("path") - runner[:foo] = :bar - Spec::Story::Runner::StoryMediator.should_receive(:new). - with(anything, anything, :foo => :bar). - and_return(mediator = stub("mediator", :run_stories => nil)) - runner.run mock('runner') - end - - end - end - end -end
\ No newline at end of file diff --git a/vendor/plugins/rspec/spec/spec/story/runner/scenario_collector_spec.rb b/vendor/plugins/rspec/spec/spec/story/runner/scenario_collector_spec.rb deleted file mode 100644 index 042c41e8d..000000000 --- a/vendor/plugins/rspec/spec/spec/story/runner/scenario_collector_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require File.dirname(__FILE__) + '/../story_helper' - -module Spec - module Story - module Runner - describe ScenarioCollector do - it 'should construct scenarios with the supplied story' do - # given - story = stub_everything('story') - scenario_collector = ScenarioCollector.new(story) - - # when - scenario_collector.Scenario 'scenario1' do end - scenario_collector.Scenario 'scenario2' do end - scenarios = scenario_collector.scenarios - - # then - scenario_collector.should have(2).scenarios - scenarios.first.name.should == 'scenario1' - scenarios.first.story.should equal(story) - scenarios.last.name.should == 'scenario2' - scenarios.last.story.should equal(story) - end - end - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/story/runner/scenario_runner_spec.rb b/vendor/plugins/rspec/spec/spec/story/runner/scenario_runner_spec.rb deleted file mode 100644 index c13c3d7f8..000000000 --- a/vendor/plugins/rspec/spec/spec/story/runner/scenario_runner_spec.rb +++ /dev/null @@ -1,214 +0,0 @@ -require File.dirname(__FILE__) + '/../story_helper' - -module Spec - module Story - module Runner - describe ScenarioRunner do - it 'should run a scenario in its story' do - # given - world = stub_everything - scenario_runner = ScenarioRunner.new - $answer = nil - story = Story.new 'story', 'narrative' do - @answer = 42 # this should be available to the scenario - end - scenario = Scenario.new story, 'scenario' do - $answer = @answer - end - - # when - scenario_runner.run(scenario, world) - - # then - $answer.should == 42 - end - - it 'should allow scenarios to share methods' do - # given - world = stub_everything - $shared_invoked = 0 - story = Story.new 'story', 'narrative' do - def shared - $shared_invoked += 1 - end - end - scenario1 = Scenario.new story, 'scenario1' do - shared() - end - scenario2 = Scenario.new story, 'scenario2' do - shared() - end - scenario_runner = ScenarioRunner.new - - # when - scenario_runner.run(scenario1, world) - scenario_runner.run(scenario2, world) - - # then - $shared_invoked.should == 2 - end - - it 'should notify listeners when a scenario starts' do - # given - world = stub_everything - story = Story.new 'story', 'narrative' do end - scenario = Scenario.new story, 'scenario1' do - # succeeds - end - scenario_runner = ScenarioRunner.new - mock_listener1 = stub_everything('listener1') - mock_listener2 = stub_everything('listener2') - scenario_runner.add_listener(mock_listener1) - scenario_runner.add_listener(mock_listener2) - - # expect - mock_listener1.should_receive(:scenario_started).with('story', 'scenario1') - mock_listener2.should_receive(:scenario_started).with('story', 'scenario1') - - # when - scenario_runner.run(scenario, world) - - # then - end - describe "when a scenario succeeds" do - before(:each) do - # given - @world = stub_everything('world') - @story = Story.new 'story', 'narrative' do end - @scenario = Scenario.new @story, 'scenario1' do - # succeeds - end - @scenario_runner = ScenarioRunner.new - end - - it 'should notify listeners' do - #given - mock_listener1 = stub_everything('listener1') - mock_listener2 = stub_everything('listener2') - @scenario_runner.add_listener(mock_listener1) - @scenario_runner.add_listener(mock_listener2) - - # expect - mock_listener1.should_receive(:scenario_succeeded).with('story', 'scenario1') - mock_listener2.should_receive(:scenario_succeeded).with('story', 'scenario1') - - # when - @scenario_runner.run(@scenario, @world) - - # then - end - - it "should return true" do - #when - success = @scenario_runner.run(@scenario, @world) - - #then - success.should == true - end - end - - describe "when a scenario raises an error (other than a pending error)" do - before(:each) do - # given - @error = RuntimeError.new('oops') - @story = Story.new 'title', 'narrative' do end - @scenario = Scenario.new @story, 'scenario1' do - end - @scenario_runner = ScenarioRunner.new - @world = stub_everything - - # expect - @world.should_receive(:errors).twice.and_return([@error, @error]) - end - - it 'should notify listeners ONCE' do - #given - mock_listener = stub_everything('listener') - @scenario_runner.add_listener(mock_listener) - - #expect - mock_listener.should_receive(:scenario_failed).with('title', 'scenario1', @error).once - - # when - @scenario_runner.run @scenario, @world - - # then - end - - it "should return false" do - # when - success = @scenario_runner.run @scenario, @world - - # then - success.should == false - end - - - end - - describe "when a scenario is pending" do - before(:each) do - # given - @pending_error = Spec::Example::ExamplePendingError.new('todo') - @story = Story.new 'title', 'narrative' do end - @scenario = Scenario.new @story, 'scenario1' do - end - @scenario_runner = ScenarioRunner.new - @world = stub_everything - - # expect - @world.should_receive(:errors).twice.and_return([@pending_error, @pending_error]) - end - - it 'should notify listeners' do - #given - mock_listener = mock('listener') - @scenario_runner.add_listener(mock_listener) - - # expect - mock_listener.should_receive(:scenario_started).with('title', 'scenario1') - mock_listener.should_receive(:scenario_pending).with('title', 'scenario1', 'todo').once - - # when - @scenario_runner.run @scenario, @world - - # then - end - - it "should return true" do - # when - success = @scenario_runner.run @scenario, @world - - # then - success.should == true - end - end - - describe "when a scenario has an empty body" do - before(:each) do - @story = Story.new 'title', 'narrative' do end - @scenario = Scenario.new @story, 'scenario' - @scenario_runner = ScenarioRunner.new - @world = stub_everything - end - - it "should mark the scenario as pending" do - mock_listener = stub('listener', :scenario_started => true) - @scenario_runner.add_listener mock_listener - - mock_listener.should_receive(:scenario_pending).with('title', 'scenario', '') - @scenario_runner.run @scenario, @world - end - - it "should return true" do - # when - success = @scenario_runner.run @scenario, @world - - # then - success.should == true - end - end - end - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/story/runner/story_mediator_spec.rb b/vendor/plugins/rspec/spec/spec/story/runner/story_mediator_spec.rb deleted file mode 100644 index 32abe5e05..000000000 --- a/vendor/plugins/rspec/spec/spec/story/runner/story_mediator_spec.rb +++ /dev/null @@ -1,133 +0,0 @@ -require File.dirname(__FILE__) + '/../story_helper' - -module Spec - module Story - module Runner - - describe StoryMediator do - before(:each) do - $story_mediator_spec_value = nil - @step_group = StepGroup.new - @step_group.create_matcher(:given, "given") { $story_mediator_spec_value = "given matched" } - @step_group.create_matcher(:when, "when") { $story_mediator_spec_value = "when matched" } - @step_group.create_matcher(:then, "then") { $story_mediator_spec_value = "then matched" } - - @scenario_runner = ScenarioRunner.new - @runner = StoryRunner.new @scenario_runner - @mediator = StoryMediator.new @step_group, @runner - end - - def run_stories - @mediator.run_stories - @runner.run_stories - end - - it "should have no stories" do - @mediator.stories.should be_empty - end - - it "should create two stories" do - @mediator.create_story "story title", "story narrative" - @mediator.create_story "story title 2", "story narrative 2" - run_stories - - @runner.should have(2).stories - @runner.stories.first.title.should == "story title" - @runner.stories.first.narrative.should == "story narrative" - @runner.stories.last.title.should == "story title 2" - @runner.stories.last.narrative.should == "story narrative 2" - end - - it "should create a scenario" do - @mediator.create_story "title", "narrative" - @mediator.create_scenario "scenario name" - run_stories - - @runner.should have(1).scenarios - @runner.scenarios.first.name.should == "scenario name" - @runner.scenarios.first.story.should == @runner.stories.first - end - - it "should create a given scenario step if one matches" do - pending("need to untangle the dark mysteries of the story runner - something needs to get stubbed here") do - story = @mediator.create_story "title", "narrative" - @mediator.create_scenario "previous scenario" - @mediator.create_scenario "current scenario" - @mediator.create_given_scenario "previous scenario" - run_stories - - $story_mediator_spec_value.should == "previous scenario matched" - end - end - - it "should create a given step if one matches" do - @mediator.create_story "title", "narrative" - @mediator.create_scenario "scenario" - @mediator.create_given "given" - run_stories - - $story_mediator_spec_value.should == "given matched" - end - - it "should create a pending step if no given step matches" do - @mediator.create_story "title", "narrative" - @mediator.create_scenario "scenario" - @mediator.create_given "no match" - mock_listener = stub_everything("listener") - mock_listener.should_receive(:scenario_pending).with("title", "scenario", "Unimplemented step: no match") - @scenario_runner.add_listener mock_listener - run_stories - end - - it "should create a when step if one matches" do - @mediator.create_story "title", "narrative" - @mediator.create_scenario "scenario" - @mediator.create_when "when" - run_stories - - $story_mediator_spec_value.should == "when matched" - end - - it "should create a pending step if no when step matches" do - @mediator.create_story "title", "narrative" - @mediator.create_scenario "scenario" - @mediator.create_when "no match" - mock_listener = stub_everything("listener") - mock_listener.should_receive(:scenario_pending).with("title", "scenario", "Unimplemented step: no match") - @scenario_runner.add_listener mock_listener - run_stories - end - - it "should create a then step if one matches" do - @mediator.create_story "title", "narrative" - @mediator.create_scenario "scenario" - @mediator.create_then "then" - run_stories - - $story_mediator_spec_value.should == "then matched" - end - - it "should create a pending step if no 'then' step matches" do - @mediator.create_story "title", "narrative" - @mediator.create_scenario "scenario" - @mediator.create_then "no match" - mock_listener = stub_everything("listener") - mock_listener.should_receive(:scenario_pending).with("title", "scenario", "Unimplemented step: no match") - @scenario_runner.add_listener mock_listener - run_stories - end - - it "should pass options to the stories it creates" do - @mediator = StoryMediator.new @step_group, @runner, :foo => :bar - @mediator.create_story "story title", "story narrative" - - run_stories - - @runner.stories.first[:foo].should == :bar - end - - end - - end - end -end
\ No newline at end of file diff --git a/vendor/plugins/rspec/spec/spec/story/runner/story_parser_spec.rb b/vendor/plugins/rspec/spec/spec/story/runner/story_parser_spec.rb deleted file mode 100644 index 5efc8fd18..000000000 --- a/vendor/plugins/rspec/spec/spec/story/runner/story_parser_spec.rb +++ /dev/null @@ -1,384 +0,0 @@ -require File.dirname(__FILE__) + '/../story_helper' - -module Spec - module Story - module Runner - - describe StoryParser do - before(:each) do - @story_mediator = mock("story_mediator") - @parser = StoryParser.new(@story_mediator) - end - - it "should parse no lines" do - @parser.parse([]) - end - - it "should ignore text before the first Story: begins" do - @story_mediator.should_not_receive(:create_scenario) - @story_mediator.should_not_receive(:create_given) - @story_mediator.should_not_receive(:create_when) - @story_mediator.should_not_receive(:create_then) - @story_mediator.should_receive(:create_story).with("simple addition", "") - @parser.parse(["Here is a bunch of text", "about a calculator and all the things", "that it will do", "Story: simple addition"]) - end - - it "should create a story" do - @story_mediator.should_receive(:create_story).with("simple addition", "") - @parser.parse(["Story: simple addition"]) - end - - it "should create a story when line has leading spaces" do - @story_mediator.should_receive(:create_story).with("simple addition", "") - @parser.parse([" Story: simple addition"]) - end - - it "should add a one line narrative to the story" do - @story_mediator.should_receive(:create_story).with("simple addition","narrative") - @parser.parse(["Story: simple addition","narrative"]) - end - - it "should add a multi line narrative to the story" do - @story_mediator.should_receive(:create_story).with("simple addition","narrative line 1\nline 2\nline 3") - @parser.parse(["Story: simple addition","narrative line 1", "line 2", "line 3"]) - end - - it "should exclude blank lines from the narrative" do - @story_mediator.should_receive(:create_story).with("simple addition","narrative line 1\nline 2") - @parser.parse(["Story: simple addition","narrative line 1", "", "line 2"]) - end - - it "should exclude Scenario from the narrative" do - @story_mediator.should_receive(:create_story).with("simple addition","narrative line 1\nline 2") - @story_mediator.should_receive(:create_scenario) - @parser.parse(["Story: simple addition","narrative line 1", "line 2", "Scenario: add one plus one"]) - end - - end - - describe StoryParser, "in Story state" do - before(:each) do - @story_mediator = mock("story_mediator") - @parser = StoryParser.new(@story_mediator) - @story_mediator.stub!(:create_story) - end - - it "should create a second Story for Story" do - @story_mediator.should_receive(:create_story).with("number two","") - @parser.parse(["Story: s", "Story: number two"]) - end - - it "should include And in the narrative" do - @story_mediator.should_receive(:create_story).with("s","And foo") - @story_mediator.should_receive(:create_scenario).with("bar") - @parser.parse(["Story: s", "And foo", "Scenario: bar"]) - end - - it "should create a Scenario for Scenario" do - @story_mediator.should_receive(:create_scenario).with("number two") - @parser.parse(["Story: s", "Scenario: number two"]) - end - - it "should include Given in the narrative" do - @story_mediator.should_receive(:create_story).with("s","Given foo") - @story_mediator.should_receive(:create_scenario).with("bar") - @parser.parse(["Story: s", "Given foo", "Scenario: bar"]) - end - - it "should include Given: in the narrative" do - @story_mediator.should_receive(:create_story).with("s","Given: foo") - @story_mediator.should_receive(:create_scenario).with("bar") - @parser.parse(["Story: s", "Given: foo", "Scenario: bar"]) - end - - it "should include When in the narrative" do - @story_mediator.should_receive(:create_story).with("s","When foo") - @story_mediator.should_receive(:create_scenario).with("bar") - @parser.parse(["Story: s", "When foo", "Scenario: bar"]) - end - - it "should include Then in the narrative" do - @story_mediator.should_receive(:create_story).with("s","Then foo") - @story_mediator.should_receive(:create_scenario).with("bar") - @parser.parse(["Story: s", "Then foo", "Scenario: bar"]) - end - - it "should include other in the story" do - @story_mediator.should_receive(:create_story).with("s","narrative") - @parser.parse(["Story: s", "narrative"]) - end - end - - describe StoryParser, "in Scenario state" do - before(:each) do - @story_mediator = mock("story_mediator") - @parser = StoryParser.new(@story_mediator) - @story_mediator.stub!(:create_story) - @story_mediator.stub!(:create_scenario) - end - - it "should create a Story for Story" do - @story_mediator.should_receive(:create_story).with("number two","") - @parser.parse(["Story: s", "Scenario: s", "Story: number two"]) - end - - it "should create a Scenario for Scenario" do - @story_mediator.should_receive(:create_scenario).with("number two") - @parser.parse(["Story: s", "Scenario: s", "Scenario: number two"]) - end - - it "should raise for And" do - lambda { - @parser.parse(["Story: s", "Scenario: s", "And second"]) - }.should raise_error(IllegalStepError, /^Illegal attempt to create a And after a Scenario/) - end - - it "should create a Given for Given" do - @story_mediator.should_receive(:create_given).with("gift") - @parser.parse(["Story: s", "Scenario: s", "Given gift"]) - end - - it "should create a Given for Given:" do - @story_mediator.should_receive(:create_given).with("gift") - @parser.parse(["Story: s", "Scenario: s", "Given: gift"]) - end - - it "should create a GivenScenario for GivenScenario" do - @story_mediator.should_receive(:create_given_scenario).with("previous") - @parser.parse(["Story: s", "Scenario: s", "GivenScenario previous"]) - end - - it "should create a GivenScenario for GivenScenario:" do - @story_mediator.should_receive(:create_given_scenario).with("previous") - @parser.parse(["Story: s", "Scenario: s", "GivenScenario: previous"]) - end - - it "should transition to Given state after GivenScenario" do - @story_mediator.stub!(:create_given_scenario) - @parser.parse(["Story: s", "Scenario: s", "GivenScenario previous"]) - @parser.instance_eval{@state}.should be_an_instance_of(StoryParser::GivenState) - end - - it "should transition to Given state after GivenScenario:" do - @story_mediator.stub!(:create_given_scenario) - @parser.parse(["Story: s", "Scenario: s", "GivenScenario: previous"]) - @parser.instance_eval{@state}.should be_an_instance_of(StoryParser::GivenState) - end - - it "should create a When for When" do - @story_mediator.should_receive(:create_when).with("ever") - @parser.parse(["Story: s", "Scenario: s", "When ever"]) - end - - it "should create a When for When:" do - @story_mediator.should_receive(:create_when).with("ever") - @parser.parse(["Story: s", "Scenario: s", "When: ever"]) - end - - it "should create a Then for Then" do - @story_mediator.should_receive(:create_then).with("and there") - @parser.parse(["Story: s", "Scenario: s", "Then and there"]) - end - - it "should create a Then for Then:" do - @story_mediator.should_receive(:create_then).with("and there") - @parser.parse(["Story: s", "Scenario: s", "Then: and there"]) - end - - it "should ignore other" do - @parser.parse(["Story: s", "Scenario: s", "this is ignored"]) - end - end - - describe StoryParser, "in Given state" do - before(:each) do - @story_mediator = mock("story_mediator") - @parser = StoryParser.new(@story_mediator) - @story_mediator.stub!(:create_story) - @story_mediator.stub!(:create_scenario) - @story_mediator.should_receive(:create_given).with("first") - end - - it "should create a Story for Story" do - @story_mediator.should_receive(:create_story).with("number two","") - @parser.parse(["Story: s", "Scenario: s", "Given first", "Story: number two"]) - end - - it "should create a Scenario for Scenario" do - @story_mediator.should_receive(:create_scenario).with("number two") - @parser.parse(["Story: s", "Scenario: s", "Given first", "Scenario: number two"]) - end - - it "should create a second Given for Given" do - @story_mediator.should_receive(:create_given).with("second") - @parser.parse(["Story: s", "Scenario: s", "Given first", "Given second"]) - end - - it "should create a second Given for And" do - @story_mediator.should_receive(:create_given).with("second") - @parser.parse(["Story: s", "Scenario: s", "Given: first", "And second"]) - end - - it "should create a second Given for And:" do - @story_mediator.should_receive(:create_given).with("second") - @parser.parse(["Story: s", "Scenario: s", "Given first", "And: second"]) - end - - it "should create a When for When" do - @story_mediator.should_receive(:create_when).with("ever") - @parser.parse(["Story: s", "Scenario: s", "Given first", "When ever"]) - end - - it "should create a When for When:" do - @story_mediator.should_receive(:create_when).with("ever") - @parser.parse(["Story: s", "Scenario: s", "Given first", "When: ever"]) - end - - it "should create a Then for Then" do - @story_mediator.should_receive(:create_then).with("and there") - @parser.parse(["Story: s", "Scenario: s", "Given first", "Then and there"]) - end - - it "should create a Then for Then:" do - @story_mediator.should_receive(:create_then).with("and there") - @parser.parse(["Story: s", "Scenario: s", "Given first", "Then: and there"]) - end - - it "should ignore other" do - @parser.parse(["Story: s", "Scenario: s", "Given first", "this is ignored"]) - end - end - - describe StoryParser, "in When state" do - before(:each) do - @story_mediator = mock("story_mediator") - @parser = StoryParser.new(@story_mediator) - @story_mediator.stub!(:create_story) - @story_mediator.stub!(:create_scenario) - @story_mediator.should_receive(:create_given).with("first") - @story_mediator.should_receive(:create_when).with("else") - end - - it "should create a Story for Story" do - @story_mediator.should_receive(:create_story).with("number two","") - @parser.parse(["Story: s", "Scenario: s", "Given first", "When: else", "Story: number two"]) - end - - it "should create a Scenario for Scenario" do - @story_mediator.should_receive(:create_scenario).with("number two") - @parser.parse(["Story: s", "Scenario: s", "Given first", "When else", "Scenario: number two"]) - end - - it "should create Given for Given" do - @story_mediator.should_receive(:create_given).with("second") - @parser.parse(["Story: s", "Scenario: s", "Given first", "When else", "Given second"]) - end - - it "should create Given for Given:" do - @story_mediator.should_receive(:create_given).with("second") - @parser.parse(["Story: s", "Scenario: s", "Given first", "When else", "Given: second"]) - end - - it "should create a second When for When" do - @story_mediator.should_receive(:create_when).with("ever") - @parser.parse(["Story: s", "Scenario: s", "Given first", "When else", "When ever"]) - end - - it "should create a second When for When:" do - @story_mediator.should_receive(:create_when).with("ever") - @parser.parse(["Story: s", "Scenario: s", "Given: first", "When: else", "When: ever"]) - end - - it "should create a second When for And" do - @story_mediator.should_receive(:create_when).with("ever") - @parser.parse(["Story: s", "Scenario: s", "Given first", "When else", "And ever"]) - end - - it "should create a second When for And:" do - @story_mediator.should_receive(:create_when).with("ever") - @parser.parse(["Story: s", "Scenario: s", "Given: first", "When: else", "And: ever"]) - end - - it "should create a Then for Then" do - @story_mediator.should_receive(:create_then).with("and there") - @parser.parse(["Story: s", "Scenario: s", "Given first", "When else", "Then and there"]) - end - - it "should create a Then for Then:" do - @story_mediator.should_receive(:create_then).with("and there") - @parser.parse(["Story: s", "Scenario: s", "Given: first", "When: else", "Then: and there"]) - end - - it "should ignore other" do - @parser.parse(["Story: s", "Scenario: s", "Given first", "When else", "this is ignored"]) - end - end - - describe StoryParser, "in Then state" do - before(:each) do - @story_mediator = mock("story_mediator") - @parser = StoryParser.new(@story_mediator) - @story_mediator.stub!(:create_story) - @story_mediator.stub!(:create_scenario) - @story_mediator.should_receive(:create_given).with("first") - @story_mediator.should_receive(:create_when).with("else") - @story_mediator.should_receive(:create_then).with("what") - end - - it "should create a Story for Story" do - @story_mediator.should_receive(:create_story).with("number two","") - @parser.parse(["Story: s", "Scenario: s", "Given first", "When else", "Then what", "Story: number two"]) - end - - it "should create a Scenario for Scenario" do - @story_mediator.should_receive(:create_scenario).with("number two") - @parser.parse(["Story: s", "Scenario: s", "Given first", "When else", "Then what", "Scenario: number two"]) - end - - it "should create Given for Given" do - @story_mediator.should_receive(:create_given).with("second") - @parser.parse(["Story: s", "Scenario: s", "Given first", "When else", "Then what", "Given second"]) - end - - it "should create Given for Given:" do - @story_mediator.should_receive(:create_given).with("second") - @parser.parse(["Story: s", "Scenario: s", "Given: first", "When: else", "Then: what", "Given: second"]) - end - - it "should create When for When" do - @story_mediator.should_receive(:create_when).with("ever") - @parser.parse(["Story: s", "Scenario: s", "Given first", "When else", "Then what", "When ever"]) - end - - it "should create When for When:" do - @story_mediator.should_receive(:create_when).with("ever") - @parser.parse(["Story: s", "Scenario: s", "Given: first", "When: else", "Then: what", "When: ever"]) - end - - it "should create a Then for Then" do - @story_mediator.should_receive(:create_then).with("and there") - @parser.parse(["Story: s", "Scenario: s", "Given first", "When else", "Then what", "Then and there"]) - end - - it "should create a Then for Then:" do - @story_mediator.should_receive(:create_then).with("and there") - @parser.parse(["Story: s", "Scenario: s", "Given: first", "When: else", "Then: what", "Then: and there"]) - end - - it "should create a second Then for And" do - @story_mediator.should_receive(:create_then).with("ever") - @parser.parse(["Story: s", "Scenario: s", "Given first", "When else", "Then what", "And ever"]) - end - - it "should create a second Then for And:" do - @story_mediator.should_receive(:create_then).with("ever") - @parser.parse(["Story: s", "Scenario: s", "Given: first", "When: else", "Then: what", "And: ever"]) - end - - it "should ignore other" do - @parser.parse(["Story: s", "Scenario: s", "Given first", "When else", "Then what", "this is ignored"]) - end - end - end - end -end
\ No newline at end of file diff --git a/vendor/plugins/rspec/spec/spec/story/runner/story_runner_spec.rb b/vendor/plugins/rspec/spec/spec/story/runner/story_runner_spec.rb deleted file mode 100644 index 5bed6c562..000000000 --- a/vendor/plugins/rspec/spec/spec/story/runner/story_runner_spec.rb +++ /dev/null @@ -1,294 +0,0 @@ -require File.dirname(__FILE__) + '/../story_helper' - -module Spec - module Story - module Runner - describe StoryRunner do - it 'should collect all the stories' do - # given - story_runner = StoryRunner.new(stub('scenario_runner')) - - # when - story_runner.Story 'title1', 'narrative1' do end - story_runner.Story 'title2', 'narrative2' do end - stories = story_runner.stories - - # then - story_runner.should have(2).stories - stories.first.title.should == 'title1' - stories.first.narrative.should == 'narrative1' - stories.last.title.should == 'title2' - stories.last.narrative.should == 'narrative2' - end - - it 'should gather all the scenarios in the stories' do - # given - story_runner = StoryRunner.new(stub('scenario_runner')) - - # when - story_runner.Story "story1", "narrative1" do - Scenario "scenario1" do end - Scenario "scenario2" do end - end - story_runner.Story "story2", "narrative2" do - Scenario "scenario3" do end - end - scenarios = story_runner.scenarios - - # then - story_runner.should have(3).scenarios - scenarios[0].name.should == 'scenario1' - scenarios[1].name.should == 'scenario2' - scenarios[2].name.should == 'scenario3' - end - - # captures worlds passed into a ScenarioRunner - class ScenarioWorldCatcher - attr_accessor :worlds - def run(scenario, world) - (@worlds ||= []) << world - end - end - - it 'should run each scenario in a separate object' do - # given - scenario_world_catcher = ScenarioWorldCatcher.new - story_runner = StoryRunner.new(scenario_world_catcher) - story_runner.Story 'story', 'narrative' do - Scenario 'scenario1' do end - Scenario 'scenario2' do end - end - - # when - story_runner.run_stories - - # then - worlds = scenario_world_catcher.worlds - scenario_world_catcher.should have(2).worlds - worlds[0].should_not == worlds[1] - end - - it "should return false if the scenario runner returns false ever" do - #given - stub_scenario_runner = stub_everything - story_runner = StoryRunner.new(stub_scenario_runner) - story_runner.Story 'story', 'narrative' do - Scenario 'scenario1' do end - Scenario 'scenario2' do end - end - - # expect - stub_scenario_runner.should_receive(:run).once.and_return(false,true) - - # when - success = story_runner.run_stories - - #then - success.should == false - end - - it "should return true if the scenario runner returns true for all scenarios" do - #given - stub_scenario_runner = stub_everything - story_runner = StoryRunner.new(stub_scenario_runner) - story_runner.Story 'story', 'narrative' do - Scenario 'scenario1' do end - Scenario 'scenario2' do end - end - - # expect - stub_scenario_runner.should_receive(:run).once.and_return(true,true) - - # when - success = story_runner.run_stories - - #then - success.should == true - end - - it 'should use the provided world creator to create worlds' do - # given - stub_scenario_runner = stub_everything - mock_world_creator = mock('world creator') - story_runner = StoryRunner.new(stub_scenario_runner, mock_world_creator) - story_runner.Story 'story', 'narrative' do - Scenario 'scenario1' do end - Scenario 'scenario2' do end - end - - # expect - mock_world_creator.should_receive(:create).twice - - # when - story_runner.run_stories - - # then - end - - it 'should notify listeners of the scenario count when the run starts' do - # given - story_runner = StoryRunner.new(stub_everything) - mock_listener1 = stub_everything('listener1') - mock_listener2 = stub_everything('listener2') - story_runner.add_listener(mock_listener1) - story_runner.add_listener(mock_listener2) - - story_runner.Story 'story1', 'narrative1' do - Scenario 'scenario1' do end - end - story_runner.Story 'story2', 'narrative2' do - Scenario 'scenario2' do end - Scenario 'scenario3' do end - end - - # expect - mock_listener1.should_receive(:run_started).with(3) - mock_listener2.should_receive(:run_started).with(3) - - # when - story_runner.run_stories - - # then - end - - it 'should notify listeners when a story starts' do - # given - story_runner = StoryRunner.new(stub_everything) - mock_listener1 = stub_everything('listener1') - mock_listener2 = stub_everything('listener2') - story_runner.add_listener(mock_listener1) - story_runner.add_listener(mock_listener2) - - story_runner.Story 'story1', 'narrative1' do - Scenario 'scenario1' do end - end - story_runner.Story 'story2', 'narrative2' do - Scenario 'scenario2' do end - Scenario 'scenario3' do end - end - - # expect - mock_listener1.should_receive(:story_started).with('story1', 'narrative1') - mock_listener1.should_receive(:story_ended).with('story1', 'narrative1') - mock_listener2.should_receive(:story_started).with('story2', 'narrative2') - mock_listener2.should_receive(:story_ended).with('story2', 'narrative2') - - # when - story_runner.run_stories - - # then - end - - it 'should notify listeners when the run ends' do - # given - story_runner = StoryRunner.new(stub_everything) - mock_listener1 = stub_everything('listener1') - mock_listener2 = stub_everything('listener2') - story_runner.add_listener mock_listener1 - story_runner.add_listener mock_listener2 - story_runner.Story 'story1', 'narrative1' do - Scenario 'scenario1' do end - end - - # expect - mock_listener1.should_receive(:run_ended) - mock_listener2.should_receive(:run_ended) - - # when - story_runner.run_stories - - # then - end - - it 'should run a story in an instance of a specified class' do - # given - scenario_world_catcher = ScenarioWorldCatcher.new - story_runner = StoryRunner.new(scenario_world_catcher) - story_runner.Story 'title', 'narrative', :type => String do - Scenario 'scenario' do end - end - - # when - story_runner.run_stories - - # then - scenario_world_catcher.worlds[0].should be_kind_of(String) - scenario_world_catcher.worlds[0].should be_kind_of(World) - end - - it 'should pass initialization params through to the constructed instance' do - # given - scenario_world_catcher = ScenarioWorldCatcher.new - story_runner = StoryRunner.new(scenario_world_catcher) - story_runner.Story 'title', 'narrative', :type => Array, :args => [3] do - Scenario 'scenario' do end - end - - # when - story_runner.run_stories - - # then - scenario_world_catcher.worlds[0].should be_kind_of(Array) - scenario_world_catcher.worlds[0].size.should == 3 - end - - it 'should find a scenario in the current story by name' do - # given - story_runner = StoryRunner.new(ScenarioRunner.new) - $scenario = nil - - story_runner.Story 'title', 'narrative' do - Scenario 'first scenario' do - end - Scenario 'second scenario' do - $scenario = StoryRunner.scenario_from_current_story 'first scenario' - end - end - - # when - story_runner.run_stories - - # then - $scenario.name.should == 'first scenario' - end - - it "should clean the steps between stories" do - #given - story_runner = StoryRunner.new(ScenarioRunner.new) - result = mock 'result' - - step1 = Step.new('step') do - result.one - end - steps1 = StepGroup.new - steps1.add :when, step1 - - story_runner.Story 'title', 'narrative', :steps_for => steps1 do - Scenario 'first scenario' do - When 'step' - end - end - - step2 = Step.new('step') do - result.two - end - steps2 = StepGroup.new - steps2.add :when, step2 - - story_runner.Story 'title2', 'narrative', :steps_for => steps2 do - Scenario 'second scenario' do - When 'step' - end - end - - #then - result.should_receive(:one) - result.should_receive(:two) - - #when - story_runner.run_stories - end - end - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/story/runner_spec.rb b/vendor/plugins/rspec/spec/spec/story/runner_spec.rb deleted file mode 100644 index db1c40de5..000000000 --- a/vendor/plugins/rspec/spec/spec/story/runner_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -require File.dirname(__FILE__) + '/story_helper' -require 'spec/runner/formatter/story/plain_text_formatter' -require 'spec/runner/formatter/story/html_formatter' - -module Spec - module Story - describe Runner, "module" do - before(:each) do - @world_creator = World.dup - @runner_module = Runner.dup - @runner_module.instance_eval {@story_runner = nil} - @runner_module.stub!(:register_exit_hook) - end - - def create_options(args=[]) - Spec::Runner::OptionParser.parse(args, StringIO.new, StringIO.new) - end - - it 'should wire up a singleton StoryRunner' do - @runner_module.story_runner.should_not be_nil - end - - it 'should set its options based on ARGV' do - # given - @runner_module.should_receive(:run_options).and_return( - create_options(['--dry-run']) - ) - - # when - options = @runner_module.run_options - - # then - options.dry_run.should be_true - end - - describe "initialization" do - - before(:each) do - # given - @story_runner = mock('story runner', :null_object => true) - @scenario_runner = mock('scenario runner', :null_object => true) - @world_creator = mock('world', :null_object => true) - - @runner_module.stub!(:world_creator).and_return(@world_creator) - @runner_module.stub!(:create_story_runner).and_return(@story_runner) - @runner_module.stub!(:scenario_runner).and_return(@scenario_runner) - end - - it 'should add a reporter to the runner classes' do - @runner_module.should_receive(:run_options).and_return( - create_options - ) - - # expect - @world_creator.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter)) - @story_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter)) - @scenario_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter)) - - # when - @runner_module.story_runner - end - - it 'should add a documenter to the runner classes if one is specified' do - - @runner_module.should_receive(:run_options).and_return( - create_options(["--format","html"]) - ) - - # expect - @world_creator.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter)) - @story_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter)) - @scenario_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter)) - - # when - @runner_module.story_runner - end - - it 'should add any registered listener to the runner classes' do - # given - listener = Object.new - - # expect - @world_creator.should_receive(:add_listener).with(listener) - @story_runner.should_receive(:add_listener).with(listener) - @scenario_runner.should_receive(:add_listener).with(listener) - - # when - @runner_module.register_listener listener - end - end - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/story/scenario_spec.rb b/vendor/plugins/rspec/spec/spec/story/scenario_spec.rb deleted file mode 100644 index 0cf7aff30..000000000 --- a/vendor/plugins/rspec/spec/spec/story/scenario_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require File.dirname(__FILE__) + '/story_helper' - -module Spec - module Story - describe Scenario do - it 'should not raise an error if no body is supplied' do - # given - story = StoryBuilder.new.to_story - - # when - error = exception_from do - Scenario.new story, 'name' - end - - # then - error.should be_nil - end - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/story/step_group_spec.rb b/vendor/plugins/rspec/spec/spec/story/step_group_spec.rb deleted file mode 100644 index dd28bfa26..000000000 --- a/vendor/plugins/rspec/spec/spec/story/step_group_spec.rb +++ /dev/null @@ -1,157 +0,0 @@ -require File.dirname(__FILE__) + '/story_helper' - -module Spec - module Story - describe StepGroup do - before(:each) do - @step_group = StepGroup.new - end - - it "should not find a matcher if empty" do - @step_group.find(:given, "this and that").should be_nil - end - - it "should create a given_scenario matcher" do - step = @step_group.given_scenario("this and that") {} - @step_group.find(:given_scenario, "this and that").should_not be_nil - @step_group.find(:given_scenario, "this and that").should equal(step) - end - - it "should create a given matcher" do - step = @step_group.given("this and that") {} - @step_group.find(:given, "this and that").should equal(step) - end - - it "should create a when matcher" do - step = @step_group.when("this and that") {} - @step_group.find(:when, "this and that").should equal(step) - end - - it "should create a them matcher" do - step = @step_group.then("this and that") {} - @step_group.find(:then, "this and that").should equal(step) - end - - it "should add a matcher object" do - step = Step.new("this and that") {} - @step_group.add(:given, step) - @step_group.find(:given, "this and that").should equal(step) - end - - it "should add it matchers to another StepGroup (with one given)" do - source = StepGroup.new - target = StepGroup.new - step = source.given("this and that") {} - source.add_to target - target.find(:given, "this and that").should equal(step) - end - - it "should add it matchers to another StepGroup (with some of each type)" do - source = StepGroup.new - target = StepGroup.new - given_scenario = source.given_scenario("1") {} - given = source.given("1") {} - when1 = source.when("1") {} - when2 = source.when("2") {} - then1 = source.then("1") {} - then2 = source.then("2") {} - then3 = source.then("3") {} - source.add_to target - target.find(:given_scenario, "1").should equal(given_scenario) - target.find(:given, "1").should equal(given) - target.find(:when, "1").should equal(when1) - target.find(:when, "2").should equal(when2) - target.find(:then, "1").should equal(then1) - target.find(:then, "2").should equal(then2) - target.find(:then, "3").should equal(then3) - end - - it "should append another collection" do - matchers_to_append = StepGroup.new - step = matchers_to_append.given("this and that") {} - @step_group << matchers_to_append - @step_group.find(:given, "this and that").should equal(step) - end - - it "should append several other collections" do - matchers_to_append = StepGroup.new - more_matchers_to_append = StepGroup.new - first_matcher = matchers_to_append.given("this and that") {} - second_matcher = more_matchers_to_append.given("and the other") {} - @step_group << matchers_to_append - @step_group << more_matchers_to_append - @step_group.find(:given, "this and that").should equal(first_matcher) - @step_group.find(:given, "and the other").should equal(second_matcher) - end - - it "should yield itself on initialization" do - begin - $step_group_spec_step = nil - matchers = StepGroup.new do |matchers| - $step_group_spec_step = matchers.given("foo") {} - end - $step_group_spec_step.matches?("foo").should be_true - ensure - $step_group_spec_step = nil - end - end - - it "should support defaults" do - class StepGroupSubclass < StepGroup - steps do |add| - add.given("foo") {} - end - end - StepGroupSubclass.new.find(:given, "foo").should_not be_nil - end - - it "should create a Given" do - sub = Class.new(StepGroup).new - step = sub.Given("foo") {} - sub.find(:given, "foo").should == step - end - - it "should create a When" do - sub = Class.new(StepGroup).new - step = sub.When("foo") {} - sub.find(:when, "foo").should == step - end - - it "should create a Then" do - sub = Class.new(StepGroup).new - step = sub.Then("foo") {} - sub.find(:then, "foo").should == step - end - - it "should create steps in a block" do - sub = Class.new(StepGroup).new do - Given("a given") {} - When("a when") {} - Then("a then") {} - end - sub.find(:given, "a given").should_not be_nil - sub.find(:when, "a when").should_not be_nil - sub.find(:then, "a then").should_not be_nil - end - - it "should clear itself" do - step = @step_group.given("this and that") {} - @step_group.clear - @step_group.find(:given, "this and that").should be_nil - end - - it "should tell you when it is empty" do - @step_group.should be_empty - end - - it "should tell you when it is not empty" do - @step_group.given("this and that") {} - @step_group.should_not be_empty - end - - it "should handle << nil" do - @step_group << nil - end - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/story/step_mother_spec.rb b/vendor/plugins/rspec/spec/spec/story/step_mother_spec.rb deleted file mode 100644 index 64efd7a6a..000000000 --- a/vendor/plugins/rspec/spec/spec/story/step_mother_spec.rb +++ /dev/null @@ -1,72 +0,0 @@ -require File.dirname(__FILE__) + '/story_helper' - -module Spec - module Story - describe StepMother do - it 'should store a step by name and type' do - # given - step_mother = StepMother.new - step = Step.new("a given", &lambda {}) - step_mother.store(:given, step) - - # when - found = step_mother.find(:given, "a given") - - # then - found.should == step - end - - it 'should NOT raise an error if a step is missing' do - # given - step_mother = StepMother.new - - # then - lambda do - # when - step_mother.find(:given, "doesn't exist") - end.should_not raise_error - end - - it "should create a default step which raises a pending error" do - # given - step_mother = StepMother.new - - # when - step = step_mother.find(:given, "doesn't exist") - - # then - step.should be_an_instance_of(Step) - - lambda do - step.perform(Object.new, "doesn't exist") - end.should raise_error(Spec::Example::ExamplePendingError, /Unimplemented/) - end - - it 'should clear itself' do - # given - step_mother = StepMother.new - step = Step.new("a given") do end - step_mother.store(:given, step) - - # when - step_mother.clear - - # then - step_mother.should be_empty - end - - it "should use assigned steps" do - step_mother = StepMother.new - - step = Step.new('step') {} - step_group = StepGroup.new - step_group.add(:given, step) - - step_mother.use(step_group) - - step_mother.find(:given, "step").should equal(step) - end - - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/story/step_spec.rb b/vendor/plugins/rspec/spec/spec/story/step_spec.rb deleted file mode 100644 index 2b523607a..000000000 --- a/vendor/plugins/rspec/spec/spec/story/step_spec.rb +++ /dev/null @@ -1,219 +0,0 @@ -require File.dirname(__FILE__) + '/story_helper' - -module Spec - module Story - describe Step, "matching" do - it "should match a text string" do - step = Step.new("this text") {} - step.matches?("this text").should be_true - end - - it "should not match a text string that does not start the same" do - step = Step.new("this text") {} - step.matches?("Xthis text").should be_false - end - - it "should not match a text string that does not end the same" do - step = Step.new("this text") {} - step.matches?("this textX").should be_false - end - - it "should match a text string with a param" do - step = Step.new("this $param text") {} - step.matches?("this anything text").should be_true - end - - it "should not be greedy" do - step = Step.new("enter $value for $key") {} - step.parse_args("enter 3 for keys for a piano").should == ['3','keys for a piano'] - end - - it "should match a text string with 3 params" do - step = Step.new("1 $one 2 $two 3 $three 4") {} - step.matches?("1 a 2 b 3 c 4").should be_true - end - - it "should match a text string with a param at the beginning" do - step = Step.new("$one 2 3") {} - step.matches?("a 2 3").should be_true - end - - it "should match a text string with a param at the end" do - step = Step.new("1 2 $three") {} - step.matches?("1 2 c").should be_true - end - - it "should match a text string with a dollar sign ($)" do - step = Step.new("show me the $$money") {} - step.matches?("show me the $kwan").should be_true - end - - it "should match a string with an escaped dollar sign" do - step = Step.new("show me the \$money") {} - step.matches?("show me the $kwan").should be_true - end - - it "should not match a different string" do - step = Step.new("this text") {} - step.matches?("other text").should be_false - end - - it "should match a regexp" do - step = Step.new(/this text/) {} - step.matches?("this text").should be_true - end - - it "should match a regexp with a match group" do - step = Step.new(/this (.*) text/) {} - step.matches?("this anything text").should be_true - end - - it "should match a regexp with a named variable" do - step = Step.new(/this $variable text/) {} - step.matches?("this anything text").should be_true - end - - it "should not match a non matching regexp" do - step = Step.new(/this (.*) text/) {} - step.matches?("other anything text").should be_false - end - - it "should not match a non matching regexp with a named variable" do - step = Step.new(/this $variable text/) {} - step.matches?("other anything text").should be_false - end - - it "should not get bogged down by parens in strings" do - step = Step.new("before () after") {} - step.matches?("before () after").should be_true - end - - it "should match any option of an alteration" do - step = Step.new(/(he|she) is cool/) {} - step.matches?("he is cool").should be_true - step.matches?("she is cool").should be_true - end - - it "should match alteration as well as a variable" do - step = Step.new(/(he|she) is (.*)/) {} - step.matches?("he is cool").should be_true - step.parse_args("he is cool").should == ['he', 'cool'] - end - - it "should match alteration as well as a named variable" do - step = Step.new(/(he|she) is $adjective/) {} - step.matches?("he is cool").should be_true - step.parse_args("he is cool").should == ['he', 'cool'] - end - - it "should match alteration as well as a anonymous and named variable" do - step = Step.new(/(he|she) is (.*?) $adjective/) {} - step.matches?("he is very cool").should be_true - step.parse_args("he is very cool").should == ['he', 'very', 'cool'] - end - - it "should match a regex with a dollar sign ($)" do - step = Step.new(/show me the \$\d+/) {} - step.matches?("show me the $123").should be_true - end - - it "should match a regex with a dollar sign and named variable" do - step = Step.new(/show me the \$$money/) {} - step.matches?("show me the $123").should be_true - end - end - - describe Step do - it "should make complain with no block" do - lambda { - step = Step.new("foo") - }.should raise_error - end - - it "should perform itself on an object" do - # given - $instance = nil - step = Step.new 'step' do - $instance = self - end - instance = Object.new - - # when - step.perform(instance, "step") - - # then - $instance.should == instance - end - - it "should perform itself with one parameter with match expression" do - # given - $result = nil - step = Step.new 'an account with $count dollars' do |count| - $result = count - end - instance = Object.new - - # when - args = step.parse_args("an account with 3 dollars") - step.perform(instance, *args) - - # then - $result.should == "3" - end - - it "should perform itself with one parameter without a match expression" do - # given - $result = nil - step = Step.new 'an account with a balance of' do |amount| - $result = amount - end - instance = Object.new - - # when - step.perform(instance, 20) - - # then - $result.should == 20 - end - - it "should perform itself with 2 parameters" do - # given - $account_type = nil - $amount = nil - step = Step.new 'a $account_type account with $amount dollars' do |account_type, amount| - $account_type = account_type - $amount = amount - end - instance = Object.new - - # when - args = step.parse_args("a savings account with 3 dollars") - step.perform(instance, *args) - - # then - $account_type.should == "savings" - $amount.should == "3" - end - - it "should perform itself when defined with a regexp with 2 parameters" do - # given - $pronoun = nil - $adjective = nil - step = Step.new /(he|she) is (.*)/ do |pronoun, adjective| - $pronoun = pronoun - $adjective = adjective - end - instance = Object.new - - # when - args = step.parse_args("he is cool") - step.perform(instance, *args) - - # then - $pronoun.should == "he" - $adjective.should == "cool" - end - - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/story/story_helper.rb b/vendor/plugins/rspec/spec/spec/story/story_helper.rb deleted file mode 100644 index bb906f255..000000000 --- a/vendor/plugins/rspec/spec/spec/story/story_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -require File.dirname(__FILE__) + '/../../spec_helper' -require File.dirname(__FILE__) + '/builders' diff --git a/vendor/plugins/rspec/spec/spec/story/story_spec.rb b/vendor/plugins/rspec/spec/spec/story/story_spec.rb deleted file mode 100644 index f6bce544f..000000000 --- a/vendor/plugins/rspec/spec/spec/story/story_spec.rb +++ /dev/null @@ -1,86 +0,0 @@ -require File.dirname(__FILE__) + '/story_helper' - -module Spec - module Story - describe Story do - it 'should run itself in a given object' do - # given - $instance = nil - story = Story.new 'title', 'narrative' do - $instance = self - end - object = Object.new - - # when - story.run_in(object) - - # then - $instance.should be(object) - end - - it 'should not raise an error if no block is supplied' do - # when - error = exception_from do - Story.new 'title', 'narrative' - end - - # then - error.should be_nil - end - - it "should raise an error when an error is raised running in another object" do - #given - story = Story.new 'title', 'narrative' do - raise "this is raised in the story" - end - object = Object.new - - # when/then - lambda do - story.run_in(object) - end.should raise_error - end - - it "should use the steps it is told to using a StepGroup" do - story = Story.new("title", "narrative", :steps_for => steps = StepGroup.new) do end - assignee = mock("assignee") - assignee.should_receive(:use).with(steps) - story.assign_steps_to(assignee) - end - - it "should use the steps it is told to using a key" do - begin - orig_rspec_story_steps = $rspec_story_steps - $rspec_story_steps = StepGroupHash.new - $rspec_story_steps[:foo] = steps = Object.new - - story = Story.new("title", "narrative", :steps_for => :foo) do end - assignee = mock("assignee") - - assignee.should_receive(:use).with(steps) - story.assign_steps_to(assignee) - ensure - $rspec_story_steps = orig_rspec_story_steps - end - end - - it "should use the steps it is told to using multiple keys" do - begin - orig_rspec_story_steps = $rspec_story_steps - $rspec_story_steps = StepGroupHash.new - $rspec_story_steps[:foo] = foo_steps = Object.new - $rspec_story_steps[:bar] = bar_steps = Object.new - - story = Story.new("title", "narrative", :steps_for => [:foo, :bar]) do end - assignee = mock("assignee") - - assignee.should_receive(:use).with(foo_steps) - assignee.should_receive(:use).with(bar_steps) - story.assign_steps_to(assignee) - ensure - $rspec_story_steps = orig_rspec_story_steps - end - end - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/story/world_spec.rb b/vendor/plugins/rspec/spec/spec/story/world_spec.rb deleted file mode 100644 index f5113dc42..000000000 --- a/vendor/plugins/rspec/spec/spec/story/world_spec.rb +++ /dev/null @@ -1,423 +0,0 @@ -require File.dirname(__FILE__) + '/story_helper' - -require 'spec/story' - -module Spec - module Story - describe World do - before :each do - World.listeners.clear - end - - after :each do - World.listeners.clear - World.step_mother.clear - end - - it 'should create an object that mixes in a World' do - # when - obj = World::create - - # then - obj.should be_kind_of(World) - end - - it 'should create a World from any object type' do - # when - obj = World::create String - - # then - obj.should be_kind_of(String) - obj.should be_kind_of(World) - end - - it 'should pass arguments to #new when creating an object of a specified type that mixes in a world' do - # given - Thing = Struct.new(:name, :age) - - # when - obj = World::create Thing, "David", "I'm not telling" - - # then - obj.should be_an_instance_of(Thing) - obj.name.should == "David" - obj.age.should == "I'm not telling" - obj.should be_kind_of(World) - end - - def ensure_world_executes_step(&block) - # given - obj = World::create - $step_ran = false - - # when - obj.instance_eval(&block) - - # then - $step_ran.should be_true - end - - it 'should execute a Given, When or Then step' do - ensure_world_executes_step do - Given 'a given' do - $step_ran = true - end - end - - ensure_world_executes_step do - When 'an event' do - $step_ran = true - end - end - - ensure_world_executes_step do - Then 'an outcome' do - $step_ran = true - end - end - end - - it 'should interpret Given... And... as multiple givens' do - # given - world = World.create - $steps = [] - - # when - world.instance_eval do - Given 'step 1' do - $steps << 1 - end - And 'step 2' do - $steps << 2 - end - end - - # then - $steps.should == [1,2] - World.step_mother.find(:given, 'step 1').should_not be_nil - World.step_mother.find(:given, 'step 2').should_not be_nil - end - - it 'should interpret When... And... as multiple events' do - # given - world = World.create - $steps = [] - - # when - world.instance_eval do - When 'step 1' do - $steps << 1 - end - And 'step 2' do - $steps << 2 - end - end - - # then - $steps.should == [1,2] - World.step_mother.find(:when, 'step 1').should_not be_nil - World.step_mother.find(:when, 'step 2').should_not be_nil - end - - it 'should interpret Then... And... as multiple outcomes' do - # given - world = World.create - $steps = [] - - # when - world.instance_eval do - Then 'step 1' do - $steps << 1 - end - And 'step 2' do - $steps << 2 - end - end - - # then - $steps.should == [1,2] - World.step_mother.find(:then, 'step 1').should_not be_nil - World.step_mother.find(:then, 'step 2').should_not be_nil - end - - it 'should reuse a given across scenarios' do - # given - $num_invoked = 0 - a_world = World::create - a_world.instance_eval do - Given 'a given' do - $num_invoked += 1 - end - end - another_world = World::create - - # when - another_world.instance_eval do - Given 'a given' # without a body - end - - # then - $num_invoked.should == 2 - end - - it 'should reuse an event across scenarios' do - # given - $num_invoked = 0 - a_world = World::create - a_world.instance_eval do - When 'an event' do - $num_invoked += 1 - end - end - - another_world = World::create - - # when - another_world.instance_eval do - When 'an event' # without a body - end - - # then - $num_invoked.should == 2 - end - - it 'should reuse an outcome across scenarios' do - # given - $num_invoked = 0 - a_world = World::create - a_world.instance_eval do - Then 'an outcome' do - $num_invoked += 1 - end - end - - another_world = World::create - - # when - another_world.instance_eval do - Then 'an outcome' # without a body - end - - # then - $num_invoked.should == 2 - end - - it 'should preserve instance variables between steps within a scenario' do - # given - world = World::create - $first = nil - $second = nil - - # when - world.instance_eval do - Given 'given' do - @first = 'first' - end - When 'event' do - @second = @first # from given - end - Then 'outcome' do - $first = @first # from given - $second = @second # from event - end - end - - # then - $first.should == 'first' - $second.should == 'first' - end - - it 'should invoke a reused step in the new object instance' do - # given - $instances = [] - $debug = true - world1 = World.create - world1.instance_eval do - Given 'a given' do - $instances << self.__id__ - end - end - world2 = World.create - - # when - world2.instance_eval do - Given 'a given' # reused - Then 'an outcome' do - $instances << __id__ - end - end - $debug = false - # then - $instances.should == [ world1.__id__, world2.__id__, world2.__id__ ] - end - - def ensure_world_collects_error(expected_error, &block) - # given - world = World.create - # $error = nil - - # when - world.start_collecting_errors - world.instance_eval(&block) - - # then - world.should have(1).errors - world.errors[0].should be_kind_of(expected_error) - end - - it 'should collect a failure from a Given step' do - ensure_world_collects_error RuntimeError do - Given 'a given' do - raise RuntimeError, "oops" - end - end - end - - it 'should collect a failure from a When step' do - ensure_world_collects_error RuntimeError do - When 'an event' do - raise RuntimeError, "oops" - end - end - end - - it 'should collect a failure from a Then step' do - ensure_world_collects_error RuntimeError do - Then 'an outcome' do - raise RuntimeError, "oops" - end - end - end - - it 'should inform listeners when it runs a Given, When or Then step' do - # given - world = World.create - mock_listener1 = mock('listener1') - mock_listener2 = mock('listener2') - World.add_listener(mock_listener1) - World.add_listener(mock_listener2) - - # expect - mock_listener1.should_receive(:step_upcoming).with(:given, 'a context') - mock_listener1.should_receive(:step_succeeded).with(:given, 'a context') - mock_listener1.should_receive(:step_upcoming).with(:when, 'an event') - mock_listener1.should_receive(:step_succeeded).with(:when, 'an event') - mock_listener1.should_receive(:step_upcoming).with(:then, 'an outcome') - mock_listener1.should_receive(:step_succeeded).with(:then, 'an outcome') - - mock_listener2.should_receive(:step_upcoming).with(:given, 'a context') - mock_listener2.should_receive(:step_succeeded).with(:given, 'a context') - mock_listener2.should_receive(:step_upcoming).with(:when, 'an event') - mock_listener2.should_receive(:step_succeeded).with(:when, 'an event') - mock_listener2.should_receive(:step_upcoming).with(:then, 'an outcome') - mock_listener2.should_receive(:step_succeeded).with(:then, 'an outcome') - - # when - world.instance_eval do - Given 'a context' do end - When 'an event' do end - Then 'an outcome' do end - end - - # then - end - - it 'should tell listeners but not execute the step in dry-run mode' do - # given - Runner.stub!(:dry_run).and_return(true) - mock_listener = mock('listener') - World.add_listener(mock_listener) - $step_invoked = false - world = World.create - - # expect - mock_listener.should_receive(:step_upcoming).with(:given, 'a context') - mock_listener.should_receive(:step_succeeded).with(:given, 'a context') - - # when - world.instance_eval do - Given 'a context' do - $step_invoked = true - end - end - - # then - $step_invoked.should be(false) - end - - it 'should suppress listeners while it runs a GivenScenario' do - # given - $scenario_ran = false - - scenario = ScenarioBuilder.new.name('a scenario').to_scenario do - $scenario_ran = true - Given 'given' do end - When 'event' do end - Then 'outcome' do end - end - - given_scenario = GivenScenario.new('a scenario') - Runner::StoryRunner.should_receive(:scenario_from_current_story). - with('a scenario').and_return(scenario) - - world = World.create - listener = mock('listener') - World.add_listener(listener) - - # expect - listener.should_receive(:found_scenario).with(:'given scenario', 'a scenario') - listener.should_receive(:step_succeeded).never.with(:given, 'given') - listener.should_receive(:step_succeeded).never.with(:when, 'event') - listener.should_receive(:step_succeeded).never.with(:then, 'outcome') - - # when - world.GivenScenario 'a scenario' - - # then - $scenario_ran.should be_true - end - - it 'should interpret GivenScenario... And... as multiple givens' do - # given - world = World.create - $steps = [] - - scenario = ScenarioBuilder.new.name('a scenario').to_scenario do - $steps << 1 - end - Runner::StoryRunner.should_receive(:scenario_from_current_story). - with('a scenario').and_return(scenario) - - # when - world.instance_eval do - GivenScenario 'a scenario' - And 'step 2' do - $steps << 2 - end - end - - # then - $steps.should == [1,2] - World.step_mother.find(:given, 'step 2').should_not be_nil - end - - it 'should provide rspec matchers' do - # given - world = World.create - - # then - world.instance_eval do - 'hello'.should match(/^hello$/) - end - end - - it "should use assigned matchers" do - world = World.create - - World.should_receive(:use).with(steps = Object.new) - - World.use(steps) - end - end - end -end diff --git a/vendor/plugins/rspec/spec/spec/translator_spec.rb b/vendor/plugins/rspec/spec/spec/translator_spec.rb deleted file mode 100644 index 01293d9ee..000000000 --- a/vendor/plugins/rspec/spec/spec/translator_spec.rb +++ /dev/null @@ -1,265 +0,0 @@ -require File.dirname(__FILE__) + '/../spec_helper.rb' -require 'spec/translator' - -describe "Translator" do - before do - @t = Spec::Translator.new - end - - it "should translate files" do - from = File.dirname(__FILE__) + '/..' - to = "#{Dir.tmpdir}/translated_specs" - @t.translate_dir(from, to) - end - - it "should translate context_setup do" do - @t.translate_line( - "context_setup do\n" - ).should eql( - "before(:all) do\n" - ) - end - - it "should translate context_setup {foo}" do - @t.translate_line( - "context_setup {foo}\n" - ).should eql( - "before(:all) {foo}\n" - ) - end - - it "should translate context ' to describe '" do - @t.translate_line( - "context 'Translator' do\n" - ).should eql( - "describe 'Translator' do\n" - ) - end - - it 'should translate context " to describe "' do - @t.translate_line( - 'context "Translator"' - ).should eql( - 'describe "Translator"' - ) - end - - it 'should translate spaces then context " to describe "' do - @t.translate_line( - ' context "Translator"' - ).should eql( - ' describe "Translator"' - ) - end - - it "should not translate context=foo" do - @t.translate_line(' context=foo').should eql(' context=foo') - end - - it "should not translate context = foo" do - @t.translate_line(' context = foo').should eql(' context = foo') - end - - it "should not translate context = foo" do - @t.translate_line(' context = foo').should eql(' context = foo') - end - - it "should translate should_be_close" do - @t.translate_line('5.0.should_be_close(5.0, 0.5)').should eql('5.0.should be_close(5.0, 0.5)') - end - - it "should translate should_not_raise" do - @t.translate_line('lambda { self.call }.should_not_raise').should eql('lambda { self.call }.should_not raise_error') - end - - it "should translate should_throw" do - @t.translate_line('lambda { self.call }.should_throw').should eql('lambda { self.call }.should throw_symbol') - end - - it "should not translate 0.9 should_not" do - @t.translate_line('@target.should_not @matcher').should eql('@target.should_not @matcher') - end - - it "should leave should_not_receive" do - @t.translate_line('@mock.should_not_receive(:not_expected).with("unexpected text")').should eql('@mock.should_not_receive(:not_expected).with("unexpected text")') - end - - it "should leave should_receive" do - @t.translate_line('@mock.should_receive(:not_expected).with("unexpected text")').should eql('@mock.should_receive(:not_expected).with("unexpected text")') - end - - it "should translate multi word predicates" do - @t.translate_line('foo.should_multi_word_predicate').should eql('foo.should be_multi_word_predicate') - end - - it "should translate multi word predicates prefixed with be" do - @t.translate_line('foo.should_be_multi_word_predicate').should eql('foo.should be_multi_word_predicate') - end - - it "should translate be(expected) to equal(expected)" do - @t.translate_line('foo.should_be :cool').should eql('foo.should equal :cool') - end - - it "should translate instance_of" do - @t.translate_line('5.should_be_an_instance_of(Integer)').should eql('5.should be_an_instance_of(Integer)') - end - - it "should translate should_be <" do - @t.translate_line('3.should_be < 4').should eql('3.should be < 4') - end - - it "should translate should_be <=" do - @t.translate_line('3.should_be <= 4').should eql('3.should be <= 4') - end - - it "should translate should_be >=" do - @t.translate_line('4.should_be >= 3').should eql('4.should be >= 3') - end - - it "should translate should_be >" do - @t.translate_line('4.should_be > 3').should eql('4.should be > 3') - end - - it "should translate should_be_happy" do - @t.translate_line("4.should_be_happy").should eql("4.should be_happy") - end - - it "should translate custom method taking regexp with parenthesis" do - @t.translate_line("@browser.should_contain_text(/Sn.rrunger og annet rusk/)").should eql("@browser.should be_contain_text(/Sn.rrunger og annet rusk/)") - end - - it "should translate custom method taking regexp without parenthesis" do - @t.translate_line("@browser.should_contain_text /Sn.rrunger og annet rusk/\n").should eql("@browser.should be_contain_text(/Sn.rrunger og annet rusk/)\n") - end - - it "should translate should_not_be_nil" do - @t.translate_line("foo.should_not_be_nil\n").should eql("foo.should_not be_nil\n") - end - - it "should translate kind of" do - @t.translate_line('@object.should_be_kind_of(MessageExpectation)').should( - eql('@object.should be_kind_of(MessageExpectation)')) - end - - it "should translate should_be_true" do - @t.translate_line("foo.should_be_true\n").should eql("foo.should be_true\n") - end - - # [#9674] spec_translate incorrectly handling shoud_match, when regexp in a var, in a block - # http://rubyforge.org/tracker/?func=detail&atid=3149&aid=9674&group_id=797 - it "should translate should_match on a regexp, in a var, in a block" do - @t.translate_line("collection.each { |c| c.should_match a_regexp_in_a_var }\n").should eql("collection.each { |c| c.should match(a_regexp_in_a_var) }\n") - @t.translate_line("collection.each{|c| c.should_match a_regexp_in_a_var}\n").should eql("collection.each{|c| c.should match(a_regexp_in_a_var) }\n") - end - - # From Rubinius specs - it "should translate close_to without parens" do - @t.translate_line("end.should_be_close 3.14159_26535_89793_23846, TOLERANCE\n").should eql("end.should be_close(3.14159_26535_89793_23846, TOLERANCE)\n") - end - - # [#9882] 0.9 Beta 1 - translator bugs - # http://rubyforge.org/tracker/index.php?func=detail&aid=9882&group_id=797&atid=3149 - it "should support symbol arguments" do - @t.translate_line( - "lambda { sequence.parse('bar') }.should_throw :ZeroWidthParseSuccess\n" - ).should eql( - "lambda { sequence.parse('bar') }.should throw_symbol(:ZeroWidthParseSuccess)\n" - ) - end - - # [#9882] 0.9 Beta 1 - translator bugs - # http://rubyforge.org/tracker/index.php?func=detail&aid=9882&group_id=797&atid=3149 - it "should support instance var arguments" do - @t.translate_line( - "a.should_eql @local" - ).should eql( - "a.should eql(@local)" - ) - end - - # [#9882] 0.9 Beta 1 - translator bugs - # http://rubyforge.org/tracker/index.php?func=detail&aid=9882&group_id=797&atid=3149 - it "should support lambdas as expecteds" do - @t.translate_line( - "@parslet.should_not_eql lambda { nil }.to_parseable" - ).should eql( - "@parslet.should_not eql(lambda { nil }.to_parseable)" - ) - end - - # [#9882] 0.9 Beta 1 - translator bugs - # http://rubyforge.org/tracker/index.php?func=detail&aid=9882&group_id=797&atid=3149 - it "should support fully qualified names" do - @t.translate_line( - "results.should_be_kind_of SimpleASTLanguage::Identifier" - ).should eql( - "results.should be_kind_of(SimpleASTLanguage::Identifier)" - ) - end - - # [#9882] 0.9 Beta 1 - translator bugs - # http://rubyforge.org/tracker/index.php?func=detail&aid=9882&group_id=797&atid=3149 - # it "should leave whitespace between expression and comments" do - # @t.translate_line( - # "lambda { @instance.foo = foo }.should_raise NoMethodError # no writer defined" - # ).should eql( - # "lambda { @instance.foo = foo }.should raise_error(NoMethodError) # no writer defined" - # ) - # end - - it "should translate redirects" do - @t.translate_line( - "controller.should_redirect_to 'http://not_existing_domain_for_novalis.test.host/404.html'" - ).should eql( - "controller.should redirect_to('http://not_existing_domain_for_novalis.test.host/404.html')" - ) - end - - it "should translate :any_args" do - @t.translate_line( - "mock.should_receive(:foo).with(:any_args)" - ).should eql( - "mock.should_receive(:foo).with(any_args)" - ) - end - - it "should translate :anything" do - @t.translate_line( - "mock.should_receive(:foo).with(:anything)" - ).should eql( - "mock.should_receive(:foo).with(anything)" - ) - end - - it "should translate :boolean" do - @t.translate_line( - "mock.should_receive(:foo).with(:boolean)" - ).should eql( - "mock.should_receive(:foo).with(boolean)" - ) - end - - it "should translate :no_args" do - @t.translate_line( - "mock.should_receive(:foo).with(:no_args)" - ).should eql( - "mock.should_receive(:foo).with(no_args)" - ) - end - - it "should translate :numeric" do - @t.translate_line( - "mock.should_receive(:foo).with(:numeric)" - ).should eql( - "mock.should_receive(:foo).with(an_instance_of(Numeric))" - ) - end - - it "should translate :string" do - @t.translate_line( - "mock.should_receive(:foo).with(:string)" - ).should eql( - "mock.should_receive(:foo).with(an_instance_of(String))" - ) - end -end diff --git a/vendor/plugins/rspec/spec/spec_helper.rb b/vendor/plugins/rspec/spec/spec_helper.rb index 1318176d5..3cffe875d 100644 --- a/vendor/plugins/rspec/spec/spec_helper.rb +++ b/vendor/plugins/rspec/spec/spec_helper.rb @@ -1,18 +1,24 @@ require 'stringio' -dir = File.dirname(__FILE__) -lib_path = File.expand_path("#{dir}/../lib") -$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path) $_spec_spec = true # Prevents Kernel.exit in various places require 'spec' require 'spec/mocks' -require 'spec/story' -spec_classes_path = File.expand_path("#{dir}/../spec/spec/spec_classes") -require spec_classes_path unless $LOAD_PATH.include?(spec_classes_path) -require File.dirname(__FILE__) + '/../lib/spec/expectations/differs/default' +require 'spec/runner/differs/default' +require 'spec/autorun' + +require 'support/spec_classes' +require 'support/macros' + +def jruby? + ::RUBY_PLATFORM == 'java' +end + +module Spec + module Example + class NonStandardError < Exception; end + end -module Spec module Matchers def fail raise_error(Spec::Expectations::ExpectationNotMetError) @@ -22,82 +28,85 @@ module Spec raise_error(Spec::Expectations::ExpectationNotMetError, message) end - class Pass - def matches?(proc, &block) - begin - proc.call - true - rescue Exception => @error - false - end - end - - def failure_message - @error.message + "\n" + @error.backtrace.join("\n") + def exception_from(&block) + exception = nil + begin + yield + rescue StandardError => e + exception = e end - end - - def pass - Pass.new + exception end - class CorrectlyOrderedMockExpectation - def initialize(&event) - @event = event - end - - def expect(&expectations) - expectations.call - @event.call - end - end - - def during(&block) - CorrectlyOrderedMockExpectation.new(&block) - end - end -end - -class NonStandardError < Exception; end - -module Custom - class ExampleGroupRunner - attr_reader :options, :arg - def initialize(options, arg) - @options, @arg = options, arg + def run_with(options) + ::Spec::Runner::CommandLine.run(options) end - def load_files(files) + def with_ruby(version) + yield if RUBY_VERSION =~ Regexp.compile("^#{version.to_s}") end - - def run - end - end -end - -def exception_from(&block) - exception = nil - begin - yield - rescue StandardError => e - exception = e end - exception end -describe "sandboxed rspec_options", :shared => true do +def with_sandboxed_options attr_reader :options + + before(:each) do + @original_rspec_options = ::Spec::Runner.options + ::Spec::Runner.use(@options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new)) + end - before(:all) do - @original_rspec_options = $rspec_options + after(:each) do + ::Spec::Runner.use(@original_rspec_options) end + + yield +end +def with_sandboxed_config + attr_reader :config + before(:each) do - @options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new) - $rspec_options = options + @config = ::Spec::Runner::Configuration.new + @original_configuration = ::Spec::Runner.configuration + spec_configuration = @config + ::Spec::Runner.instance_eval {@configuration = spec_configuration} end + + after(:each) do + original_configuration = @original_configuration + ::Spec::Runner.instance_eval {@configuration = original_configuration} + ::Spec::Example::ExampleGroupFactory.reset + end + + yield +end - after do - $rspec_options = @original_rspec_options +module Spec + module Example + module Resettable + def reset # :nodoc: + @before_all_parts = nil + @after_all_parts = nil + @before_each_parts = nil + @after_each_parts = nil + end + end + class ExampleGroup + extend Resettable + end + class ExampleGroupDouble < ExampleGroup + ::Spec::Runner.options.remove_example_group self + def register_example_group(klass) + #ignore + end + def initialize(proxy=nil, &block) + super(proxy || ExampleProxy.new, &block) + end + end end +end + +Spec::Runner.configure do |config| + config.extend(Macros) end
\ No newline at end of file |