Module RR::DoubleDefinitions::DoubleDefinition::TimesDefinitionConstructionMethods
In: lib/rr/double_definitions/double_definition.rb

Methods

Public Instance methods

Double#any_number_of_times sets an that the Double will be called any number of times. This effectively removes the times called expectation from the Doublen

Passing in a block sets the return value.

  mock(subject).method_name.any_number_of_times

[Source]

     # File lib/rr/double_definitions/double_definition.rb, line 147
147:         def any_number_of_times(&return_value_block)
148:           @times_matcher = TimesCalledMatchers::AnyTimesMatcher.new
149:           install_method_callback return_value_block
150:           self
151:         end
any_times(&return_value_block)

Double#at_least sets the expectation that the Double will be called at least n times. It works by creating a TimesCalledExpectation.

Passing in a block sets the return value.

  mock(subject).method_name.at_least(4) {:return_value}

[Source]

     # File lib/rr/double_definitions/double_definition.rb, line 121
121:         def at_least(number, &return_value_block)
122:           @times_matcher = TimesCalledMatchers::AtLeastMatcher.new(number)
123:           install_method_callback return_value_block
124:           self
125:         end

Double#at_most allows sets the expectation that the Double will be called at most n times. It works by creating a TimesCalledExpectation.

Passing in a block sets the return value.

  mock(subject).method_name.at_most(4) {:return_value}

[Source]

     # File lib/rr/double_definitions/double_definition.rb, line 134
134:         def at_most(number, &return_value_block)
135:           @times_matcher = TimesCalledMatchers::AtMostMatcher.new(number)
136:           install_method_callback return_value_block
137:           self
138:         end

Double#never sets the expectation that the Double will never be called.

This method does not accept a block because it will never be called.

  mock(subject).method_name.never

[Source]

    # File lib/rr/double_definitions/double_definition.rb, line 85
85:         def never
86:           @times_matcher = TimesCalledMatchers::NeverMatcher.new
87:           self
88:         end

Double#once sets the expectation that the Double will be called 1 time.

Passing in a block sets the return value.

  mock(subject).method_name.once {:return_value}

[Source]

     # File lib/rr/double_definitions/double_definition.rb, line 96
 96:         def once(&return_value_block)
 97:           @times_matcher = TimesCalledMatchers::IntegerMatcher.new(1)
 98:           install_method_callback return_value_block
 99:           self
100:         end

Double#times creates an TimesCalledExpectation of the passed in number.

Passing in a block sets the return value.

  mock(subject).method_name.times(4) {:return_value}

[Source]

     # File lib/rr/double_definitions/double_definition.rb, line 160
160:         def times(matcher_value, &return_value_block)
161:           @times_matcher = TimesCalledMatchers::TimesCalledMatcher.create(matcher_value)
162:           install_method_callback return_value_block
163:           self
164:         end

Double#twice sets the expectation that the Double will be called 2 times.

Passing in a block sets the return value.

  mock(subject).method_name.twice {:return_value}

[Source]

     # File lib/rr/double_definitions/double_definition.rb, line 108
108:         def twice(&return_value_block)
109:           @times_matcher = TimesCalledMatchers::IntegerMatcher.new(2)
110:           install_method_callback return_value_block
111:           self
112:         end

[Validate]