X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/ddd5b4cf19a92582fd114914be5bd5a04d3522a7..3f607d565bc0e2c7b1b738301c11c16d069913d5:/vendor/gems/rspec-1.1.2/spec/spec/runner/heckle_runner_spec.rb?ds=sidebyside diff --git a/vendor/gems/rspec-1.1.2/spec/spec/runner/heckle_runner_spec.rb b/vendor/gems/rspec-1.1.2/spec/spec/runner/heckle_runner_spec.rb new file mode 100644 index 000000000..539d908c2 --- /dev/null +++ b/vendor/gems/rspec-1.1.2/spec/spec/runner/heckle_runner_spec.rb @@ -0,0 +1,78 @@ +require File.dirname(__FILE__) + '/../../spec_helper.rb' +unless [/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM} + require 'spec/runner/heckle_runner' + + module Foo + class Bar + def one; end + def two; end + end + + class Zap + def three; end + def four; end + end + end + + describe "HeckleRunner" do + before(:each) do + @heckle = mock("heckle", :null_object => true) + @heckle_class = mock("heckle_class") + 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_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_runner = Spec::Runner::HeckleRunner.new("Foo::Bar", @heckle_class) + heckle_runner.heckle_with + end + + it "should fail heckling when the class is not found" do + lambda do + heckle_runner = Spec::Runner::HeckleRunner.new("Foo::Bob", @heckle_class) + heckle_runner.heckle_with + end.should raise_error(StandardError, "Heckling failed - \"Foo::Bob\" is not a known class or module") + 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_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_runner = Spec::Runner::HeckleRunner.new("Foo::Bar.two", @heckle_class) + heckle_runner.heckle_with + end + end + + describe "Heckler" do + it "should say yes to tests_pass? if specs pass" do + options = mock("options", :null_object => true) + options.should_receive(:run_examples).and_return(true) + heckler = Spec::Runner::Heckler.new("Foo", nil, options) + heckler.tests_pass?.should be_true + end + + it "should say no to tests_pass? if specs fail" do + options = mock("options", :null_object => true) + options.should_receive(:run_examples).and_return(false) + heckler = Spec::Runner::Heckler.new("Foo", nil, options) + heckler.tests_pass?.should be_false + end + end +end