Class: Spec::Expectations::Helper::HandCodedMock

Inherits:
Object
  • Object
show all
Includes:
Matchers
Defined in:
lib/gems/rspec-1.1.11/spec/spec/spec_classes.rb

Instance Attribute Summary

Attributes included from Matchers::ModuleMethods

#last_matcher, #last_should

Instance Method Summary collapse

Methods included from Matchers

#be, #be_close, #change, #eql, #equal, #exception_from, #exist, #fail, #fail_with, #have, #have_at_least, #have_at_most, #include, #map_specs, #match, #method_missing, #raise_error, #respond_to, #run_with, #satisfy, #simple_matcher, #smart_match, #throw_symbol

Methods included from Matchers::ModuleMethods

#clear_generated_description, #generated_description

Constructor Details

#initialize(return_val) ⇒ HandCodedMock

Returns a new instance of HandCodedMock.



61
62
63
64
# File 'lib/gems/rspec-1.1.11/spec/spec/spec_classes.rb', line 61

def initialize(return_val)
  @return_val = return_val
  @funny_called = false
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Spec::Matchers

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/gems/rspec-1.1.11/spec/spec/spec_classes.rb', line 79

def exists?
  @return_val
end

#funny?Boolean

Returns:

  • (Boolean)


66
67
68
69
# File 'lib/gems/rspec-1.1.11/spec/spec/spec_classes.rb', line 66

def funny?
  @funny_called = true
  @return_val
end

#hungry?(a, b, c) ⇒ Boolean

Returns:

  • (Boolean)


71
72
73
74
75
76
77
# File 'lib/gems/rspec-1.1.11/spec/spec/spec_classes.rb', line 71

def hungry?(a, b, c)
  a.should equal(1)
  b.should equal(2)
  c.should equal(3)
  @funny_called = true
  @return_val
end

#multi_word_predicate?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/gems/rspec-1.1.11/spec/spec/spec_classes.rb', line 83

def multi_word_predicate?
  @return_val
end

#rspec_verifyObject



87
88
89
# File 'lib/gems/rspec-1.1.11/spec/spec/spec_classes.rb', line 87

def rspec_verify
  @funny_called.should be_true
end