evt-schema-fixtures 0.0.0.0 → 0.0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc9111e97989d9438e3bf7de94bf6873a6d4b1b838f1c42812c5b0a1acd8912a
4
- data.tar.gz: 33fa35056749cd4b9849ca76482536dbe5c45e2c9b8949c449945b3ec5b03a58
3
+ metadata.gz: 9fb18002db077a88beb7223802c29209dbfa96a04f4765d4d131c66316f43896
4
+ data.tar.gz: 4c2bbf6002d66ee540f3c3523d1812be732a3cb0a3ff09cc4af55ffb0100e1ee
5
5
  SHA512:
6
- metadata.gz: bb515269536abacc5960c134a4c58d7bebdd428a901685bc8351b13804bda7f1dd1ca9bfc07039f59c6f83faf718a2a9e75be684a3eb6db48c1feae323436d70
7
- data.tar.gz: b82cc17779017eaafbccaa264c681320195230e43f849111d2c9370e11d35fa50c54d237e5d91ca51b38ae690b95f265265c1b9b21060d73f031d27d2e6280c8
6
+ metadata.gz: 290500b80a0cbc723fa6dc4615f9d44dcac8547b2e4fe838b1d555c3d69c6cecc0e7393160906c29697e60f15e45698ab47f94bb4b5a3ef8f2ca2b0da6ea6fe6
7
+ data.tar.gz: 75db324f49fade5d3a51f04a0147bf5ec91a16f04e565848a0b534b79dd4b02050cffa6b8d9c315c7b9a730a7473cc55d1139fd24bbbfdd1fdf814a3cdd78198
@@ -1 +1,7 @@
1
+ require 'test_bench/fixture'
2
+
1
3
  require 'schema'
4
+
5
+ require 'schema/fixtures/attribute'
6
+ require 'schema/fixtures/equality'
7
+ require 'schema/fixtures/assignment'
@@ -0,0 +1,63 @@
1
+ module Schema
2
+ module Fixtures
3
+ class Assignment
4
+ include TestBench::Fixture
5
+ include Initializer
6
+
7
+ def print_title_context?
8
+ if @print_title_context.nil?
9
+ @print_title_context = true
10
+ end
11
+ @print_title_context
12
+ end
13
+
14
+ def title_context_name
15
+ @title_context_name ||= "Schema Assignment: #{comparison.compare_class.type}"
16
+ end
17
+
18
+ def attributes_context_name
19
+ @attributes_context_name ||= 'Attributes'
20
+ end
21
+
22
+ def schema_class
23
+ comparison.control_class
24
+ end
25
+
26
+ initializer :comparison, na(:print_title_context), na(:title_context_name), na(:attributes_context_name)
27
+
28
+ def self.build(compare, attribute_names=nil, print_title_context: nil, title_context_name: nil, attributes_context_name: nil)
29
+ control = compare.class.new
30
+ comparison = Schema::Compare.(control, compare, attribute_names)
31
+ new(comparison, print_title_context, title_context_name, attributes_context_name)
32
+ end
33
+
34
+ def call
35
+ if print_title_context?
36
+ context "#{title_context_name}" do
37
+ detail "Class: #{schema_class.name}"
38
+
39
+ call!
40
+ end
41
+ else
42
+ call!
43
+ end
44
+ end
45
+
46
+ def call!
47
+ context attributes_context_name do
48
+ comparison.entries.each do |entry|
49
+ default_attribute_value = entry.control_value
50
+ attribute_value = entry.compare_value
51
+
52
+ test "#{entry.compare_name}" do
53
+ detail "Default Value: #{default_attribute_value.inspect}"
54
+ detail "Assigned Value: #{attribute_value.inspect}"
55
+
56
+ refute(attribute_value == default_attribute_value)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,16 @@
1
+ module Schema
2
+ module Fixtures
3
+ module Attribute
4
+ def self.printed_name(entry)
5
+ control_name = entry.control_name
6
+ compare_name = entry.compare_name
7
+
8
+ if control_name == compare_name
9
+ return control_name.to_s
10
+ else
11
+ return "#{control_name} => #{compare_name}"
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1 +1,7 @@
1
1
  require 'schema/controls'
2
+
3
+ module Schema
4
+ module Fixtures
5
+ Controls = Schema::Controls
6
+ end
7
+ end
@@ -0,0 +1,79 @@
1
+ module Schema
2
+ module Fixtures
3
+ class Equality
4
+ include TestBench::Fixture
5
+ include Initializer
6
+
7
+ def ignore_class?
8
+ @ignore_class ||= false
9
+ end
10
+
11
+ def print_title_context?
12
+ if @print_title_context.nil?
13
+ @print_title_context = true
14
+ end
15
+ @print_title_context
16
+ end
17
+
18
+ def title_context_name
19
+ @title_context_name ||= "Schema Equality: #{comparison.control_class.type}, #{comparison.compare_class.type}"
20
+ end
21
+
22
+ def attributes_context_name
23
+ @attributes_context_name ||= 'Attributes'
24
+ end
25
+
26
+ def control_class
27
+ comparison.control_class
28
+ end
29
+
30
+ def compare_class
31
+ comparison.compare_class
32
+ end
33
+
34
+ initializer :comparison, na(:ignore_class), na(:print_title_context), na(:title_context_name), na(:attributes_context_name)
35
+
36
+ def self.build(control, compare, attribute_names=nil, ignore_class: nil, print_title_context: nil, title_context_name: nil, attributes_context_name: nil)
37
+ comparison = Schema::Compare.(control, compare, attribute_names)
38
+ new(comparison, ignore_class, print_title_context, title_context_name, attributes_context_name)
39
+ end
40
+
41
+ def call
42
+ if print_title_context?
43
+ context "#{title_context_name}" do
44
+ detail "Control Class: #{control_class.name}"
45
+ detail "Compare Class: #{compare_class.name}"
46
+
47
+ call!
48
+ end
49
+ else
50
+ call!
51
+ end
52
+ end
53
+
54
+ def call!
55
+ if not ignore_class?
56
+ test "Classes are the same" do
57
+ assert(control_class == compare_class)
58
+ end
59
+ end
60
+
61
+ context attributes_context_name do
62
+ comparison.entries.each do |entry|
63
+ printed_attribute_name = Attribute.printed_name(entry)
64
+
65
+ control_attribute_value = entry.control_value
66
+ compare_attribute_value = entry.compare_value
67
+
68
+ test printed_attribute_name do
69
+ detail "#{control_class.name.split('::').last} Value: #{control_attribute_value.inspect}"
70
+ detail "#{compare_class.name.split('::').last} Value: #{compare_attribute_value.inspect}"
71
+
72
+ assert(compare_attribute_value == control_attribute_value)
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-schema-fixtures
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.0
4
+ version: 0.0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-09 00:00:00.000000000 Z
11
+ date: 2020-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-schema
@@ -59,7 +59,10 @@ extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
61
  - lib/schema/fixtures.rb
62
+ - lib/schema/fixtures/assignment.rb
63
+ - lib/schema/fixtures/attribute.rb
62
64
  - lib/schema/fixtures/controls.rb
65
+ - lib/schema/fixtures/equality.rb
63
66
  homepage: https://github.com/eventide-project/schema-fixtures
64
67
  licenses:
65
68
  - MIT