Permalink
Browse files

Cleanup whitespace.

  • Loading branch information...
1 parent a6365b0 commit cd196c5c791fa412c5bfd88a81a165efaabb8c21 @myronmarston myronmarston committed Oct 17, 2012
Showing with 40 additions and 40 deletions.
  1. +40 −40 spec/rspec/expectations/handler_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
module ExampleExpectations
-
+
class ArbitraryMatcher
def initialize(*args, &block)
if args.last.is_a? Hash
@@ -10,38 +10,38 @@ def initialize(*args, &block)
@expected = block.call if block
@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 RSpec
@@ -54,23 +54,23 @@ module Expectations
matcher.should_receive(:matches?).with(actual).and_return(true)
RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
end
-
+
it "returns the match value" do
matcher = mock("matcher")
actual = Object.new
matcher.should_receive(:matches?).with(actual).and_return(:this_value)
RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher).should == :this_value
end
-
+
it "calls failure_message_for_should if the matcher implements it" do
matcher = mock("matcher", :failure_message_for_should => "message", :matches? => false)
actual = Object.new
-
+
::RSpec::Expectations.should_receive(:fail_with).with("message")
-
+
RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
end
-
+
it "calls fail if matcher.diffable?" do
matcher = mock("matcher",
:diffable? => true,
@@ -80,28 +80,28 @@ module Expectations
:actual => 2
)
actual = Object.new
-
+
::RSpec::Expectations.should_receive(:fail_with).with("message", 1, 2)
-
+
RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
end
-
+
it "calls failure_message if the matcher does not implement failure_message_for_should" do
matcher = mock("matcher", :failure_message => "message", :matches? => false)
actual = Object.new
-
+
::RSpec::Expectations.should_receive(:fail_with).with("message")
-
+
RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
-
+
end
-
+
it "appends the :or message in the options hash passed to should" do
matcher = mock("matcher", :failure_message_for_should => "message", :matches? => false)
actual = Object.new
-
+
::RSpec::Expectations.should_receive(:fail_with).with("custom")
-
+
RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher, "custom")
end
end
@@ -123,7 +123,7 @@ module Expectations
matcher.should_receive(:matches?).with(actual).and_return(false)
RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
end
-
+
it "returns the match value" do
matcher = mock("matcher")
actual = Object.new
@@ -132,28 +132,28 @@ module Expectations
RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher).should be_false
end
-
+
it "calls failure_message_for_should_not if the matcher implements it" do
matcher = mock("matcher", :failure_message_for_should_not => "message", :matches? => true)
actual = Object.new
-
+
::RSpec::Expectations.should_receive(:fail_with).with("message")
-
+
RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
-
+
end
-
+
it "calls negative_failure_message if the matcher does not implement failure_message_for_should_not" do
matcher = mock("matcher", :negative_failure_message => "message", :matches? => true)
actual = Object.new
-
+
::RSpec::Expectations.should_receive(:fail_with).with("message")
-
+
RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
-
+
end
-
+
it "calls fail if matcher.diffable?" do
matcher = mock("matcher",
:diffable? => true,
@@ -163,27 +163,27 @@ module Expectations
:actual => 2
)
actual = Object.new
-
+
::RSpec::Expectations.should_receive(:fail_with).with("message", 1, 2)
-
+
RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
end
it "appends the :or message in the options hash passed to should" do
matcher = mock("matcher", :failure_message_for_should_not => "message", :matches? => true)
actual = Object.new
-
+
::RSpec::Expectations.should_receive(:fail_with).with("custom")
-
+
RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher, "custom")
end
end
end
-
+
describe PositiveExpectationHandler do
include ExampleExpectations
-
+
it "handles submitted args" do
5.should arbitrary_matcher(:expected => 5)
5.should arbitrary_matcher(:expected => "wrong").with(5)
@@ -200,7 +200,7 @@ module Expectations
5.should arbitrary_matcher(:expected => 4) { 5 }
5.should arbitrary_matcher(:expected => 4).with(5) { 3 }
end
-
+
end
end
end

0 comments on commit cd196c5

Please sign in to comment.