mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-03 09:45:14 +08:00
to setup controller using block.
I implemented @colinta 's idea which was discussed below link. https://groups.google.com/d/msg/rubymotion/M9T6LybaEUs/AWip_Vwy5_4J When you want to setup UIViewController, you can setup it in a block of tests method. # Example describe MyViewController do tests MyViewController do |controller| # you can set data to the controller here controller.my_data = "foo" end . . end
This commit is contained in:
@@ -167,8 +167,8 @@ module Bacon
|
||||
# TODO
|
||||
# * :navigation => true
|
||||
# * :tab => true
|
||||
def tests(controller_class, options = {})
|
||||
@controller_class, @options = controller_class, options
|
||||
def tests(controller_class, options = {}, &block)
|
||||
@controller_class, @options, @after_created_block = controller_class, options, block
|
||||
extend Bacon::Functional::API
|
||||
extend Bacon::Functional::ContextExt
|
||||
end
|
||||
@@ -220,7 +220,11 @@ module Bacon
|
||||
else
|
||||
c = @controller_class.alloc.init
|
||||
end
|
||||
send(@options[:after_created], c) if @options[:after_created]
|
||||
if @after_created_block
|
||||
@after_created_block.call(c)
|
||||
else
|
||||
send(@options[:after_created], c) if @options[:after_created]
|
||||
end
|
||||
c
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user