magicka 0.5.1 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +3 -3
- data/.rubocop.yml +1 -1
- data/Dockerfile +1 -1
- data/README.md +75 -3
- data/config/check_specs.yml +1 -1
- data/config/yardstick.yml +1 -1
- data/lib/magicka.rb +1 -0
- data/lib/magicka/aggregator.rb +4 -4
- data/lib/magicka/aggregator/method_builder.rb +7 -3
- data/lib/magicka/element.rb +5 -2
- data/lib/magicka/element/method_builder.rb +1 -1
- data/lib/magicka/helper.rb +14 -0
- data/lib/magicka/version.rb +1 -1
- data/magicka.gemspec +12 -12
- data/spec/lib/magicka/aggregator_spec.rb +209 -0
- data/spec/lib/magicka/display_spec.rb +27 -0
- data/spec/lib/magicka/element_spec.rb +41 -0
- data/spec/lib/magicka/form_spec.rb +27 -0
- metadata +34 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b014302f0498ecea2e69670c168bdf2ee5eaaa8162b210faf007351d4417976
|
4
|
+
data.tar.gz: 1ee57425d99ce223334f9567156ff1ab791f78e6f043c9ae5adca87291e28f1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37e81304adc719f63fd65d3a643d2392cca27fdce94489072f675571b440815f074e9bf5613bf365dae1b8f26edc24cdf4a564d8821e69a49d4419488bf7cd0c
|
7
|
+
data.tar.gz: 20b572511516fd8af749499059b2d14d01bf0047fbe3b509304b4c117032b617427aa84d7389ed400aa5b9acfb0d6c6dff539cd67e448b55e0c25dd5582f17ab
|
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.
|
25
|
+
- image: darthjee/circleci_rails_gems:0.7.0
|
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.
|
44
|
+
- image: darthjee/circleci_rails_gems:0.7.0
|
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.
|
69
|
+
- image: darthjee/circleci_rails_gems:0.7.0
|
70
70
|
environment:
|
71
71
|
PROJECT: magicka
|
72
72
|
steps:
|
data/.rubocop.yml
CHANGED
data/Dockerfile
CHANGED
data/README.md
CHANGED
@@ -9,20 +9,23 @@ Magicka
|
|
9
9
|
|
10
10
|
![magicka](https://raw.githubusercontent.com/darthjee/magicka/master/magicka.jpg)
|
11
11
|
|
12
|
+
Magica helps creating html templates for forms and display data using js applications
|
13
|
+
such as AngulaJS
|
14
|
+
|
12
15
|
Yard Documentation
|
13
16
|
-------------------
|
14
|
-
[https://www.rubydoc.info/gems/magicka/0.5.
|
17
|
+
[https://www.rubydoc.info/gems/magicka/0.5.6](https://www.rubydoc.info/gems/magicka/0.5.6)
|
15
18
|
|
16
19
|
Installation
|
17
20
|
---------------
|
18
21
|
|
19
|
-
-
|
22
|
+
- Install it
|
20
23
|
|
21
24
|
```ruby
|
22
25
|
gem install magicka
|
23
26
|
```
|
24
27
|
|
25
|
-
-
|
28
|
+
- Or add Magicka to your `Gemfile` and `bundle install`:
|
26
29
|
|
27
30
|
```ruby
|
28
31
|
gem 'magicka'
|
@@ -31,3 +34,72 @@ Installation
|
|
31
34
|
```bash
|
32
35
|
bundle install magicka
|
33
36
|
```
|
37
|
+
|
38
|
+
## Usage
|
39
|
+
Magicka is used as a helper for erb coding so that each element is paired with an
|
40
|
+
element class, a template and a method in an aggregator.
|
41
|
+
|
42
|
+
Different aggregators have the same method so that they render the same `element` in
|
43
|
+
different ways
|
44
|
+
|
45
|
+
### example
|
46
|
+
```html.erb
|
47
|
+
<!-- new.html.erb -->
|
48
|
+
|
49
|
+
<% magicka_form('controller.person') do |form| %>
|
50
|
+
<%= render partial: 'person_form', locals: { form: form } %>
|
51
|
+
<% end %>
|
52
|
+
```
|
53
|
+
|
54
|
+
```html.erb
|
55
|
+
<!-- show.html.erb -->
|
56
|
+
|
57
|
+
<% magicka_display('controller.person') do |form| %>
|
58
|
+
<%= render partial: 'person_form', locals: { form: form } %>
|
59
|
+
<% end %>
|
60
|
+
```
|
61
|
+
|
62
|
+
```html.erb
|
63
|
+
<!-- _person_form.html.erb -->
|
64
|
+
|
65
|
+
<%= form.input(:first_name) %>
|
66
|
+
<%= form.input(:last_name) %>
|
67
|
+
<%= form.input(:age) %>
|
68
|
+
<%= form.select(:gender, options: %w[MALE FEMALE] %>
|
69
|
+
<%= form.button(ng_click: 'controller.save', text: 'Save') %>
|
70
|
+
```
|
71
|
+
|
72
|
+
## Configuring
|
73
|
+
In order to use magicka, the helper has to added to the controllers and any custom
|
74
|
+
element needs to added
|
75
|
+
|
76
|
+
`app/controllers/application_controller.rb`
|
77
|
+
```ruby
|
78
|
+
class ApplicationController < ActionController::Base
|
79
|
+
helper Magicka::Helper
|
80
|
+
end
|
81
|
+
```
|
82
|
+
|
83
|
+
### Including custom elements
|
84
|
+
|
85
|
+
Elements can be included by defining attributes that they can be initialized with
|
86
|
+
and that can be passed to the template
|
87
|
+
|
88
|
+
`config/initializers/magicka.rb`
|
89
|
+
```ruby
|
90
|
+
module Magicka
|
91
|
+
class MyTextInput < Magicka::Element
|
92
|
+
with_attribute_locals :label, :field, :id
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
Magicka::Form.with_element(Magicka::MyTextInput)
|
97
|
+
```
|
98
|
+
|
99
|
+
`templates/form/_my_text_input.html.erb`
|
100
|
+
```html.erb
|
101
|
+
<div>
|
102
|
+
<label for="<%= field %>"><%= label %></label>
|
103
|
+
<input type="text" id="<%= id %>" name="field" />
|
104
|
+
</div>
|
105
|
+
```
|
data/config/check_specs.yml
CHANGED
data/config/yardstick.yml
CHANGED
data/lib/magicka.rb
CHANGED
@@ -17,6 +17,7 @@ module Magicka
|
|
17
17
|
autoload :Element, 'magicka/element'
|
18
18
|
autoload :FormElement, 'magicka/form_element'
|
19
19
|
autoload :Form, 'magicka/form'
|
20
|
+
autoload :Helper, 'magicka/helper'
|
20
21
|
autoload :Input, 'magicka/input'
|
21
22
|
autoload :Select, 'magicka/select'
|
22
23
|
autoload :Text, 'magicka/text'
|
data/lib/magicka/aggregator.rb
CHANGED
@@ -8,9 +8,9 @@ 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
|
@@ -23,8 +23,8 @@ module Magicka
|
|
23
23
|
@model = model
|
24
24
|
end
|
25
25
|
|
26
|
-
def with_model(model)
|
27
|
-
new_model = [
|
26
|
+
def with_model(model, base: self.model)
|
27
|
+
new_model = [base, model].compact.join('.')
|
28
28
|
|
29
29
|
yield self.class.new(renderer, new_model)
|
30
30
|
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,
|
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
|
data/lib/magicka/element.rb
CHANGED
data/lib/magicka/version.rb
CHANGED
data/magicka.gemspec
CHANGED
@@ -19,31 +19,31 @@ 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.
|
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.
|
26
|
-
gem.add_development_dependency 'activerecord', '5.2.
|
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.
|
29
|
+
gem.add_development_dependency 'nokogiri', '1.11.4'
|
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.
|
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
|
-
gem.add_development_dependency 'reek', '
|
35
|
+
gem.add_development_dependency 'reek', '6.0.3'
|
36
36
|
gem.add_development_dependency 'rspec', '3.9.0'
|
37
|
-
gem.add_development_dependency 'rspec-core', '3.9.
|
38
|
-
gem.add_development_dependency 'rspec-expectations', '3.9.
|
37
|
+
gem.add_development_dependency 'rspec-core', '3.9.3'
|
38
|
+
gem.add_development_dependency 'rspec-expectations', '3.9.4'
|
39
39
|
gem.add_development_dependency 'rspec-mocks', '3.9.1'
|
40
|
-
gem.add_development_dependency 'rspec-rails', '3.9.
|
41
|
-
gem.add_development_dependency 'rspec-support', '3.9.
|
40
|
+
gem.add_development_dependency 'rspec-rails', '3.9.1'
|
41
|
+
gem.add_development_dependency 'rspec-support', '3.9.4'
|
42
42
|
gem.add_development_dependency 'rubocop', '0.80.1'
|
43
43
|
gem.add_development_dependency 'rubocop-rspec', '1.38.1'
|
44
|
-
gem.add_development_dependency 'rubycritic', '4.
|
44
|
+
gem.add_development_dependency 'rubycritic', '4.6.1'
|
45
45
|
gem.add_development_dependency 'simplecov', '0.17.1'
|
46
46
|
gem.add_development_dependency 'sqlite3', '1.4.2'
|
47
|
-
gem.add_development_dependency 'yard', '0.9.
|
47
|
+
gem.add_development_dependency 'yard', '0.9.26'
|
48
48
|
gem.add_development_dependency 'yardstick', '0.9.9'
|
49
49
|
end
|
@@ -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
|
@@ -139,4 +139,31 @@ describe Magicka::Display do
|
|
139
139
|
end
|
140
140
|
end
|
141
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
|
142
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
|
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.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DarthJee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-21 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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
103
|
+
version: 1.11.4
|
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.
|
110
|
+
version: 1.11.4
|
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.
|
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.
|
152
|
+
version: 5.2.x
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: rails-controller-testing
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,14 +184,14 @@ dependencies:
|
|
184
184
|
requirements:
|
185
185
|
- - '='
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
187
|
+
version: 6.0.3
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
192
|
- - '='
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version:
|
194
|
+
version: 6.0.3
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: rspec
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,28 +212,28 @@ dependencies:
|
|
212
212
|
requirements:
|
213
213
|
- - '='
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version: 3.9.
|
215
|
+
version: 3.9.3
|
216
216
|
type: :development
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
220
|
- - '='
|
221
221
|
- !ruby/object:Gem::Version
|
222
|
-
version: 3.9.
|
222
|
+
version: 3.9.3
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
224
|
name: rspec-expectations
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
226
226
|
requirements:
|
227
227
|
- - '='
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version: 3.9.
|
229
|
+
version: 3.9.4
|
230
230
|
type: :development
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
234
|
- - '='
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
version: 3.9.
|
236
|
+
version: 3.9.4
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: rspec-mocks
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -254,28 +254,28 @@ dependencies:
|
|
254
254
|
requirements:
|
255
255
|
- - '='
|
256
256
|
- !ruby/object:Gem::Version
|
257
|
-
version: 3.9.
|
257
|
+
version: 3.9.1
|
258
258
|
type: :development
|
259
259
|
prerelease: false
|
260
260
|
version_requirements: !ruby/object:Gem::Requirement
|
261
261
|
requirements:
|
262
262
|
- - '='
|
263
263
|
- !ruby/object:Gem::Version
|
264
|
-
version: 3.9.
|
264
|
+
version: 3.9.1
|
265
265
|
- !ruby/object:Gem::Dependency
|
266
266
|
name: rspec-support
|
267
267
|
requirement: !ruby/object:Gem::Requirement
|
268
268
|
requirements:
|
269
269
|
- - '='
|
270
270
|
- !ruby/object:Gem::Version
|
271
|
-
version: 3.9.
|
271
|
+
version: 3.9.4
|
272
272
|
type: :development
|
273
273
|
prerelease: false
|
274
274
|
version_requirements: !ruby/object:Gem::Requirement
|
275
275
|
requirements:
|
276
276
|
- - '='
|
277
277
|
- !ruby/object:Gem::Version
|
278
|
-
version: 3.9.
|
278
|
+
version: 3.9.4
|
279
279
|
- !ruby/object:Gem::Dependency
|
280
280
|
name: rubocop
|
281
281
|
requirement: !ruby/object:Gem::Requirement
|
@@ -310,14 +310,14 @@ dependencies:
|
|
310
310
|
requirements:
|
311
311
|
- - '='
|
312
312
|
- !ruby/object:Gem::Version
|
313
|
-
version: 4.
|
313
|
+
version: 4.6.1
|
314
314
|
type: :development
|
315
315
|
prerelease: false
|
316
316
|
version_requirements: !ruby/object:Gem::Requirement
|
317
317
|
requirements:
|
318
318
|
- - '='
|
319
319
|
- !ruby/object:Gem::Version
|
320
|
-
version: 4.
|
320
|
+
version: 4.6.1
|
321
321
|
- !ruby/object:Gem::Dependency
|
322
322
|
name: simplecov
|
323
323
|
requirement: !ruby/object:Gem::Requirement
|
@@ -352,14 +352,14 @@ dependencies:
|
|
352
352
|
requirements:
|
353
353
|
- - '='
|
354
354
|
- !ruby/object:Gem::Version
|
355
|
-
version: 0.9.
|
355
|
+
version: 0.9.26
|
356
356
|
type: :development
|
357
357
|
prerelease: false
|
358
358
|
version_requirements: !ruby/object:Gem::Requirement
|
359
359
|
requirements:
|
360
360
|
- - '='
|
361
361
|
- !ruby/object:Gem::Version
|
362
|
-
version: 0.9.
|
362
|
+
version: 0.9.26
|
363
363
|
- !ruby/object:Gem::Dependency
|
364
364
|
name: yardstick
|
365
365
|
requirement: !ruby/object:Gem::Requirement
|
@@ -406,6 +406,7 @@ files:
|
|
406
406
|
- lib/magicka/element/method_builder.rb
|
407
407
|
- lib/magicka/form.rb
|
408
408
|
- lib/magicka/form_element.rb
|
409
|
+
- lib/magicka/helper.rb
|
409
410
|
- lib/magicka/input.rb
|
410
411
|
- lib/magicka/select.rb
|
411
412
|
- lib/magicka/text.rb
|
@@ -473,6 +474,7 @@ files:
|
|
473
474
|
- spec/dummy/storage/.keep
|
474
475
|
- spec/integration/readme/.keep
|
475
476
|
- spec/integration/yard/.keep
|
477
|
+
- spec/lib/magicka/aggregator_spec.rb
|
476
478
|
- spec/lib/magicka/button_spec.rb
|
477
479
|
- spec/lib/magicka/display_spec.rb
|
478
480
|
- spec/lib/magicka/element/class_methods_spec.rb
|