magicka 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -0
- data/README.md +3 -3
- data/config/check_specs.yml +0 -2
- data/config/yardstick.yml +8 -2
- data/lib/magicka/aggregator/method_builder.rb +35 -28
- data/lib/magicka/aggregator.rb +16 -8
- data/lib/magicka/display.rb +1 -1
- data/lib/magicka/element/class_methods.rb +2 -0
- data/lib/magicka/element.rb +4 -2
- data/lib/magicka/helper/aggregator_options.rb +64 -0
- data/lib/magicka/helper/class_methods.rb +10 -2
- data/lib/magicka/helper/method_builder.rb +10 -6
- data/lib/magicka/helper.rb +12 -6
- data/lib/magicka/version.rb +1 -1
- data/magicka.gemspec +1 -1
- data/spec/dummy/app/controllers/application_controller.rb +1 -0
- data/spec/dummy/app/controllers/documents_controller.rb +9 -0
- data/spec/dummy/app/models/document.rb +5 -0
- data/spec/dummy/app/models/magicka/data_entry.rb +7 -0
- data/spec/dummy/app/models/magicka/data_table.rb +6 -0
- data/spec/dummy/app/views/documents/show.html.erb +6 -0
- data/spec/dummy/app/views/templates/display/_data_entry.html.erb +2 -0
- data/spec/dummy/config/environments/development.rb +1 -0
- data/spec/dummy/config/initializers/magicka.rb +7 -0
- data/spec/dummy/config/routes.rb +1 -0
- data/spec/dummy/db/schema.rb +5 -0
- data/spec/integration/yard/magicka/helper_spec.rb +33 -0
- data/spec/lib/magicka/aggregator/class_methods_spec.rb +352 -0
- data/spec/lib/magicka/aggregator/method_builder_spec.rb +29 -0
- data/spec/lib/magicka/aggregator_spec.rb +0 -221
- data/spec/lib/magicka/helper/aggregator_options_spec.rb +99 -0
- data/spec/lib/magicka/helper/class_methods_spec.rb +101 -0
- data/spec/lib/magicka/helper_spec.rb +2 -18
- data/spec/support/factories/document.rb +7 -0
- data/spec/support/factory_bot.rb +7 -0
- data/spec/support/models/custom_aggregator.rb +12 -0
- data/spec/support/models/my_element.rb +6 -0
- metadata +21 -4
@@ -0,0 +1,101 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Magicka::Helper::ClassMethods do
|
6
|
+
subject(:object) { klass.new }
|
7
|
+
|
8
|
+
let(:model) { Object.new }
|
9
|
+
|
10
|
+
let(:helper_class) { Magicka::Helper }
|
11
|
+
let(:klass) do
|
12
|
+
Class.new do
|
13
|
+
include Magicka::Helper
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#with' do
|
18
|
+
let(:aggregator_class) do
|
19
|
+
Class.new(Magicka::Aggregator) do
|
20
|
+
def self.name
|
21
|
+
'Magicka::MyClass'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when passing a class' do
|
27
|
+
it do
|
28
|
+
expect { helper_class.with(aggregator_class) }
|
29
|
+
.to add_method('magicka_my_class')
|
30
|
+
.to(object)
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when the method is called' do
|
34
|
+
before { helper_class.with(aggregator_class) }
|
35
|
+
|
36
|
+
it do
|
37
|
+
object.magicka_my_class(model) do |aggregator|
|
38
|
+
expect(aggregator).to be_a(aggregator_class)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when an element is added in the block' do
|
44
|
+
before do
|
45
|
+
helper_class.with(aggregator_class) do
|
46
|
+
with_element(Magicka::Input, :my_input)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it do
|
51
|
+
object.magicka_my_class(model) do |aggregator|
|
52
|
+
expect(aggregator).to respond_to(:my_input)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when passing a string as agregator' do
|
59
|
+
let(:aggregator_name) { :Test1Aggregator }
|
60
|
+
let(:aggregator_class_name) { "Magicka::#{aggregator_name}" }
|
61
|
+
|
62
|
+
it do
|
63
|
+
expect { helper_class.with(aggregator_class_name, :test1_aggregator) }
|
64
|
+
.to add_method('magicka_test1_aggregator')
|
65
|
+
.to(object)
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when the method is called' do
|
69
|
+
before do
|
70
|
+
helper_class.with(aggregator_class_name, :test1_aggregator)
|
71
|
+
|
72
|
+
Magicka.const_set(aggregator_name, aggregator_class)
|
73
|
+
end
|
74
|
+
|
75
|
+
it do
|
76
|
+
object.magicka_test1_aggregator(model) do |aggregator|
|
77
|
+
expect(aggregator).to be_a(aggregator_class)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'when an element is added in the block' do
|
83
|
+
let(:aggregator_name) { :Test2Aggregator }
|
84
|
+
|
85
|
+
before do
|
86
|
+
helper_class.with(aggregator_class_name, :test2_aggregator) do
|
87
|
+
with_element(Magicka::Input, :my_input)
|
88
|
+
end
|
89
|
+
|
90
|
+
Magicka.const_set(aggregator_name, aggregator_class)
|
91
|
+
end
|
92
|
+
|
93
|
+
it do
|
94
|
+
object.magicka_test2_aggregator(model) do |aggregator|
|
95
|
+
expect(aggregator).to respond_to(:my_input)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -5,30 +5,14 @@ require 'spec_helper'
|
|
5
5
|
describe Magicka::Helper do
|
6
6
|
subject(:object) { klass.new }
|
7
7
|
|
8
|
+
let(:model) { Object.new }
|
9
|
+
|
8
10
|
let(:klass) do
|
9
11
|
Class.new do
|
10
12
|
include Magicka::Helper
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
|
-
let(:model) { 'model' }
|
15
|
-
|
16
|
-
describe '.with' do
|
17
|
-
let(:aggregator_class) do
|
18
|
-
Class.new(Magicka::Aggregator) do
|
19
|
-
def self.name
|
20
|
-
'Magicka::MyClass'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
it do
|
26
|
-
expect { described_class.with(aggregator_class) }
|
27
|
-
.to add_method('magicka_my_class')
|
28
|
-
.to(object)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
16
|
describe '#magicka_display' do
|
33
17
|
it do
|
34
18
|
object.magicka_display(model) do |display|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magicka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DarthJee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.0.
|
33
|
+
version: 2.0.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.0.
|
40
|
+
version: 2.0.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: actionpack
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -436,6 +436,7 @@ files:
|
|
436
436
|
- lib/magicka/form.rb
|
437
437
|
- lib/magicka/form_element.rb
|
438
438
|
- lib/magicka/helper.rb
|
439
|
+
- lib/magicka/helper/aggregator_options.rb
|
439
440
|
- lib/magicka/helper/class_methods.rb
|
440
441
|
- lib/magicka/helper/method_builder.rb
|
441
442
|
- lib/magicka/input.rb
|
@@ -456,14 +457,20 @@ files:
|
|
456
457
|
- spec/dummy/app/channels/application_cable/connection.rb
|
457
458
|
- spec/dummy/app/controllers/application_controller.rb
|
458
459
|
- spec/dummy/app/controllers/concerns/.keep
|
460
|
+
- spec/dummy/app/controllers/documents_controller.rb
|
459
461
|
- spec/dummy/app/helpers/application_helper.rb
|
460
462
|
- spec/dummy/app/jobs/application_job.rb
|
461
463
|
- spec/dummy/app/mailers/application_mailer.rb
|
462
464
|
- spec/dummy/app/models/application_record.rb
|
463
465
|
- spec/dummy/app/models/concerns/.keep
|
466
|
+
- spec/dummy/app/models/document.rb
|
467
|
+
- spec/dummy/app/models/magicka/data_entry.rb
|
468
|
+
- spec/dummy/app/models/magicka/data_table.rb
|
469
|
+
- spec/dummy/app/views/documents/show.html.erb
|
464
470
|
- spec/dummy/app/views/layouts/application.html.erb
|
465
471
|
- spec/dummy/app/views/layouts/mailer.html.erb
|
466
472
|
- spec/dummy/app/views/layouts/mailer.text.erb
|
473
|
+
- spec/dummy/app/views/templates/display/_data_entry.html.erb
|
467
474
|
- spec/dummy/bin/bundle
|
468
475
|
- spec/dummy/bin/rails
|
469
476
|
- spec/dummy/bin/rake
|
@@ -486,6 +493,7 @@ files:
|
|
486
493
|
- spec/dummy/config/initializers/cookies_serializer.rb
|
487
494
|
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
488
495
|
- spec/dummy/config/initializers/inflections.rb
|
496
|
+
- spec/dummy/config/initializers/magicka.rb
|
489
497
|
- spec/dummy/config/initializers/mime_types.rb
|
490
498
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
491
499
|
- spec/dummy/config/locales/en.yml
|
@@ -505,6 +513,9 @@ files:
|
|
505
513
|
- spec/dummy/storage/.keep
|
506
514
|
- spec/integration/readme/.keep
|
507
515
|
- spec/integration/yard/.keep
|
516
|
+
- spec/integration/yard/magicka/helper_spec.rb
|
517
|
+
- spec/lib/magicka/aggregator/class_methods_spec.rb
|
518
|
+
- spec/lib/magicka/aggregator/method_builder_spec.rb
|
508
519
|
- spec/lib/magicka/aggregator_spec.rb
|
509
520
|
- spec/lib/magicka/button_spec.rb
|
510
521
|
- spec/lib/magicka/display_spec.rb
|
@@ -513,12 +524,18 @@ files:
|
|
513
524
|
- spec/lib/magicka/element_spec.rb
|
514
525
|
- spec/lib/magicka/form_element_spec.rb
|
515
526
|
- spec/lib/magicka/form_spec.rb
|
527
|
+
- spec/lib/magicka/helper/aggregator_options_spec.rb
|
528
|
+
- spec/lib/magicka/helper/class_methods_spec.rb
|
516
529
|
- spec/lib/magicka/helper_spec.rb
|
517
530
|
- spec/lib/magicka/input_spec.rb
|
518
531
|
- spec/lib/magicka/select_spec.rb
|
519
532
|
- spec/lib/magicka/text_spec.rb
|
520
533
|
- spec/spec_helper.rb
|
534
|
+
- spec/support/factories/document.rb
|
535
|
+
- spec/support/factory_bot.rb
|
521
536
|
- spec/support/models/.keep
|
537
|
+
- spec/support/models/custom_aggregator.rb
|
538
|
+
- spec/support/models/my_element.rb
|
522
539
|
- spec/support/shared_examples/.keep
|
523
540
|
homepage: https://github.com/darthjee/magicka
|
524
541
|
licenses: []
|