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

Inherits:
Object
  • Object
show all
Includes:
Matchers
Defined in:
lib/vendor/plugins/rspec/spec/support/spec_classes.rb

Instance Method Summary collapse

Methods included from Matchers

#be, #be_a, #be_a_kind_of, #be_an_instance_of, #be_close, #change, clear_generated_description, #eql, #equal, #exception_from, #exist, #fail, #fail_with, generated_description, #have, #have_at_least, #have_at_most, #include, #map_specs, #match, #method_missing, #raise_error, #respond_to, #run_with, #satisfy, #simple_matcher, #throw_symbol, #with_ruby, #wrap_expectation

Methods included from Matchers::DSL

#create, #define

Constructor Details

#initialize(return_val) ⇒ HandCodedMock

Returns a new instance of HandCodedMock.



61
62
63
64
# File 'lib/vendor/plugins/rspec/spec/support/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/vendor/plugins/rspec/spec/support/spec_classes.rb', line 79

def exists?
  @return_val
end

#funny?Boolean

Returns:

  • (Boolean)


66
67
68
69
# File 'lib/vendor/plugins/rspec/spec/support/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/vendor/plugins/rspec/spec/support/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/vendor/plugins/rspec/spec/support/spec_classes.rb', line 83

def multi_word_predicate?
  @return_val
end

#rspec_verifyObject



87
88
89
# File 'lib/vendor/plugins/rspec/spec/support/spec_classes.rb', line 87

def rspec_verify
  @funny_called.should be_true
end