Commit ede6ca9f authored by Greg Gard's avatar Greg Gard

cleanup on presenter tests. refactored components back to mixins

parent c5804997
# stateless component mixins
# - allows presenters to be composed with different sets of ui widgets/utilities
# - goal to create "functionally pure" methods with no external dependencies or side-effects.
# - rails' tag implementation does, under the hood, rely on an output buffer in the target class (eg presener).
# might be interesting to convert these to self-contained classes with *_ui delegation in target class maybe.
......@@ -13,7 +14,7 @@ module TransfersComponent
tag._html "<h1>This should be big with no tags in text</h1>"
tag.div do
tag.h3 opts[:time]
tag.a(opts[:link_label], href: opts[:link_path])
tag.a(opts[:link_label], href: opts[:link_url])
......@@ -5,7 +5,7 @@ class TransfersPresenter < ApplicationPresenter
title: "Emergency Transfer Form",
link_label: 'Foo',
link_path: ''
link_url: ''
def transfers
......@@ -9,7 +9,7 @@ class TransfersPresenterTest < PresenterTestCase
test "should have a link" do
assert_select "a", defaults[:link_label]
assert_select "a:match('href', ?)", defaults[:link_path]
assert_select "a", {count: 1, text: defaults[:link_label]}
assert_select "a:match('href', ?)", defaults[:link_url]
......@@ -9,11 +9,13 @@ class ActiveSupport::TestCase
# Add more helper methods to be used by all tests here...
# presenter tests allows unit testing of view components without needing request/integration tests
# - assumes component methodsa are built "functionally pure" with no side effects or dependencies (eg global request object)
# - inspired by react.
# -
# - some other view test helpers
# - be careful with dom testing assertions as they will/may pass if given a nil test criterion, but content !nil?
class PresenterTestCase < ActiveSupport::TestCase
include Rails::Dom::Testing::Assertions
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment