Class: WebFixtures::Helper
- Inherits:
-
Object
- Object
- WebFixtures::Helper
- Includes:
- Initializer, TestBench::Fixture
- Defined in:
- lib/web_fixtures/helper.rb
Constant Summary collapse
- Error =
Class.new(RuntimeError)
Instance Attribute Summary collapse
-
#helper_module ⇒ Object
readonly
Returns the value of attribute helper_module.
-
#test_block ⇒ Object
readonly
Returns the value of attribute test_block.
-
#title_context_name ⇒ Object
readonly
Returns the value of attribute title_context_name.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#helper_module ⇒ Object (readonly)
Returns the value of attribute helper_module.
8 9 10 |
# File 'lib/web_fixtures/helper.rb', line 8 def helper_module @helper_module end |
#test_block ⇒ Object (readonly)
Returns the value of attribute test_block.
10 11 12 |
# File 'lib/web_fixtures/helper.rb', line 10 def test_block @test_block end |
#title_context_name ⇒ Object (readonly)
Returns the value of attribute title_context_name.
9 10 11 |
# File 'lib/web_fixtures/helper.rb', line 9 def title_context_name @title_context_name end |
Class Method Details
.build(helper_module, print_title_context: nil, title_context_name: nil, &test_block) ⇒ Object
28 29 30 |
# File 'lib/web_fixtures/helper.rb', line 28 def self.build(helper_module, print_title_context: nil, title_context_name: nil, &test_block) new(helper_module, print_title_context, title_context_name, test_block) end |
Instance Method Details
#call ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/web_fixtures/helper.rb', line 34 def call if test_block.nil? raise Error, "Helper fixture must be actuated with a block" end if print_title_context? context "#{title_context_name}" do call! end else call! end end |
#call! ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/web_fixtures/helper.rb', line 48 def call! helper_module = self.helper_module test_case_class = Class.new(ActionView::TestCase) do tests helper_module end test_case = test_case_class.new(helper_module.to_s) test_case.setup_with_controller helper = test_case.send(:view) test_block.(helper) end |
#print_title_context? ⇒ Boolean
12 13 14 15 16 17 18 |
# File 'lib/web_fixtures/helper.rb', line 12 def print_title_context? if @print_title_context.nil? @print_title_context = true end @print_title_context end |