magicka 0.5.0 → 0.5.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: 05ffde0ed491999459ac688704b00c0ce07e2c93ae89aaa75f78a1c6b8acabba
4
- data.tar.gz: 6d08209c27862a6791917a32e322775bfc801a00dcb666924d7b0b387c92f03b
3
+ metadata.gz: c5648c42b3fd9a9cbfdf7b9e72df4a88374d0fb2164aaa5c96cee42c21cf97ef
4
+ data.tar.gz: 984fccb391fd20285a9ecbe498289ad789da1ea9a62eeb71b5b1b1b60c1ff384
5
5
  SHA512:
6
- metadata.gz: 4d2aa6d343fe5104e275dc9257fb838c650f0353406452b217fb17f40978ea4152838c56181300bec3f1da208f28764790e947619f5137426545206c540e5952
7
- data.tar.gz: 91036aeff9fbefe61eacc3b93005e8f51e9c6cf86ce7cb618e5360ea8059c7ba6df680c4bd5cebf9c57cb3a8154058b63aa1aeb1c362261b4613e4707cf41ca0
6
+ metadata.gz: 33f95d6caa25e20d6af95b2e47411840be056512de6533c322808d719105030ca3464edbe8786b7982527ef904b9131b53c6197f00d5729038fc12fd55ef6747
7
+ data.tar.gz: 51ee56a29de58f704bcd3b2babb0b2181f3c0eab207c37acfdb08cd00125e82c73154376b2579909dff1c2dcb7b42b95211249ccd75c09b3e974cc637121b6c8
data/.circleci/config.yml CHANGED
@@ -22,7 +22,7 @@ workflows:
22
22
  jobs:
23
23
  test:
24
24
  docker:
25
- - image: darthjee/circleci_rails_gems:0.6.0
25
+ - image: darthjee/circleci_rails_gems:0.6.3
26
26
  environment:
27
27
  PROJECT: magicka
28
28
  steps:
@@ -41,7 +41,7 @@ jobs:
41
41
  command: cc-test-reporter after-build --exit-code $?
42
42
  checks:
43
43
  docker:
44
- - image: darthjee/circleci_rails_gems:0.6.0
44
+ - image: darthjee/circleci_rails_gems:0.6.3
45
45
  environment:
46
46
  PROJECT: magicka
47
47
  steps:
@@ -66,7 +66,7 @@ jobs:
66
66
  command: check_specs
67
67
  build-and-release:
68
68
  docker:
69
- - image: darthjee/circleci_rails_gems:0.5.4
69
+ - image: darthjee/circleci_rails_gems:0.6.3
70
70
  environment:
71
71
  PROJECT: magicka
72
72
  steps:
data/.rubocop.yml CHANGED
@@ -32,7 +32,7 @@ RSpec/MultipleExpectations:
32
32
  - 'spec/integration/readme/**/*_spec.rb'
33
33
 
34
34
  RSpec/NestedGroups:
35
- Max: 4
35
+ Max: 5
36
36
  Exclude:
37
37
  - 'spec/integration/yard/**/*.rb'
38
38
 
data/Dockerfile CHANGED
@@ -1,6 +1,6 @@
1
1
  FROM darthjee/scripts:0.1.8 as scripts
2
2
 
3
- FROM darthjee/rails_gems:0.6.0 as base
3
+ FROM darthjee/rails_gems:0.6.3 as base
4
4
 
5
5
  COPY --chown=app:app ./ /home/app/app/
6
6
 
data/README.md CHANGED
@@ -11,7 +11,7 @@ Magicka
11
11
 
12
12
  Yard Documentation
13
13
  -------------------
14
- [https://www.rubydoc.info/gems/magicka/0.5.0](https://www.rubydoc.info/gems/magicka/0.5.0)
14
+ [https://www.rubydoc.info/gems/magicka/0.5.5](https://www.rubydoc.info/gems/magicka/0.5.5)
15
15
 
16
16
  Installation
17
17
  ---------------
@@ -1,5 +1,5 @@
1
1
  ignore:
2
2
  - lib/magicka/version.rb
3
3
  - lib/magicka.rb
4
- - lib/magicka/aggregator.rb
5
4
  - lib/magicka/aggregator/method_builder.rb
5
+ - lib/magicka/helper.rb
data/config/yardstick.yml CHANGED
@@ -1,4 +1,4 @@
1
- threshold: 85.5
1
+ threshold: 84.1
2
2
  require_exact_threshold: false
3
3
  rules:
4
4
  ApiTag::Presence:
data/lib/magicka.rb CHANGED
@@ -13,9 +13,12 @@ module Magicka
13
13
  autoload :VERSION, 'magicka/version'
14
14
  autoload :Aggregator, 'magicka/aggregator'
15
15
  autoload :Button, 'magicka/button'
16
+ autoload :Display, 'magicka/display'
16
17
  autoload :Element, 'magicka/element'
17
18
  autoload :FormElement, 'magicka/form_element'
18
19
  autoload :Form, 'magicka/form'
20
+ autoload :Helper, 'magicka/helper'
19
21
  autoload :Input, 'magicka/input'
20
22
  autoload :Select, 'magicka/select'
23
+ autoload :Text, 'magicka/text'
21
24
  end
@@ -8,12 +8,40 @@ module Magicka
8
8
  autoload :MethodBuilder, 'magicka/aggregator/method_builder'
9
9
 
10
10
  class << self
11
- def with_element(element_class, method_name = nil)
11
+ def with_element(element_class, method_name = nil, template: nil)
12
12
  MethodBuilder
13
- .new(self, element_class, method_name)
13
+ .new(self, element_class, method_name, template: template)
14
14
  .prepare
15
15
  .build
16
16
  end
17
17
  end
18
+
19
+ attr_reader :model
20
+
21
+ def initialize(renderer, model)
22
+ @renderer = renderer
23
+ @model = model
24
+ end
25
+
26
+ def with_model(model, base: self.model)
27
+ new_model = [base, model].compact.join('.')
28
+
29
+ yield self.class.new(renderer, new_model)
30
+ end
31
+
32
+ def equal?(other)
33
+ return unless other.class == self.class
34
+
35
+ other.renderer == renderer &&
36
+ other.model == model
37
+ end
38
+
39
+ alias == equal?
40
+
41
+ protected
42
+
43
+ attr_reader :renderer
44
+
45
+ delegate :render, to: :renderer
18
46
  end
19
47
  end
@@ -6,19 +6,23 @@ module Magicka
6
6
  #
7
7
  # Class responsible for building an {Aggregator} method
8
8
  class MethodBuilder < Sinclair
9
- def initialize(klass, element_class, method_name = nil)
9
+ def initialize(klass, element_class, method_name = nil, template: nil)
10
10
  super(klass)
11
11
 
12
12
  @element_class = element_class
13
13
  @method_name = method_name
14
+ @template = template
14
15
  end
15
16
 
16
17
  def prepare
17
18
  element_klass = element_class
19
+ template_file = template
18
20
 
19
21
  add_method(method_name) do |field, model: self.model, **args|
20
22
  element_klass.render(
21
- renderer: renderer, field: field, model: model, **args
23
+ renderer: renderer, field: field,
24
+ model: model, template: template_file,
25
+ **args
22
26
  )
23
27
  end
24
28
 
@@ -27,7 +31,7 @@ module Magicka
27
31
 
28
32
  private
29
33
 
30
- attr_reader :element_class
34
+ attr_reader :element_class, :template
31
35
 
32
36
  def method_name
33
37
  @method_name ||= element_class
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Magicka
4
+ # Class responsible for controlling one object display
5
+ class Display < Aggregator
6
+ with_element(Text, :input)
7
+ with_element(Text, :select)
8
+
9
+ def button(**_args); end
10
+ end
11
+ end
@@ -77,8 +77,11 @@ module Magicka
77
77
  #
78
78
  # @return [String]
79
79
  def template
80
- self.class.name.underscore
81
- .gsub(%r{^.*/}, "#{template_folder}/")
80
+ @template ||= self
81
+ .class
82
+ .name
83
+ .underscore
84
+ .gsub(%r{^.*/}, "#{template_folder}/")
82
85
  end
83
86
  end
84
87
  end
@@ -14,7 +14,7 @@ module Magicka
14
14
  #
15
15
  # @return [Array<Sinclair::MethodDefinition>]
16
16
  def add_template(template)
17
- add_method(:template) do
17
+ add_method(:template, cached: true) do
18
18
  template
19
19
  end
20
20
 
data/lib/magicka/form.rb CHANGED
@@ -3,39 +3,11 @@
3
3
  module Magicka
4
4
  # Class responsible for controlling one object form
5
5
  class Form < Aggregator
6
- attr_reader :model
7
-
8
- def initialize(renderer, model)
9
- @renderer = renderer
10
- @model = model
11
- end
12
-
13
6
  with_element(Input)
14
7
  with_element(Select)
15
8
 
16
9
  def button(**args)
17
10
  Button.render(renderer: renderer, **args)
18
11
  end
19
-
20
- def with_model(model)
21
- new_model = [self.model, model].join('.')
22
-
23
- yield Form.new(renderer, new_model)
24
- end
25
-
26
- def equal?(other)
27
- return unless other.class == self.class
28
-
29
- other.renderer == renderer &&
30
- other.model == model
31
- end
32
-
33
- alias == equal?
34
-
35
- protected
36
-
37
- attr_reader :renderer
38
-
39
- delegate :render, to: :renderer
40
12
  end
41
13
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Magicka
4
+ # Helper module to be used on rails
5
+ module Helper
6
+ def magicka_form(model)
7
+ yield Form.new(self, model)
8
+ end
9
+
10
+ def magicka_display(model)
11
+ yield Display.new(self, model)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Magicka
4
+ # Input element representing an HTML +<input/>+
5
+ class Text < FormElement
6
+ template_folder 'templates/display'
7
+ end
8
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Magicka
4
- VERSION = '0.5.0'
4
+ VERSION = '0.5.5'
5
5
  end
data/magicka.gemspec CHANGED
@@ -19,17 +19,17 @@ Gem::Specification.new do |gem|
19
19
  gem.test_files = gem.files.grep(%r{^(test|gem|features)/})
20
20
  gem.require_paths = ['lib']
21
21
 
22
- gem.add_runtime_dependency 'activesupport', '~> 5.2.4.3'
22
+ gem.add_runtime_dependency 'activesupport', '~> 5.2.x'
23
23
  gem.add_runtime_dependency 'sinclair', '>= 1.6.7'
24
24
 
25
- gem.add_development_dependency 'actionpack', '5.2.4.3'
26
- gem.add_development_dependency 'activerecord', '5.2.4.3'
25
+ gem.add_development_dependency 'actionpack', '~> 5.2.x'
26
+ gem.add_development_dependency 'activerecord', '~> 5.2.x'
27
27
  gem.add_development_dependency 'bundler', '1.16.1'
28
28
  gem.add_development_dependency 'factory_bot', '5.2.0'
29
- gem.add_development_dependency 'nokogiri', '1.10.9'
29
+ gem.add_development_dependency 'nokogiri', '1.11.3'
30
30
  gem.add_development_dependency 'pry', '0.12.2'
31
31
  gem.add_development_dependency 'pry-nav', '0.3.0'
32
- gem.add_development_dependency 'rails', '5.2.4.3'
32
+ gem.add_development_dependency 'rails', '~> 5.2.x'
33
33
  gem.add_development_dependency 'rails-controller-testing', '1.0.4'
34
34
  gem.add_development_dependency 'rake', '13.0.1'
35
35
  gem.add_development_dependency 'reek', '5.6.0'
@@ -0,0 +1,209 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Magicka::Aggregator do
6
+ subject(:aggregator) { aggregator_class.new(renderer, model) }
7
+
8
+ let(:aggregator_class) { Class.new(described_class) }
9
+ let(:model) { :my_model }
10
+ let(:renderer) { instance_double('renderer') }
11
+ let(:template) { 'templates/forms/input' }
12
+ let(:locals) { {} }
13
+
14
+ describe '.with_element' do
15
+ context 'when seeting element class only' do
16
+ it do
17
+ expect { aggregator_class.with_element(Magicka::Input) }
18
+ .to add_method(:input)
19
+ .to(aggregator)
20
+ end
21
+
22
+ context 'when built method is called' do
23
+ let(:template) { 'templates/forms/input' }
24
+ let(:field) { :field }
25
+ let(:label) { 'Label' }
26
+ let(:placeholder) { 'Value' }
27
+
28
+ let(:locals) do
29
+ {
30
+ field: field,
31
+ label: label,
32
+ ng_errors: 'my_model.errors.field',
33
+ ng_model: 'my_model.field',
34
+ placeholder: placeholder
35
+ }
36
+ end
37
+
38
+ let(:arguments) do
39
+ {
40
+ label: label,
41
+ placeholder: placeholder
42
+ }
43
+ end
44
+
45
+ before do
46
+ aggregator_class.with_element(Magicka::Input)
47
+
48
+ allow(renderer)
49
+ .to receive(:render)
50
+ .with(partial: template, locals: locals)
51
+ end
52
+
53
+ it 'renders an input' do
54
+ aggregator.input(field, arguments)
55
+
56
+ expect(renderer).to have_received(:render)
57
+ end
58
+
59
+ context 'when passing a custom model' do
60
+ let(:locals) do
61
+ {
62
+ field: field,
63
+ label: label,
64
+ ng_errors: 'my_custom_model.errors.field',
65
+ ng_model: 'my_custom_model.field',
66
+ placeholder: placeholder
67
+ }
68
+ end
69
+
70
+ it 'renders an input' do
71
+ aggregator.input(field, model: 'my_custom_model', **arguments)
72
+
73
+ expect(renderer).to have_received(:render)
74
+ end
75
+ end
76
+ end
77
+ end
78
+
79
+ context 'when seeting element class and method' do
80
+ it do
81
+ expect { aggregator_class.with_element(Magicka::Input, :my_input) }
82
+ .to add_method(:my_input)
83
+ .to(aggregator)
84
+ end
85
+
86
+ context 'when built method is called' do
87
+ let(:template) { 'templates/forms/input' }
88
+ let(:field) { :field }
89
+ let(:label) { 'Label' }
90
+ let(:placeholder) { 'Value' }
91
+
92
+ let(:locals) do
93
+ {
94
+ field: field,
95
+ label: label,
96
+ ng_errors: 'my_model.errors.field',
97
+ ng_model: 'my_model.field',
98
+ placeholder: placeholder
99
+ }
100
+ end
101
+
102
+ let(:arguments) do
103
+ {
104
+ label: label,
105
+ placeholder: placeholder
106
+ }
107
+ end
108
+
109
+ before do
110
+ aggregator_class.with_element(Magicka::Input, :my_input)
111
+
112
+ allow(renderer)
113
+ .to receive(:render)
114
+ .with(partial: template, locals: locals)
115
+ end
116
+
117
+ it 'renders an input' do
118
+ aggregator.my_input(field, arguments)
119
+
120
+ expect(renderer).to have_received(:render)
121
+ end
122
+
123
+ context 'when passing a custom model' do
124
+ let(:locals) do
125
+ {
126
+ field: field,
127
+ label: label,
128
+ ng_errors: 'my_custom_model.errors.field',
129
+ ng_model: 'my_custom_model.field',
130
+ placeholder: placeholder
131
+ }
132
+ end
133
+
134
+ it 'renders an input' do
135
+ aggregator.my_input(field, model: 'my_custom_model', **arguments)
136
+
137
+ expect(renderer).to have_received(:render)
138
+ end
139
+ end
140
+ end
141
+ end
142
+
143
+ context 'when seeting element class and template' do
144
+ it do
145
+ expect do
146
+ aggregator_class.with_element(Magicka::Input, template: template)
147
+ end
148
+ .to add_method(:input)
149
+ .to(aggregator)
150
+ end
151
+
152
+ context 'when built method is called' do
153
+ let(:template) { 'my_templates/my_input' }
154
+ let(:field) { :field }
155
+ let(:label) { 'Label' }
156
+ let(:placeholder) { 'Value' }
157
+
158
+ let(:locals) do
159
+ {
160
+ field: field,
161
+ label: label,
162
+ ng_errors: 'my_model.errors.field',
163
+ ng_model: 'my_model.field',
164
+ placeholder: placeholder
165
+ }
166
+ end
167
+
168
+ let(:arguments) do
169
+ {
170
+ label: label,
171
+ placeholder: placeholder
172
+ }
173
+ end
174
+
175
+ before do
176
+ aggregator_class.with_element(Magicka::Input, template: template)
177
+
178
+ allow(renderer)
179
+ .to receive(:render)
180
+ .with(partial: template, locals: locals)
181
+ end
182
+
183
+ it 'renders an input' do
184
+ aggregator.input(field, arguments)
185
+
186
+ expect(renderer).to have_received(:render)
187
+ end
188
+
189
+ context 'when passing a custom model' do
190
+ let(:locals) do
191
+ {
192
+ field: field,
193
+ label: label,
194
+ ng_errors: 'my_custom_model.errors.field',
195
+ ng_model: 'my_custom_model.field',
196
+ placeholder: placeholder
197
+ }
198
+ end
199
+
200
+ it 'renders an input' do
201
+ aggregator.input(field, model: 'my_custom_model', **arguments)
202
+
203
+ expect(renderer).to have_received(:render)
204
+ end
205
+ end
206
+ end
207
+ end
208
+ end
209
+ end
@@ -0,0 +1,169 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Magicka::Display do
6
+ subject(:form) { described_class.new(renderer, model) }
7
+
8
+ let(:model) { :my_model }
9
+ let(:renderer) { instance_double('renderer') }
10
+ let(:template) { 'templates/display/text' }
11
+ let(:locals) { {} }
12
+
13
+ before do
14
+ allow(renderer)
15
+ .to receive(:render)
16
+ .with(partial: template, locals: locals)
17
+ end
18
+
19
+ describe '#input' do
20
+ let(:template) { 'templates/display/text' }
21
+ let(:field) { :field }
22
+ let(:label) { 'Label' }
23
+ let(:placeholder) { 'Value' }
24
+
25
+ let(:locals) do
26
+ {
27
+ field: field,
28
+ label: label,
29
+ ng_errors: 'my_model.errors.field',
30
+ ng_model: 'my_model.field'
31
+ }
32
+ end
33
+
34
+ let(:arguments) do
35
+ {
36
+ label: label,
37
+ placeholder: placeholder
38
+ }
39
+ end
40
+
41
+ it 'renders a text' do
42
+ form.input(field, arguments)
43
+
44
+ expect(renderer).to have_received(:render)
45
+ end
46
+
47
+ context 'when passing a custom model' do
48
+ let(:locals) do
49
+ {
50
+ field: field,
51
+ label: label,
52
+ ng_errors: 'my_custom_model.errors.field',
53
+ ng_model: 'my_custom_model.field'
54
+ }
55
+ end
56
+
57
+ it 'renders a text' do
58
+ form.input(field, model: 'my_custom_model', **arguments)
59
+
60
+ expect(renderer).to have_received(:render)
61
+ end
62
+ end
63
+ end
64
+
65
+ describe '#select' do
66
+ let(:template) { 'templates/display/text' }
67
+ let(:field) { :field }
68
+ let(:label) { 'Label' }
69
+ let(:options) { %i[option_a option_b] }
70
+
71
+ let(:locals) do
72
+ {
73
+ field: field,
74
+ label: label,
75
+ ng_errors: 'my_model.errors.field',
76
+ ng_model: 'my_model.field'
77
+ }
78
+ end
79
+
80
+ let(:arguments) do
81
+ {
82
+ label: label,
83
+ options: options
84
+ }
85
+ end
86
+
87
+ it 'renders a text' do
88
+ form.select(field, arguments)
89
+
90
+ expect(renderer).to have_received(:render)
91
+ end
92
+
93
+ context 'when passing a custom model' do
94
+ let(:locals) do
95
+ {
96
+ field: field,
97
+ label: label,
98
+ ng_errors: 'my_custom_model.errors.field',
99
+ ng_model: 'my_custom_model.field'
100
+ }
101
+ end
102
+
103
+ it 'renders a text' do
104
+ form.select(field, model: 'my_custom_model', **arguments)
105
+
106
+ expect(renderer).to have_received(:render)
107
+ end
108
+ end
109
+ end
110
+
111
+ describe '#button' do
112
+ let(:ng_click) { 'controler.click()' }
113
+ let(:ng_disabled) { 'false' }
114
+ let(:classes) { 'custom class' }
115
+ let(:text) { 'Click' }
116
+
117
+ let(:arguments) do
118
+ {
119
+ ng_click: ng_click,
120
+ ng_disabled: ng_disabled,
121
+ classes: classes,
122
+ text: text
123
+ }
124
+ end
125
+
126
+ it 'renders nothing' do
127
+ form.button(arguments)
128
+
129
+ expect(renderer).not_to have_received(:render)
130
+ end
131
+ end
132
+
133
+ describe '#with_model' do
134
+ let(:expected_form) { described_class.new(renderer, 'my_model.inner') }
135
+
136
+ it do
137
+ form.with_model(:inner) do |new_form|
138
+ expect(new_form).to eq(expected_form)
139
+ end
140
+ end
141
+ end
142
+
143
+ describe '#with_form' do
144
+ it do
145
+ form.with_model('sub') do |new_form|
146
+ expect(new_form)
147
+ .to eq(described_class.new(renderer, 'my_model.sub'))
148
+ end
149
+ end
150
+
151
+ context 'when passing a new base' do
152
+ it do
153
+ form.with_model('sub', base: :other_model) do |new_form|
154
+ expect(new_form)
155
+ .to eq(described_class.new(renderer, 'other_model.sub'))
156
+ end
157
+ end
158
+ end
159
+
160
+ context 'when passing an empty base' do
161
+ it do
162
+ form.with_model('sub', base: nil) do |new_form|
163
+ expect(new_form)
164
+ .to eq(described_class.new(renderer, 'sub'))
165
+ end
166
+ end
167
+ end
168
+ end
169
+ end
@@ -82,5 +82,46 @@ describe Magicka::Element do
82
82
  expect(renderer).to have_received(:render)
83
83
  end
84
84
  end
85
+
86
+ context 'when class has a template but is initialized with template' do
87
+ subject(:element) do
88
+ klass.new(renderer: renderer, template: custom_template)
89
+ end
90
+
91
+ let(:custom_template) { 'custom_folder/custom_template' }
92
+ let(:expected_template) { custom_template }
93
+
94
+ before do
95
+ klass.template(template)
96
+ end
97
+
98
+ it do
99
+ element.render
100
+
101
+ expect(renderer).to have_received(:render)
102
+ end
103
+ end
104
+
105
+ context 'when class has folder but is initialized with template' do
106
+ subject(:element) do
107
+ klass.new(renderer: renderer, template: custom_template)
108
+ end
109
+
110
+ let(:custom_template) { 'custom_folder/custom_template' }
111
+ let(:expected_template) { custom_template }
112
+
113
+ before do
114
+ klass.template_folder(folder)
115
+
116
+ method_builder.add_class_method(:name) { 'Magicka::MyElement' }
117
+ method_builder.build
118
+ end
119
+
120
+ it do
121
+ element.render
122
+
123
+ expect(renderer).to have_received(:render)
124
+ end
125
+ end
85
126
  end
86
127
  end
@@ -153,4 +153,31 @@ describe Magicka::Form do
153
153
  end
154
154
  end
155
155
  end
156
+
157
+ describe '#with_form' do
158
+ it do
159
+ form.with_model('sub') do |new_form|
160
+ expect(new_form)
161
+ .to eq(described_class.new(renderer, 'my_model.sub'))
162
+ end
163
+ end
164
+
165
+ context 'when passing a new base' do
166
+ it do
167
+ form.with_model('sub', base: :other_model) do |new_form|
168
+ expect(new_form)
169
+ .to eq(described_class.new(renderer, 'other_model.sub'))
170
+ end
171
+ end
172
+ end
173
+
174
+ context 'when passing an empty base' do
175
+ it do
176
+ form.with_model('sub', base: nil) do |new_form|
177
+ expect(new_form)
178
+ .to eq(described_class.new(renderer, 'sub'))
179
+ end
180
+ end
181
+ end
182
+ end
156
183
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Magicka::Text do
6
+ let(:renderer) { instance_double('renderer') }
7
+ let(:template) { 'templates/display/text' }
8
+
9
+ let(:model) { :my_model }
10
+ let(:field) { :field }
11
+ let(:label) { 'Label' }
12
+
13
+ let(:locals) do
14
+ {
15
+ field: field,
16
+ label: label,
17
+ ng_model: 'my_model.field',
18
+ ng_errors: 'my_model.errors.field'
19
+ }
20
+ end
21
+
22
+ describe '.render' do
23
+ let(:arguments) do
24
+ {
25
+ renderer: renderer,
26
+ field: field,
27
+ label: label,
28
+ model: model
29
+ }
30
+ end
31
+
32
+ before do
33
+ allow(renderer)
34
+ .to receive(:render)
35
+ .with(partial: template, locals: locals)
36
+ end
37
+
38
+ it do
39
+ described_class.render(arguments)
40
+
41
+ expect(renderer).to have_received(:render)
42
+ end
43
+
44
+ context 'when called with extra params' do
45
+ it do
46
+ described_class.render(name: 'Name', **arguments)
47
+
48
+ expect(renderer).to have_received(:render)
49
+ end
50
+ end
51
+ end
52
+ end
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: 0.5.0
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - DarthJee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-04 00:00:00.000000000 Z
11
+ date: 2021-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.4.3
19
+ version: 5.2.x
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 5.2.4.3
26
+ version: 5.2.x
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sinclair
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -42,30 +42,30 @@ dependencies:
42
42
  name: actionpack
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 5.2.4.3
47
+ version: 5.2.x
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 5.2.4.3
54
+ version: 5.2.x
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activerecord
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '='
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 5.2.4.3
61
+ version: 5.2.x
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '='
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 5.2.4.3
68
+ version: 5.2.x
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 1.10.9
103
+ version: 1.11.3
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 1.10.9
110
+ version: 1.11.3
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: pry
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -140,16 +140,16 @@ dependencies:
140
140
  name: rails
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '='
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 5.2.4.3
145
+ version: 5.2.x
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '='
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 5.2.4.3
152
+ version: 5.2.x
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rails-controller-testing
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -400,13 +400,16 @@ files:
400
400
  - lib/magicka/aggregator.rb
401
401
  - lib/magicka/aggregator/method_builder.rb
402
402
  - lib/magicka/button.rb
403
+ - lib/magicka/display.rb
403
404
  - lib/magicka/element.rb
404
405
  - lib/magicka/element/class_methods.rb
405
406
  - lib/magicka/element/method_builder.rb
406
407
  - lib/magicka/form.rb
407
408
  - lib/magicka/form_element.rb
409
+ - lib/magicka/helper.rb
408
410
  - lib/magicka/input.rb
409
411
  - lib/magicka/select.rb
412
+ - lib/magicka/text.rb
410
413
  - lib/magicka/version.rb
411
414
  - magicka.gemspec
412
415
  - magicka.jpg
@@ -471,7 +474,9 @@ files:
471
474
  - spec/dummy/storage/.keep
472
475
  - spec/integration/readme/.keep
473
476
  - spec/integration/yard/.keep
477
+ - spec/lib/magicka/aggregator_spec.rb
474
478
  - spec/lib/magicka/button_spec.rb
479
+ - spec/lib/magicka/display_spec.rb
475
480
  - spec/lib/magicka/element/class_methods_spec.rb
476
481
  - spec/lib/magicka/element/method_builder_spec.rb
477
482
  - spec/lib/magicka/element_spec.rb
@@ -479,6 +484,7 @@ files:
479
484
  - spec/lib/magicka/form_spec.rb
480
485
  - spec/lib/magicka/input_spec.rb
481
486
  - spec/lib/magicka/select_spec.rb
487
+ - spec/lib/magicka/text_spec.rb
482
488
  - spec/spec_helper.rb
483
489
  - spec/support/models/.keep
484
490
  - spec/support/shared_examples/.keep