lib/surrogate/rspec.rb in surrogate-0.5.0 vs lib/surrogate/rspec.rb in surrogate-0.5.1

- old
+ new

@@ -1,7 +1,10 @@ # Maybe I should be my own gem? +require 'rspec/core' +require 'surrogate' + class Surrogate module RSpec class << self def rspec_mocks_loaded? return @mocks_loaded if @alrady_checked_mocks @@ -17,28 +20,53 @@ @mocks_loaded = bool end end module Matchers - def have_been_told_to(expected) - HaveBeenToldTo.new expected + def have_been_told_to(method_name) + HaveBeenToldTo.new method_name end - def have_been_asked_for_its(expected) - HaveBeenAskedForIts.new expected + def told_to(method_name) + HaveBeenToldTo.new method_name end + def have_been_asked_if(method_name) + HaveBeenAskedIf.new method_name + end + + def asked_if(method_name) + HaveBeenAskedIf.new method_name + end + + def have_been_asked_for_its(method_name) + HaveBeenAskedForIts.new method_name + end + + def asked_for(method_name) + HaveBeenAskedForIts.new method_name + end + def have_been_initialized_with(*initialization_args, &block) HaveBeenInitializedWith.new *initialization_args, &block end + + def initialized_with(*initialization_args, &block) + HaveBeenInitializedWith.new *initialization_args, &block + end end end + + Endower.add_hook do |klass| + klass.class_eval do + alias was should + alias was_not should_not + end + end end -require 'rspec/core' -require 'surrogate' require 'surrogate/rspec/substitute_for' - +require 'surrogate/rspec/have_been_asked_if' require 'surrogate/rspec/have_been_asked_for_its' require 'surrogate/rspec/have_been_initialized_with' require 'surrogate/rspec/have_been_told_to'