spec/acceptance_spec.rb in surrogate-0.6.1 vs spec/acceptance_spec.rb in surrogate-0.6.2

- old
+ new

@@ -105,16 +105,16 @@ # ===== raise errors ===== # pass the error as the return value, it will be raised when method is invoked error = StandardError.new("some message") user.will_add_phone_number error - expect { user.add_phone_number }.to raise_error StandardError, "some message" + expect { user.add_phone_number '312', '123-4567' }.to raise_error StandardError, "some message" # ===== Substitutability ===== # real user is not a suitable substitute if missing methods that mock user has - user_class.should_not substitute_for Class.new + Class.new.should_not substitute_for user_class # real user must have all of mock user's methods to be substitutable substitutable_real_user_class = Class.new do def self.find(id) end def initialize(id) end @@ -122,24 +122,24 @@ def name() end def address() end def phone_numbers() end def add_phone_number(area_code, number) end end - user_class.should substitute_for substitutable_real_user_class - user_class.should substitute_for substitutable_real_user_class, subset: true + substitutable_real_user_class.should substitute_for user_class + substitutable_real_user_class.should substitute_for user_class, subset: true # when real user class has extra methods, it is only substitutable as a subset real_user_class = substitutable_real_user_class.clone def real_user_class.some_class_meth() end - user_class.should_not substitute_for real_user_class + real_user_class.should_not substitute_for user_class real_user_class = substitutable_real_user_class.dup real_user_class.send(:define_method, :some_instance_method) {} - user_class.should_not substitute_for real_user_class - user_class.should substitute_for real_user_class, subset: true + real_user_class.should_not substitute_for user_class + real_user_class.should substitute_for user_class, subset: true # subset substitutability does not work for superset real_user_class = substitutable_real_user_class.dup real_user_class.send :undef_method, :address - user_class.should_not substitute_for real_user_class, subset: true + real_user_class.should_not substitute_for user_class, subset: true end end