Class Spec::Expectations::Should::Should
In: lib/spec/expectations/should/should.rb
Parent: Base

Methods

Public Class methods

[Source]

   # File lib/spec/expectations/should/should.rb, line 6
6:         def initialize(target)
7:           @target = target
8:           @be_seen = false
9:         end

Public Instance methods

[Source]

    # File lib/spec/expectations/should/should.rb, line 46
46:         def __delegate_method_missing_to_target(original_sym, actual_sym, *args)
47:           return if @target.send(actual_sym, *args)
48:           message = default_message("should#{@be_seen ? ' be' : ''} #{original_sym}", args[0])
49:           fail_with_message(message)
50:         end

[Source]

    # File lib/spec/expectations/should/should.rb, line 38
38:         def a_kind_of(expected_class)
39:           fail_with_message(default_message("should be a kind of", expected_class)) unless @target.kind_of? expected_class
40:         end

[Source]

    # File lib/spec/expectations/should/should.rb, line 34
34:         def an_instance_of(expected_class)
35:           fail_with_message(default_message("should be an instance of", expected_class)) unless @target.instance_of? expected_class
36:         end

[Source]

    # File lib/spec/expectations/should/should.rb, line 28
28:         def be(expected = :___no_arg)
29:           @be_seen = true
30:           return self if (expected == :___no_arg)
31:           fail_with_message(default_message("should be", expected)) unless (@target.equal?(expected))
32:         end

[Source]

    # File lib/spec/expectations/should/should.rb, line 15
15:         def change(receiver=nil, message=nil, &block)
16:           Change.new(@target, receiver, message, &block)
17:         end

[Source]

    # File lib/spec/expectations/should/should.rb, line 11
11:         def have(expected_number=nil)
12:           Have.new(@target, :exactly, expected_number)
13:         end

[Source]

    # File lib/spec/expectations/should/should.rb, line 52
52:         def match(expected)
53:            fail_with_message(default_message("should match", expected)) unless (@target =~ expected)
54:         end

[Source]

    # File lib/spec/expectations/should/should.rb, line 19
19:         def not
20:           Not.new(@target)
21:         end

[Source]

    # File lib/spec/expectations/should/should.rb, line 56
56:         def raise(exception=Exception, message=nil)
57:           begin
58:             @target.call
59:           rescue exception => e
60:             unless message.nil?
61:               if message.is_a?(Regexp)
62:                 e.message.should =~ message
63:               else
64:                 e.message.should == message
65:               end
66:             end
67:             return
68:           rescue => e
69:             fail_with_message("#{default_message("should raise", exception)} but raised #{e.inspect}")
70:           end
71:           fail_with_message("#{default_message("should raise", exception)} but raised nothing")
72:         end

[Source]

    # File lib/spec/expectations/should/should.rb, line 42
42:         def respond_to(message)
43:           fail_with_message(default_message("should respond to", message)) unless @target.respond_to? message
44:         end

[Source]

    # File lib/spec/expectations/should/should.rb, line 23
23:         def satisfy
24:           return if yield(@target)
25:           fail_with_message "Supplied expectation was not satisfied"
26:         end

[Source]

    # File lib/spec/expectations/should/should.rb, line 74
74:         def throw(symbol)
75:           begin
76:             catch symbol do
77:               @target.call
78:               fail_with_message(default_message("should throw", symbol.inspect))
79:             end
80:           rescue NameError
81:             fail_with_message(default_message("should throw", symbol.inspect))
82:           end
83:         end

[Validate]