Class: Schema::Fixtures::Equality
- Inherits:
-
Object
- Object
- Schema::Fixtures::Equality
- Includes:
- Initializer, TestBench::Fixture
- Defined in:
- lib/schema/fixtures/equality.rb
Class Method Summary collapse
Instance Method Summary collapse
- #attributes_context_name ⇒ Object
- #call ⇒ Object
- #call! ⇒ Object
- #compare_class ⇒ Object
- #control_class ⇒ Object
- #ignore_class? ⇒ Boolean
- #print_title_context? ⇒ Boolean
- #title_context_name ⇒ Object
Class Method Details
.build(control, compare, attribute_names = nil, ignore_class: nil, print_title_context: nil, title_context_name: nil, attributes_context_name: nil) ⇒ Object
36 37 38 39 |
# File 'lib/schema/fixtures/equality.rb', line 36 def self.build(control, compare, attribute_names=nil, ignore_class: nil, print_title_context: nil, title_context_name: nil, attributes_context_name: nil) comparison = Schema::Compare.(control, compare, attribute_names) new(comparison, ignore_class, print_title_context, title_context_name, attributes_context_name) end |
Instance Method Details
#attributes_context_name ⇒ Object
22 23 24 |
# File 'lib/schema/fixtures/equality.rb', line 22 def attributes_context_name @attributes_context_name ||= 'Attributes' end |
#call ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/schema/fixtures/equality.rb', line 41 def call if print_title_context? context "#{title_context_name}" do detail "Control Class: #{control_class.name}" detail "Compare Class: #{compare_class.name}" call! end else call! end end |
#call! ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/schema/fixtures/equality.rb', line 54 def call! if not ignore_class? test "Classes are the same" do assert(control_class == compare_class) end end context attributes_context_name do comparison.entries.each do |entry| printed_attribute_name = Attribute.printed_name(entry) control_attribute_value = entry.control_value compare_attribute_value = entry.compare_value test printed_attribute_name do detail "#{control_class.name.split('::').last} Value: #{control_attribute_value.pretty_inspect.chomp}" detail "#{compare_class.name.split('::').last} Value: #{compare_attribute_value.pretty_inspect.chomp}" assert(compare_attribute_value == control_attribute_value) end end end end |
#compare_class ⇒ Object
30 31 32 |
# File 'lib/schema/fixtures/equality.rb', line 30 def compare_class comparison.compare_class end |
#control_class ⇒ Object
26 27 28 |
# File 'lib/schema/fixtures/equality.rb', line 26 def control_class comparison.control_class end |
#ignore_class? ⇒ Boolean
7 8 9 |
# File 'lib/schema/fixtures/equality.rb', line 7 def ignore_class? @ignore_class ||= false end |
#print_title_context? ⇒ Boolean
11 12 13 14 15 16 |
# File 'lib/schema/fixtures/equality.rb', line 11 def print_title_context? if @print_title_context.nil? @print_title_context = true end @print_title_context end |
#title_context_name ⇒ Object
18 19 20 |
# File 'lib/schema/fixtures/equality.rb', line 18 def title_context_name @title_context_name ||= "Schema Equality: #{comparison.control_class.type}, #{comparison.compare_class.type}" end |