Module: Cuca::Test::Helpers
- Defined in:
- lib/cuca/test/helpers.rb
Overview
Some function that should help you testing your widgets and controllers
Instance Method Summary collapse
-
#init(app_path = '/', params = {}) ⇒ Object
init the application.
-
#widget(widget_class, *args, &block) ⇒ Object
this will create a widget instance with params and block as passed to this function.
-
#widget_p(widget_class, *args, &block) ⇒ Object
same as above but enable the profiler to stdout.
Instance Method Details
#init(app_path = '/', params = {}) ⇒ Object
init the application. call this from the setup method.
12 13 14 15 16 17 |
# File 'lib/cuca/test/helpers.rb', line 12 def init(app_path = '/', params = {}) require 'cuca/cgi_emu' @cgi = CGIEmu.new({'PATH_INFO' => app_path, 'QUERY_PARAMS' => params}) @app = Cuca::App.new(@cgi) @app.load_support_files end |
#widget(widget_class, *args, &block) ⇒ Object
this will create a widget instance with params and block as passed to this function. Also it will pass current instance variables to the assigns.
23 24 25 26 27 28 29 |
# File 'lib/cuca/test/helpers.rb', line 23 def (, *args, &block) a = {} instance_variables.each do |v| a[v.gsub(/\@/,'')] = self.instance_variable_get(v) end return .new({:assigns => a, :args => args}, &block) end |
#widget_p(widget_class, *args, &block) ⇒ Object
same as above but enable the profiler to stdout
32 33 34 35 36 37 38 |
# File 'lib/cuca/test/helpers.rb', line 32 def (, *args, &block) a = {} instance_variables.each do |v| a[v.gsub(/\@/,'')] = self.instance_variable_get(v) end return .new({:assigns => a, :args => args, :profiler => $stdout}, &block) end |