Module: Yattho::TestSelectorHelper

Included in:
Component
Defined in:
app/lib/yattho/test_selector_helper.rb

Overview

Module to allow components to deal with the ‘test_selector` argument. It will only add the selector if env is not Production.

test_selector: “foo” => data-test-selector=“foo”

Constant Summary collapse

TEST_SELECTOR_TAG =
:test_selector

Instance Method Summary collapse

Instance Method Details

#add_test_selector(args) ⇒ Object



11
12
13
14
15
16
17
18
# File 'app/lib/yattho/test_selector_helper.rb', line 11

def add_test_selector(args)
  if args.key?(TEST_SELECTOR_TAG) && !Rails.env.production?
    args[:data] ||= {}
    args[:data][TEST_SELECTOR_TAG] = args[TEST_SELECTOR_TAG]
  end

  args.except(TEST_SELECTOR_TAG)
end