Sha256: 9ac1777eee445c807f4b5ce9f5c6ef6a8afa990ac5a0618a581d0b4f76591bd6

Contents?: true

Size: 558 Bytes

Versions: 41

Compression:

Stored size: 558 Bytes

Contents

# frozen_string_literal: true

module Primer
  # Module to allow components to deal with the `test_selector` argument.
  # It will only add the selector if env is not Production.
  #
  # test_selecotr: "foo" => data-test-selector="foo"
  module TestSelectorHelper
    TEST_SELECTOR_TAG = :test_selector

    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
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
primer_view_components-0.0.67 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.66 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.65 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.64 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.63 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.62 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.61 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.60 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.59 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.58 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.57 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.56 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.55 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.54 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.53 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.52 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.51 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.50 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.49 app/lib/primer/test_selector_helper.rb
primer_view_components-0.0.48 app/lib/primer/test_selector_helper.rb