Class | Spec::Expectations::Should::Not |
In: |
lib/spec/expectations/should/not.rb
|
Parent: | Base |
# File lib/spec/expectations/should/not.rb, line 6 6: def initialize(target) 7: @target = target 8: @be_seen = false 9: end
# File lib/spec/expectations/should/not.rb, line 69 69: def __delegate_method_missing_to_target original_sym, actual_sym, *args 70: return unless @target.__send__(actual_sym, *args) 71: fail_with_message(default_message("should not#{@be_seen ? ' be' : ''} #{original_sym}" + (args.empty? ? '' : ' ' + args[0].inspect))) 72: end
# File lib/spec/expectations/should/not.rb, line 33 33: def a_kind_of expected_class 34: fail_with_message(default_message("should not be a kind of", expected_class)) if @target.kind_of? expected_class 35: end
# File lib/spec/expectations/should/not.rb, line 29 29: def an_instance_of expected_class 30: fail_with_message(default_message("should not be an instance of", expected_class)) if @target.instance_of? expected_class 31: end
# File lib/spec/expectations/should/not.rb, line 23 23: def be(expected = :no_arg) 24: @be_seen = true 25: return self if (expected == :no_arg) 26: fail_with_message(default_message("should not be", expected)) if (@target.equal?(expected)) 27: end
# File lib/spec/expectations/should/not.rb, line 15 15: def change(receiver, message) 16: NotChange.new(@target, receiver, message) 17: end
# File lib/spec/expectations/should/not.rb, line 11 11: def have(expected_number=nil) 12: NotHave.new(@target, :exactly, expected_number) 13: end
# File lib/spec/expectations/should/not.rb, line 41 41: def match(expected) 42: fail_with_message(default_message("should not match", expected)) if (@target =~ expected) 43: end
# File lib/spec/expectations/should/not.rb, line 45 45: def raise(exception=Exception, message=nil) 46: begin 47: @target.call 48: rescue exception => e 49: return unless message.nil? || e.message == message || (message.is_a?(Regexp) && e.message =~ message) 50: fail_with_message("#{default_message("should not raise", exception)}") if e.instance_of? exception 51: fail_with_message("#{default_message("should not raise", exception)} but raised #{e.inspect}") unless e.instance_of? exception 52: rescue 53: true 54: end 55: end
# File lib/spec/expectations/should/not.rb, line 37 37: def respond_to message 38: fail_with_message(default_message("should not respond to", message)) if @target.respond_to? message 39: end
# File lib/spec/expectations/should/not.rb, line 19 19: def satisfy 20: fail_with_message "Supplied expectation was satisfied, but should not have been" if (yield @target) 21: end
# File lib/spec/expectations/should/not.rb, line 57 57: def throw(symbol=:___this_is_a_symbol_that_will_likely_never_occur___) 58: begin 59: catch symbol do 60: @target.call 61: return true 62: end 63: fail_with_message(default_message("should not throw", symbol.inspect)) 64: rescue NameError 65: true 66: end 67: end