Class: Messaging::Fixtures::Message
- Inherits:
-
Object
- Object
- Messaging::Fixtures::Message
- Includes:
- Initializer, TestBench::Fixture
- Defined in:
- lib/messaging/fixtures/message.rb
Constant Summary collapse
- Error =
Class.new(RuntimeError)
Class Method Summary collapse
Instance Method Summary collapse
- #assert_attribute_value(name, value) ⇒ Object
- #assert_attributes_assigned(attribute_names = nil) ⇒ Object (also: #assert_all_attributes_assigned)
- #assert_attributes_copied(attribute_names = nil) ⇒ Object
- #assert_follows ⇒ Object
- #assert_metadata(&test_block) ⇒ Object
- #call ⇒ Object
- #message_class ⇒ Object
- #message_type ⇒ Object
- #source_message_class ⇒ Object
- #source_message_type ⇒ Object
- #title_context_name ⇒ Object
Class Method Details
.build(message, source_message = nil, title_context_name: nil, &test_block) ⇒ Object
31 32 33 |
# File 'lib/messaging/fixtures/message.rb', line 31 def self.build(, =nil, title_context_name: nil, &test_block) new(, , title_context_name, test_block) end |
Instance Method Details
#assert_attribute_value(name, value) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/messaging/fixtures/message.rb', line 109 def assert_attribute_value(name, value) context "Attribute Value" do attribute_value = .public_send(name) test "#{name}" do detail "Attribute Value: #{attribute_value.inspect}" detail "Compare Value: #{value.inspect}" assert(attribute_value == value) end end end |
#assert_attributes_assigned(attribute_names = nil) ⇒ Object Also known as: assert_all_attributes_assigned
62 63 64 65 66 67 68 69 70 |
# File 'lib/messaging/fixtures/message.rb', line 62 def assert_attributes_assigned(attribute_names=nil) fixture( Schema::Fixtures::Assignment, , attribute_names, print_title_context: false, attributes_context_name: "Attributes Assigned" ) end |
#assert_attributes_copied(attribute_names = nil) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/messaging/fixtures/message.rb', line 73 def assert_attributes_copied(attribute_names=nil) if .nil? test "Source message not nil" do detail "Source Message: nil" refute(.nil?) end return end fixture( Schema::Fixtures::Equality, , , attribute_names, ignore_class: true, print_title_context: false, attributes_context_name: "Attributes Copied: #{} => #{}" ) end |
#assert_follows ⇒ Object
102 103 104 105 106 107 |
# File 'lib/messaging/fixtures/message.rb', line 102 def assert_follows = . = &. fixture(Follows, , ) end |
#assert_metadata(&test_block) ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/messaging/fixtures/message.rb', line 93 def (&test_block) fixture( Metadata, ., &., &test_block ) end |
#call ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/messaging/fixtures/message.rb', line 35 def call context_name = title_context_name context context_name do if test_block.nil? raise Error, "Message fixture must be executed with a block" end if .nil? test "Not nil" do detail "Message: nil" detail "Remaining message tests are skipped" refute(.nil?) end return end detail "Message Class: #{.name}" if not .nil? detail "Source Message Class: #{.name}" end test_block.call(self) end end |
#message_class ⇒ Object
9 10 11 |
# File 'lib/messaging/fixtures/message.rb', line 9 def .class end |
#message_type ⇒ Object
13 14 15 |
# File 'lib/messaging/fixtures/message.rb', line 13 def .name.split('::').last end |
#source_message_class ⇒ Object
17 18 19 |
# File 'lib/messaging/fixtures/message.rb', line 17 def .class end |
#source_message_type ⇒ Object
21 22 23 |
# File 'lib/messaging/fixtures/message.rb', line 21 def .name.split('::').last end |
#title_context_name ⇒ Object
25 26 27 |
# File 'lib/messaging/fixtures/message.rb', line 25 def title_context_name @title_context_name ||= "Message: #{}" end |