danica 2.7.4 → 2.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +28 -0
- data/.gitignore +6 -1
- data/.rubocop.yml +9 -0
- data/.rubocop_todo.yml +100 -0
- data/Dockerfile +26 -0
- data/Gemfile +2 -1
- data/Rakefile +4 -0
- data/config/rubycritc.rb +12 -0
- data/config/yardstick.rb +13 -0
- data/config/yardstick.yml +33 -0
- data/danica.gemspec +14 -7
- data/docker-compose.yml +14 -9
- data/lib/danica.rb +2 -1
- data/lib/danica/base_operations.rb +2 -0
- data/lib/danica/builder.rb +2 -0
- data/lib/danica/common.rb +5 -2
- data/lib/danica/dsl.rb +8 -6
- data/lib/danica/dsl/builder.rb +3 -1
- data/lib/danica/equation.rb +3 -3
- data/lib/danica/equation/builder.rb +2 -0
- data/lib/danica/exception.rb +3 -2
- data/lib/danica/expressable.rb +14 -8
- data/lib/danica/expression.rb +4 -2
- data/lib/danica/expression/gauss.rb +5 -5
- data/lib/danica/formatted.rb +4 -2
- data/lib/danica/function.rb +5 -3
- data/lib/danica/function/name.rb +2 -0
- data/lib/danica/operator.rb +12 -9
- data/lib/danica/operator/addition.rb +4 -3
- data/lib/danica/operator/chained.rb +4 -3
- data/lib/danica/operator/cos.rb +2 -1
- data/lib/danica/operator/division.rb +2 -1
- data/lib/danica/operator/exponential.rb +2 -1
- data/lib/danica/operator/functional.rb +3 -2
- data/lib/danica/operator/multiplication.rb +4 -2
- data/lib/danica/operator/power.rb +4 -3
- data/lib/danica/operator/sin.rb +2 -1
- data/lib/danica/operator/squared_root.rb +2 -1
- data/lib/danica/variables_holder.rb +7 -4
- data/lib/danica/variables_holder/alias_builder.rb +4 -4
- data/lib/danica/variables_holder/calculator.rb +2 -0
- data/lib/danica/variables_holder/store.rb +3 -2
- data/lib/danica/variables_holder/variables_builder.rb +2 -1
- data/lib/danica/version.rb +3 -1
- data/lib/danica/wrapper.rb +11 -9
- data/lib/danica/wrapper/constant.rb +9 -14
- data/lib/danica/wrapper/container.rb +2 -3
- data/lib/danica/wrapper/group.rb +2 -2
- data/lib/danica/wrapper/negative.rb +2 -1
- data/lib/danica/wrapper/number.rb +4 -3
- data/lib/danica/wrapper/plus_minus.rb +2 -1
- data/lib/danica/wrapper/variable.rb +10 -8
- data/scripts/check_readme.sh +6 -0
- data/scripts/rubycritic.sh +10 -0
- data/spec/integration/global/danica/formatted_spec.rb +87 -0
- data/spec/integration/global/danica/operator/addition_spec.rb +32 -0
- data/spec/integration/{multiplication_spec.rb → global/danica/operator/multiplication_spec.rb} +12 -9
- data/spec/integration/{power_spec.rb → global/danica/operator/power_spec.rb} +4 -2
- data/spec/integration/{negative_spec.rb → global/danica/wrapper/negative_spec.rb} +9 -8
- data/spec/integration/{plus_minus_spec.rb → global/danica/wrapper/plus_minus_spec.rb} +5 -4
- data/spec/integration/readme/constant_spec.rb +4 -1
- data/spec/integration/readme/danica/formatted_spec.rb +24 -0
- data/spec/integration/readme/danica_spec.rb +20 -4
- data/spec/integration/readme/equation_spec.rb +4 -2
- data/spec/integration/readme/expression_spec.rb +11 -8
- data/spec/integration/readme/function_spec.rb +11 -7
- data/spec/integration/readme/number_spec.rb +9 -8
- data/spec/integration/readme/operator_spec.rb +3 -1
- data/spec/integration/readme/variables_spec.rb +8 -6
- data/spec/lib/danica/common_spec.rb +23 -9
- data/spec/lib/danica/dsl_spec.rb +5 -2
- data/spec/lib/danica/equation_spec.rb +10 -8
- data/spec/lib/danica/expressable_spec.rb +5 -2
- data/spec/lib/danica/expression/gauss_spec.rb +6 -3
- data/spec/lib/danica/expression_spec.rb +48 -26
- data/spec/lib/danica/formatted_spec.rb +20 -14
- data/spec/lib/danica/function/name_spec.rb +3 -1
- data/spec/lib/danica/function_spec.rb +14 -10
- data/spec/lib/danica/operator/addition_spec.rb +16 -15
- data/spec/lib/danica/operator/cos_spec.rb +9 -8
- data/spec/lib/danica/operator/division_spec.rb +18 -17
- data/spec/lib/danica/operator/exponential_spec.rb +9 -8
- data/spec/lib/danica/operator/multiplication_spec.rb +16 -15
- data/spec/lib/danica/operator/power_spec.rb +17 -16
- data/spec/lib/danica/operator/sin_spec.rb +9 -8
- data/spec/lib/danica/operator/squared_root_spec.rb +9 -8
- data/spec/lib/danica/operator_spec.rb +13 -4
- data/spec/lib/danica/variables_holder/store_spec.rb +19 -13
- data/spec/lib/danica/variables_holder_spec.rb +76 -59
- data/spec/lib/danica/wrapper/constant_spec.rb +9 -2
- data/spec/lib/danica/wrapper/group_spec.rb +4 -1
- data/spec/lib/danica/wrapper/negative_spec.rb +4 -1
- data/spec/lib/danica/wrapper/number_spec.rb +8 -3
- data/spec/lib/danica/wrapper/plus_minus_spec.rb +4 -1
- data/spec/lib/danica/wrapper/variable_spec.rb +6 -3
- data/spec/lib/danica/wrapper_spec.rb +14 -12
- data/spec/lib/danica_spec.rb +6 -5
- data/spec/spec_helper.rb +2 -1
- data/spec/support/models/expression/baskara.rb +3 -3
- data/spec/support/models/expression/parabole.rb +2 -0
- data/spec/support/models/expression/quadratic_sum.rb +3 -1
- data/spec/support/models/expression/spatial.rb +2 -1
- data/spec/support/models/function/my_function.rb +3 -1
- data/spec/support/models/function/parabole.rb +1 -1
- data/spec/support/models/function/quadratic_sum.rb +2 -0
- data/spec/support/models/function/spatial.rb +2 -0
- data/spec/support/models/operator/inverse.rb +3 -1
- data/spec/support/models/operator/my_operator.rb +3 -1
- data/spec/support/models/variables_holder/dummy.rb +3 -1
- data/spec/support/shared_contexts/common.rb +4 -2
- data/spec/support/shared_examples/base_operations.rb +7 -4
- data/spec/support/shared_examples/common.rb +3 -1
- data/spec/support/shared_examples/operator/chained.rb +12 -6
- data/spec/support/shared_examples/operator/dual_term.rb +9 -8
- data/spec/support/shared_examples/operator/single_input.rb +7 -2
- data/spec/support/shared_examples/variable.rb +8 -4
- metadata +109 -30
- data/spec/integration/addition_spec.rb +0 -28
- data/spec/integration/formatted_spec.rb +0 -75
- data/spec/integration/readme/formatting_spec.rb +0 -34
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
shared_examples 'an object that returns the default variables hash' do
|
@@ -11,12 +13,16 @@ shared_examples 'an object that returns the default variables hash' do
|
|
11
13
|
end
|
12
14
|
|
13
15
|
shared_examples 'an object that returns the default variables' do
|
14
|
-
|
15
|
-
|
16
|
+
let(:expected_variables) do
|
17
|
+
[
|
16
18
|
Danica::Wrapper::Variable.new(name: :x),
|
17
19
|
Danica::Wrapper::Variable.new(latex: '\y'),
|
18
20
|
Danica::Wrapper::Number.new(10)
|
19
|
-
]
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns the default variables hash' do
|
25
|
+
expect(subject.variables).to eq(expected_variables)
|
20
26
|
end
|
21
27
|
end
|
22
28
|
|
@@ -24,20 +30,20 @@ shared_examples 'an variable set that does not change the class variables' do
|
|
24
30
|
it 'does not change the the class variables' do
|
25
31
|
expect do
|
26
32
|
subject.variables = variables
|
27
|
-
end.not_to change
|
33
|
+
end.not_to change(clazz, :variables_hash)
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
31
37
|
shared_examples 'a class with mapped variables' do
|
32
38
|
context 'when initializing with an array' do
|
33
|
-
subject { clazz.new(1,2,3) }
|
39
|
+
subject { clazz.new(1, 2, 3) }
|
34
40
|
|
35
41
|
it 'initialize variables in order of declaration' do
|
36
|
-
expect(subject.variables_hash).to eq(
|
42
|
+
expect(subject.variables_hash).to eq(
|
37
43
|
x: Danica::Wrapper::Number.new(1),
|
38
44
|
y: Danica::Wrapper::Number.new(2),
|
39
45
|
z: Danica::Wrapper::Number.new(3)
|
40
|
-
|
46
|
+
)
|
41
47
|
end
|
42
48
|
end
|
43
49
|
|
@@ -45,55 +51,56 @@ shared_examples 'a class with mapped variables' do
|
|
45
51
|
subject { clazz.new(z: 1, y: 2) }
|
46
52
|
|
47
53
|
it 'initialize variables with the map given' do
|
48
|
-
expect(subject.variables_hash).to eq(
|
54
|
+
expect(subject.variables_hash).to eq(
|
49
55
|
x: Danica::Wrapper::Variable.new(name: :x),
|
50
56
|
y: Danica::Wrapper::Number.new(2),
|
51
57
|
z: Danica::Wrapper::Number.new(1)
|
52
|
-
|
58
|
+
)
|
53
59
|
end
|
54
60
|
end
|
55
61
|
|
56
62
|
context 'when initializing with hashes' do
|
57
63
|
subject do
|
58
64
|
clazz.new(
|
59
|
-
{name: :xis, value: 1},
|
60
|
-
{name: :yps, value: 2},
|
61
|
-
|
65
|
+
{ name: :xis, value: 1 },
|
66
|
+
{ name: :yps, value: 2 },
|
67
|
+
name: :zes, value: 3
|
62
68
|
)
|
63
69
|
end
|
64
70
|
|
65
71
|
it 'initialize variables with the maps given' do
|
66
|
-
expect(subject.variables_hash).to eq(
|
72
|
+
expect(subject.variables_hash).to eq(
|
67
73
|
x: Danica::Wrapper::Variable.new(name: :xis, value: 1),
|
68
74
|
y: Danica::Wrapper::Variable.new(name: :yps, value: 2),
|
69
75
|
z: Danica::Wrapper::Variable.new(name: :zes, value: 3)
|
70
|
-
|
76
|
+
)
|
71
77
|
end
|
72
78
|
end
|
73
79
|
|
74
80
|
context 'when initializing with array of hashes' do
|
75
81
|
subject do
|
76
82
|
clazz.new([
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
83
|
+
{ name: :xis, value: 1 },
|
84
|
+
{ name: :yps, value: 2 },
|
85
|
+
{ name: :zes, value: 3 }
|
86
|
+
])
|
81
87
|
end
|
82
88
|
|
83
89
|
it 'initialize variables with the maps given' do
|
84
|
-
expect(subject.variables_hash).to eq(
|
90
|
+
expect(subject.variables_hash).to eq(
|
85
91
|
x: Danica::Wrapper::Variable.new(name: :xis, value: 1),
|
86
92
|
y: Danica::Wrapper::Variable.new(name: :yps, value: 2),
|
87
93
|
z: Danica::Wrapper::Variable.new(name: :zes, value: 3)
|
88
|
-
|
94
|
+
)
|
89
95
|
end
|
90
96
|
end
|
91
97
|
end
|
92
98
|
|
93
99
|
describe Danica::VariablesHolder do
|
94
|
-
let(:clazz) { described_class::Dummy }
|
95
100
|
subject { clazz.new }
|
96
101
|
|
102
|
+
let(:clazz) { described_class::Dummy }
|
103
|
+
|
97
104
|
describe '#initialize' do
|
98
105
|
context 'when using a symbolized key definition' do
|
99
106
|
it_behaves_like 'a class with mapped variables'
|
@@ -101,18 +108,24 @@ describe Danica::VariablesHolder do
|
|
101
108
|
|
102
109
|
context 'when using a string key definition' do
|
103
110
|
let(:clazz) { described_class::DummyString }
|
111
|
+
|
104
112
|
it_behaves_like 'a class with mapped variables'
|
105
113
|
end
|
106
114
|
end
|
107
115
|
|
108
116
|
describe 'variables assignement' do
|
109
|
-
it 'creates setters
|
110
|
-
%i
|
111
|
-
expect(subject).to respond_to(var)
|
117
|
+
it 'creates setters for the variables' do
|
118
|
+
%i[x y z].each do |var|
|
112
119
|
expect(subject).to respond_to("#{var}=")
|
113
120
|
end
|
114
121
|
end
|
115
122
|
|
123
|
+
it 'creates getters for the variables' do
|
124
|
+
%i[x y z].each do |var|
|
125
|
+
expect(subject).to respond_to(var)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
116
129
|
it 'accepts variable assignment' do
|
117
130
|
expect do
|
118
131
|
subject.x = 1
|
@@ -134,14 +147,14 @@ describe Danica::VariablesHolder do
|
|
134
147
|
|
135
148
|
describe '.variables_names' do
|
136
149
|
it 'returns the list of variables pre configured' do
|
137
|
-
expect(clazz.variables_names).to eq(%i
|
150
|
+
expect(clazz.variables_names).to eq(%i[x y z])
|
138
151
|
end
|
139
152
|
|
140
153
|
context 'when variables are defined in super class' do
|
141
154
|
let(:clazz) { described_class::DummyChild }
|
142
155
|
|
143
156
|
it 'returns the list of variables of both classes merged' do
|
144
|
-
expect(clazz.variables_names).to eq(%i
|
157
|
+
expect(clazz.variables_names).to eq(%i[x y z k])
|
145
158
|
end
|
146
159
|
end
|
147
160
|
|
@@ -149,7 +162,7 @@ describe Danica::VariablesHolder do
|
|
149
162
|
let(:clazz) { described_class::DummyOverwrite }
|
150
163
|
|
151
164
|
it 'returns the list of variables of both classes merged' do
|
152
|
-
expect(clazz.variables_names).to eq(%i
|
165
|
+
expect(clazz.variables_names).to eq(%i[k z])
|
153
166
|
end
|
154
167
|
end
|
155
168
|
end
|
@@ -159,7 +172,7 @@ describe Danica::VariablesHolder do
|
|
159
172
|
let(:clazz) { described_class::DummyAlias }
|
160
173
|
|
161
174
|
it 'returns the list of variables of both classes merged' do
|
162
|
-
expect(clazz.variables_names).to eq(%i
|
175
|
+
expect(clazz.variables_names).to eq(%i[a y z])
|
163
176
|
end
|
164
177
|
|
165
178
|
context 'when original variable is set' do
|
@@ -175,9 +188,7 @@ describe Danica::VariablesHolder do
|
|
175
188
|
|
176
189
|
context 'when changing the new alias value' do
|
177
190
|
it do
|
178
|
-
expect
|
179
|
-
subject.a = 20
|
180
|
-
end.to change { subject.x.content }
|
191
|
+
expect { subject.a = 20 }.to(change { subject.x.content })
|
181
192
|
end
|
182
193
|
end
|
183
194
|
end
|
@@ -195,9 +206,8 @@ describe Danica::VariablesHolder do
|
|
195
206
|
|
196
207
|
context 'when changing the original variable value' do
|
197
208
|
it do
|
198
|
-
expect
|
199
|
-
subject.
|
200
|
-
end.to change { subject.a.content }
|
209
|
+
expect { subject.x = 20 }
|
210
|
+
.to(change { subject.a.content })
|
201
211
|
end
|
202
212
|
end
|
203
213
|
end
|
@@ -208,21 +218,25 @@ describe Danica::VariablesHolder do
|
|
208
218
|
context 'when changing the variables of the object' do
|
209
219
|
context 'when all the variables are set with value' do
|
210
220
|
let(:variables) { [1, 2, 3] }
|
221
|
+
|
211
222
|
it_behaves_like 'an variable set that does not change the class variables'
|
212
223
|
end
|
213
224
|
|
214
|
-
context 'setting the variables through a hash' do
|
225
|
+
context 'when setting the variables through a hash' do
|
215
226
|
let(:variables) { { x: 1, y: 2, z: 3 } }
|
227
|
+
|
216
228
|
it_behaves_like 'an variable set that does not change the class variables'
|
217
229
|
end
|
218
230
|
|
219
231
|
context 'when none of the variables are set with values' do
|
220
232
|
let(:variables) { [] }
|
233
|
+
|
221
234
|
it_behaves_like 'an variable set that does not change the class variables'
|
222
235
|
end
|
223
236
|
|
224
237
|
context 'when the variables are set through an empty hash' do
|
225
238
|
let(:variables) { {} }
|
239
|
+
|
226
240
|
it_behaves_like 'an variable set that does not change the class variables'
|
227
241
|
end
|
228
242
|
end
|
@@ -231,14 +245,16 @@ describe Danica::VariablesHolder do
|
|
231
245
|
before do
|
232
246
|
subject.variables = variables
|
233
247
|
end
|
248
|
+
|
234
249
|
let(:variables) { [1, 2, 3] }
|
235
250
|
|
236
251
|
it 'changes the values of the variables' do
|
237
252
|
expect(subject.x).to eq(Danica::Wrapper::Number.new(1))
|
238
253
|
end
|
239
254
|
|
240
|
-
context '
|
255
|
+
context 'when the array is empty' do
|
241
256
|
let(:variables) { [] }
|
257
|
+
|
242
258
|
it_behaves_like 'an object that returns the default variables hash'
|
243
259
|
end
|
244
260
|
end
|
@@ -254,8 +270,9 @@ describe Danica::VariablesHolder do
|
|
254
270
|
expect(subject.x).to eq(Danica::Wrapper::Number.new(1))
|
255
271
|
end
|
256
272
|
|
257
|
-
context '
|
273
|
+
context 'when the hash is empty' do
|
258
274
|
let(:variables) { {} }
|
275
|
+
|
259
276
|
it_behaves_like 'an object that returns the default variables hash'
|
260
277
|
end
|
261
278
|
end
|
@@ -277,10 +294,10 @@ describe Danica::VariablesHolder do
|
|
277
294
|
|
278
295
|
it 'returns the default variables and the new set one' do
|
279
296
|
expect(subject.variables).to eq([
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
297
|
+
Danica::Wrapper::Variable.new(name: :x),
|
298
|
+
Danica::Wrapper::Number.new(1),
|
299
|
+
Danica::Wrapper::Number.new(10)
|
300
|
+
])
|
284
301
|
end
|
285
302
|
|
286
303
|
it 'does not change the class variables' do
|
@@ -314,7 +331,7 @@ describe Danica::VariablesHolder do
|
|
314
331
|
describe '#variables_value_hash' do
|
315
332
|
context 'when instance has no variables defined' do
|
316
333
|
it 'returns the default value' do
|
317
|
-
expect(subject.variables_value_hash).to eq(
|
334
|
+
expect(subject.variables_value_hash).to eq(x: nil, y: nil, z: 10)
|
318
335
|
end
|
319
336
|
end
|
320
337
|
|
@@ -324,7 +341,7 @@ describe Danica::VariablesHolder do
|
|
324
341
|
end
|
325
342
|
|
326
343
|
it 'returns the values' do
|
327
|
-
expect(subject.variables_value_hash).to eq(
|
344
|
+
expect(subject.variables_value_hash).to eq(x: nil, y: 1, z: 10)
|
328
345
|
end
|
329
346
|
end
|
330
347
|
end
|
@@ -338,24 +355,24 @@ describe Danica::VariablesHolder do
|
|
338
355
|
let(:containers) { subject.containers }
|
339
356
|
|
340
357
|
it 'changes the variables in the containers' do
|
341
|
-
expect
|
342
|
-
|
343
|
-
end.to change { containers.map(&:content) }
|
358
|
+
expect { subject.x = 2 }
|
359
|
+
.to(change { containers.map(&:content) })
|
344
360
|
end
|
345
361
|
end
|
346
362
|
end
|
347
363
|
|
348
364
|
describe '#extract_variables' do
|
349
365
|
let(:clazz) { described_class::DummyChild }
|
366
|
+
|
350
367
|
context 'when holder has straight variables' do
|
351
368
|
it 'returns the variables hash' do
|
352
|
-
expect(subject.extract_variables).to eq(subject.containers.as_hash([
|
369
|
+
expect(subject.extract_variables).to eq(subject.containers.as_hash(%i[x y zeta k]))
|
353
370
|
end
|
354
371
|
|
355
|
-
context '
|
372
|
+
context 'when one of them is a number' do
|
356
373
|
let(:clazz) { described_class::Dummy }
|
357
374
|
let(:expected) do
|
358
|
-
subject.containers_hash.reject { |k,
|
375
|
+
subject.containers_hash.reject { |k, _v| k == :z }
|
359
376
|
end
|
360
377
|
|
361
378
|
it 'returns only the variables' do
|
@@ -368,7 +385,7 @@ describe Danica::VariablesHolder do
|
|
368
385
|
let(:subject) { clazz.new(x: :xis, y: :lambda, z: :zeta, k: :key) }
|
369
386
|
|
370
387
|
it 'returns the names as keys' do
|
371
|
-
expect(subject.extract_variables.keys).to eq(%i
|
388
|
+
expect(subject.extract_variables.keys).to eq(%i[xis lambda zeta key])
|
372
389
|
end
|
373
390
|
end
|
374
391
|
|
@@ -378,8 +395,8 @@ describe Danica::VariablesHolder do
|
|
378
395
|
clazz.new(z: inner)
|
379
396
|
end
|
380
397
|
let(:expected) do
|
381
|
-
subject.containers_hash.reject { |k,
|
382
|
-
|
398
|
+
subject.containers_hash.reject { |k, _v| k == :z }
|
399
|
+
.merge(inner.containers_hash)
|
383
400
|
end
|
384
401
|
|
385
402
|
it 'returns the ineer variables of the inner holder as well' do
|
@@ -389,7 +406,7 @@ describe Danica::VariablesHolder do
|
|
389
406
|
context 'when inner holder has the same variables' do
|
390
407
|
let(:inner) { clazz.new }
|
391
408
|
let(:expected) do
|
392
|
-
inner.containers.as_hash([
|
409
|
+
inner.containers.as_hash(%i[x y zeta k])
|
393
410
|
end
|
394
411
|
|
395
412
|
it 'merges them together in favor of the inner variables' do
|
@@ -406,7 +423,7 @@ describe Danica::VariablesHolder do
|
|
406
423
|
expect { subject.calculate }.to raise_error(Danica::Exception::NotDefined)
|
407
424
|
end
|
408
425
|
|
409
|
-
context '
|
426
|
+
context 'when it does not complete the values' do
|
410
427
|
it do
|
411
428
|
expect { subject.calculate(2) }.to raise_error(Danica::Exception::NotDefined)
|
412
429
|
end
|
@@ -414,7 +431,7 @@ describe Danica::VariablesHolder do
|
|
414
431
|
end
|
415
432
|
|
416
433
|
context 'when passing the values' do
|
417
|
-
context '
|
434
|
+
context 'when values are a list' do
|
418
435
|
it do
|
419
436
|
expect { subject.calculate(2, 4) }.not_to raise_error
|
420
437
|
end
|
@@ -423,7 +440,7 @@ describe Danica::VariablesHolder do
|
|
423
440
|
expect(subject.calculate(2, 4)).to eq(26)
|
424
441
|
end
|
425
442
|
|
426
|
-
context '
|
443
|
+
context 'when replacing all the values' do
|
427
444
|
it do
|
428
445
|
expect { subject.calculate(2, 4, 5) }.not_to raise_error
|
429
446
|
end
|
@@ -434,8 +451,8 @@ describe Danica::VariablesHolder do
|
|
434
451
|
end
|
435
452
|
end
|
436
453
|
|
437
|
-
context '
|
438
|
-
context '
|
454
|
+
context 'when the values are hash' do
|
455
|
+
context 'when it completes the values' do
|
439
456
|
it do
|
440
457
|
expect { subject.calculate(x: 2, y: 4) }.not_to raise_error
|
441
458
|
end
|
@@ -445,7 +462,7 @@ describe Danica::VariablesHolder do
|
|
445
462
|
end
|
446
463
|
end
|
447
464
|
|
448
|
-
context '
|
465
|
+
context 'when it does not complete the values' do
|
449
466
|
it do
|
450
467
|
expect { subject.calculate(x: 2, z: 4) }.to raise_error(Danica::Exception::NotDefined)
|
451
468
|
end
|
@@ -1,7 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Danica::Wrapper::Constant do
|
4
6
|
subject { described_class.new(2.5, :M, :m) }
|
7
|
+
|
5
8
|
let(:other) { described_class.new(3, :N, :n) }
|
6
9
|
|
7
10
|
it_behaves_like 'an object that respond to basic_methods'
|
@@ -25,22 +28,26 @@ describe Danica::Wrapper::Constant do
|
|
25
28
|
expect(subject.to(:tex)).to eq('M')
|
26
29
|
end
|
27
30
|
end
|
31
|
+
|
28
32
|
context "when requesting 'tex'" do
|
29
33
|
it 'has a string for latex' do
|
30
34
|
expect(subject.to('tex')).to eq('M')
|
31
35
|
end
|
32
36
|
end
|
37
|
+
|
33
38
|
context 'when requesting :gnu' do
|
34
39
|
it 'has a string for gnu' do
|
35
40
|
expect(subject.to(:gnu)).to eq('m')
|
36
41
|
end
|
37
42
|
end
|
43
|
+
|
38
44
|
context "when requesting 'gnu'" do
|
39
45
|
it 'has a string for gnu' do
|
40
46
|
expect(subject.to('gnu')).to eq('m')
|
41
47
|
end
|
42
48
|
end
|
43
|
-
|
49
|
+
|
50
|
+
context 'when requesting wrong format' do
|
44
51
|
it do
|
45
52
|
expect do
|
46
53
|
subject.to('format')
|
@@ -95,9 +102,9 @@ describe Danica::Wrapper::Constant do
|
|
95
102
|
|
96
103
|
context 'with same values' do
|
97
104
|
let(:other) { described_class.new(2.5, :M, :m) }
|
105
|
+
|
98
106
|
it { expect(subject).to eq(other) }
|
99
107
|
end
|
100
108
|
end
|
101
109
|
end
|
102
110
|
end
|
103
|
-
|
@@ -1,9 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Danica::Wrapper::Group do
|
4
|
-
let(:value) { 10 }
|
5
6
|
subject { described_class.new(value) }
|
6
7
|
|
8
|
+
let(:value) { 10 }
|
9
|
+
|
7
10
|
it_behaves_like 'an object that respond to basic_methods'
|
8
11
|
it_behaves_like 'an object with basic operation'
|
9
12
|
|