Module: Rucola::TestCase
- Defined in:
- lib/rucola/test_case.rb
Defined Under Namespace
Modules: InstanceMethods
Instance Method Summary collapse
-
#tests(class_to_be_tested) ⇒ Object
Defines the controller that will be tested.
Instance Method Details
#tests(class_to_be_tested) ⇒ Object
Defines the controller that will be tested.
class ApplicationController < OSX::NSObject
ib_outlet :window
ib_outlets :tableView, :searchField
ib_outlets :textField
end
class TestFoo < Test::Unit::TestCase
tests ApplicationController
def after_setup
ib_outlets :window => mock("Main Window"),
:tableView => OSX::NSTableView.alloc.init,
:searchField => OSX::NSSearchField.alloc.init
window.stubs(:title => 'Main Window')
tableView.addTableColumn OSX::NSTableColumn.alloc.init
searchField.stringValue = "foo"
end
def test_something
p controller # => #<ApplicationController:0xdfa1ce class='ApplicationController' id=0x1e8d0e0>
p window.title # => "Main Window"
p tableView.tableColumns # => #<NSCFArray [#<OSX::NSTableColumn:0xdf9d0a class='NSTableColumn' id=0x1e90d00>]>
p searchField # => #<OSX::NSSearchField:0xdfa43a class='NSSearchField' id=0x1e84cb0>
# Note that we haven't set the textField ib_outlet to anything else in the after_setup method,
# so it will be a stub which responds to everything by returning nil.
p textField # => #<Mock:textField>
end
end
54 55 56 57 |
# File 'lib/rucola/test_case.rb', line 54 def tests(class_to_be_tested) @class_to_be_tested = class_to_be_tested include Rucola::TestCase::InstanceMethods end |