Module: InertiaRails::Minitest::AssertionFactory
- Defined in:
- lib/inertia_rails/minitest.rb
Class Method Summary collapse
- .define_component_assertion(mod) ⇒ Object
- .define_deferred_props_assertion(mod) ⇒ Object
- .define_exact_assertion(mod, name, field) ⇒ Object
- .define_key_absent_assertion(mod, name, field) ⇒ Object
- .define_partial_assertion(mod, name, field) ⇒ Object
- .define_response_assertion(mod) ⇒ Object
Class Method Details
.define_component_assertion(mod) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/inertia_rails/minitest.rb', line 49 def define_component_assertion(mod) mod.define_method(:assert_inertia_component) do |expected, = nil| result = Testing::Assertions.validate_component(inertia, expected) assert result[:passed], || result[:message] end mod.define_method(:refute_inertia_component) do |expected, = nil| result = Testing::Assertions.validate_component(inertia, expected) refute result[:passed], || result[:negated_message] end end |
.define_deferred_props_assertion(mod) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/inertia_rails/minitest.rb', line 73 def define_deferred_props_assertion(mod) mod.define_method(:assert_inertia_deferred_props) do |*keys, group: nil, message: nil| result = Testing::Assertions.validate_deferred_props(inertia, *keys, group: group) assert result[:passed], || result[:message] end mod.define_method(:refute_inertia_deferred_props) do |*keys, group: nil, message: nil| result = Testing::Assertions.validate_deferred_props(inertia, *keys, group: group) refute result[:passed], || result[:negated_message] end end |
.define_exact_assertion(mod, name, field) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/inertia_rails/minitest.rb', line 30 def define_exact_assertion(mod, name, field) mod.define_method(:"assert_inertia_#{name}_equal") do |expected, = nil| result = Testing::Assertions.validate_exact_match(inertia, field, expected) assert result[:passed], || result[:message] end mod.define_method(:"refute_inertia_#{name}_equal") do |expected, = nil| result = Testing::Assertions.validate_exact_match(inertia, field, expected) refute result[:passed], || result[:negated_message] end end |
.define_key_absent_assertion(mod, name, field) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/inertia_rails/minitest.rb', line 42 def define_key_absent_assertion(mod, name, field) mod.define_method(:"assert_no_inertia_#{name}") do |key, = nil| result = Testing::Assertions.validate_key_absent(inertia, field, key) assert result[:passed], || result[:message] end end |
.define_partial_assertion(mod, name, field) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/inertia_rails/minitest.rb', line 10 def define_partial_assertion(mod, name, field) mod.define_method(:"assert_inertia_#{name}") do |expected = nil, = nil, &block| result = if block Testing::Assertions.validate_with_block(inertia, field, &block) else Testing::Assertions.validate_partial_match(inertia, field, expected) end assert result[:passed], || result[:message] end mod.define_method(:"refute_inertia_#{name}") do |expected = nil, = nil, &block| result = if block Testing::Assertions.validate_with_block(inertia, field, &block) else Testing::Assertions.validate_partial_match(inertia, field, expected) end refute result[:passed], || result[:negated_message] end end |
.define_response_assertion(mod) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/inertia_rails/minitest.rb', line 61 def define_response_assertion(mod) mod.define_method(:assert_inertia_response) do | = nil| result = Testing::Assertions.validate_inertia_response(inertia) assert result[:passed], || result[:message] end mod.define_method(:refute_inertia_response) do | = nil| result = Testing::Assertions.validate_inertia_response(inertia) refute result[:passed], || result[:negated_message] end end |