module Cell::Testing
Builder
methods and Capybara
support. This gets included into Test::Unit, MiniTest::Spec, etc.
Private Class Methods
capybara=(value)
click to toggle source
Set this to true if you have Capybara
loaded. Happens automatically in Cell::TestCase.
# File lib/cell/testing.rb, line 30 def self.capybara=(value) @capybara = value end
capybara?()
click to toggle source
# File lib/cell/testing.rb, line 34 def self.capybara? @capybara end
controller(name)
click to toggle source
# File lib/cell/testing.rb, line 68 def self.controller(name) # DSL method for the test. self.controller_class = name end
included(base)
click to toggle source
# File lib/cell/testing.rb, line 63 def self.included(base) base.class_eval do extend Uber::InheritableAttr inheritable_attr :controller_class def self.controller(name) # DSL method for the test. self.controller_class = name end end end
Public Instance Methods
cell(name, *args)
click to toggle source
# File lib/cell/testing.rb, line 7 def cell(name, *args) cell_for(ViewModel, name, *args) end
concept(name, *args)
click to toggle source
# File lib/cell/testing.rb, line 11 def concept(name, *args) cell_for(Concept, name, *args) end
Private Instance Methods
cell_for(baseclass, name, model=nil, options={})
click to toggle source
# File lib/cell/testing.rb, line 16 def cell_for(baseclass, name, model=nil, options={}) options[:context] ||= {} options[:context][:controller] = controller cell = baseclass.cell(name, model, options) cell.extend(Capybara) if Cell::Testing.capybara? # leaving this here as most people use Capybara. # apparently it's ok to only override ViewModel#call and capybararize the result. # when joining in a Collection, the joint will still be capybararized. cell end
controller()
click to toggle source
# File lib/cell/testing.rb, line 59 def controller # FIXME: this won't allow us using let(:controller) in MiniTest. controller_for(self.class.controller_class) end