Sha256: 2e0c959528f998d702653171512acd9178072d461601952356ce72f041a11622

Contents?: true

Size: 1.3 KB

Versions: 10

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

require_relative "test_helper"

class StimulusReflex::ConcernTest < ActiveSupport::TestCase
  module TestConcern
    extend ActiveSupport::Concern
    include StimulusReflex::ConcernEnhancer
  end

  class TestReflex < StimulusReflex::Reflex
    include TestConcern

    def initialize
    end
  end

  class TestController < ActionController::Base
    include TestConcern
  end

  class TestModel < ActiveRecord::Base
    include TestConcern
  end

  test "included in a reflex it stubs controller and model methods" do
    assert_nil TestReflex.helper_method
    assert_nil TestReflex.before_action
    assert_nil TestReflex.around_action
    assert_nil TestReflex.after_action

    assert_nil TestReflex.before_save
    assert_nil TestReflex.around_save
    assert_nil TestReflex.after_save

    refute_nil TestReflex.before_reflex
  end

  test "included in a controller it stubs reflex methods" do
    assert_nil TestController.before_reflex
    assert_nil TestController.around_reflex
    assert_nil TestController.after_reflex

    refute_nil TestController.before_action
  end

  test "included in a model it stubs reflex methods" do
    assert_nil TestModel.before_reflex
    assert_nil TestModel.around_reflex
    assert_nil TestModel.after_reflex

    refute_nil TestModel.after_save
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
stimulus_reflex-3.5.0.pre9 test/concern_enhancer_test.rb
stimulus_reflex-3.5.0.pre8 test/concern_enhancer_test.rb
stimulus_reflex-3.5.0.pre7 test/concern_enhancer_test.rb
stimulus_reflex-3.5.0.pre6 test/concern_enhancer_test.rb
stimulus_reflex-3.5.0.pre5 test/concern_enhancer_test.rb
stimulus_reflex-3.5.0.pre4 test/concern_enhancer_test.rb
stimulus_reflex-3.5.0.pre3 test/concern_enhancer_test.rb
stimulus_reflex-3.5.0.pre2 test/concern_enhancer_test.rb
stimulus_reflex-3.5.0.pre1 test/concern_enhancer_test.rb
stimulus_reflex-3.5.0.pre0 test/concern_enhancer_test.rb