Class: JavaMethod::JMockStubMethodWriter

Inherits:
StubMethodWriter show all
Defined in:
lib/java_testing_guff/qdox_extensions.rb

Instance Method Summary collapse

Methods inherited from StubMethodWriter

#add_getter_stub_to, #add_stub_methods_to, #append_throws_clause_if_necessary, #initialize, #underlying_method

Constructor Details

This class inherits a constructor from JavaMethod::StubMethodWriter

Instance Method Details

#add_boolean_getter_stub_negative_case_to(body) ⇒ Object



387
388
389
# File 'lib/java_testing_guff/qdox_extensions.rb', line 387

def add_boolean_getter_stub_negative_case_to(body)
    body.line("stubs().method(\"#{name}\").will(returnValue(false));")
end

#add_boolean_getter_stub_positive_case_to(body) ⇒ Object



383
384
385
# File 'lib/java_testing_guff/qdox_extensions.rb', line 383

def add_boolean_getter_stub_positive_case_to(body)
    body.line("stubs().method(\"#{name}\").will(returnValue(true));")
end

#add_nonboolean_getter_stub_to(body, gotten_field_name) ⇒ Object



391
392
393
# File 'lib/java_testing_guff/qdox_extensions.rb', line 391

def add_nonboolean_getter_stub_to(body, gotten_field_name)
    body.line("stubs().method(\"#{name}\").will(returnValue(#{gotten_field_name}));")
end

#add_nongetter_stub_to(method_builder) ⇒ Object



395
396
397
398
399
400
401
402
403
404
# File 'lib/java_testing_guff/qdox_extensions.rb', line 395

def add_nongetter_stub_to(method_builder)
    method_builder.body {|body|
        if (returns_something?)
            body.line("stubs().method(\"#{name}\").#{jmock_with_clause}.will(returnValue(result));")
        else
            body.line("stubs().method(\"#{name}\").#{jmock_with_clause};")
        end
        body.line('return (T) this;')
    }
end