danica 2.7.6 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +18 -10
  3. data/.rubocop.yml +11 -1
  4. data/.rubocop_todo.yml +50 -73
  5. data/Dockerfile +2 -2
  6. data/Gemfile +15 -0
  7. data/Makefile +7 -0
  8. data/README.md +7 -1
  9. data/danica.gemspec +3 -16
  10. data/danica.png +0 -0
  11. data/lib/danica/common.rb +13 -13
  12. data/lib/danica/dsl.rb +4 -4
  13. data/lib/danica/equation/builder.rb +2 -2
  14. data/lib/danica/equation.rb +6 -6
  15. data/lib/danica/exception.rb +2 -0
  16. data/lib/danica/expressable.rb +1 -1
  17. data/lib/danica/formatted.rb +10 -10
  18. data/lib/danica/function/name.rb +3 -3
  19. data/lib/danica/function.rb +2 -2
  20. data/lib/danica/operator/chained.rb +4 -4
  21. data/lib/danica/operator/division.rb +4 -4
  22. data/lib/danica/operator/functional.rb +3 -3
  23. data/lib/danica/operator/power.rb +4 -4
  24. data/lib/danica/variables_holder/alias_builder.rb +15 -1
  25. data/lib/danica/variables_holder/variables_builder.rb +11 -10
  26. data/lib/danica/variables_holder.rb +4 -4
  27. data/lib/danica/version.rb +1 -1
  28. data/lib/danica/wrapper/constant.rb +1 -5
  29. data/lib/danica/wrapper/group.rb +4 -4
  30. data/lib/danica/wrapper/negative.rb +2 -2
  31. data/lib/danica/wrapper/number.rb +1 -1
  32. data/lib/danica/wrapper/plus_minus.rb +4 -4
  33. data/lib/danica/wrapper/variable.rb +4 -4
  34. data/lib/danica/wrapper.rb +1 -1
  35. data/spec/integration/global/danica/operator/multiplication_spec.rb +1 -1
  36. data/spec/integration/readme/{equation_spec.rb → danica/equation_spec.rb} +2 -2
  37. data/spec/integration/readme/danica/expression/baskara_spec.rb +11 -0
  38. data/spec/integration/readme/{expression_spec.rb → danica/expression_spec.rb} +0 -8
  39. data/spec/integration/readme/danica/function/my_function_spec.rb +11 -0
  40. data/spec/integration/readme/danica/function/quadratic_sum_spec.rb +11 -0
  41. data/spec/integration/readme/{function_spec.rb → danica/function/spatial_spec.rb} +0 -32
  42. data/spec/integration/readme/danica/function_spec.rb +19 -0
  43. data/spec/integration/readme/{operator_spec.rb → danica/operator/inverse_spec.rb} +0 -22
  44. data/spec/integration/readme/danica/operator/my_operator_spec.rb +25 -0
  45. data/spec/integration/readme/{constant_spec.rb → danica/wrapper/constant_spec.rb} +2 -2
  46. data/spec/integration/readme/{number_spec.rb → danica/wrapper/number_spec.rb} +3 -3
  47. data/spec/integration/readme/{variables_spec.rb → danica/wrapper/variables_spec.rb} +15 -15
  48. data/spec/integration/readme/danica_spec.rb +3 -3
  49. data/spec/lib/danica/common_spec.rb +27 -27
  50. data/spec/lib/danica/dsl_spec.rb +1 -5
  51. data/spec/lib/danica/equation_spec.rb +7 -7
  52. data/spec/lib/danica/expression/gauss_spec.rb +6 -6
  53. data/spec/lib/danica/expression_spec.rb +39 -41
  54. data/spec/lib/danica/formatted_spec.rb +24 -23
  55. data/spec/lib/danica/function/name_spec.rb +6 -5
  56. data/spec/lib/danica/function_spec.rb +7 -18
  57. data/spec/lib/danica/operator/division_spec.rb +5 -5
  58. data/spec/lib/danica/operator_spec.rb +5 -5
  59. data/spec/lib/danica/variables_holder/store_spec.rb +9 -13
  60. data/spec/lib/danica/variables_holder_spec.rb +68 -67
  61. data/spec/lib/danica/wrapper/constant_spec.rb +19 -19
  62. data/spec/lib/danica/wrapper/group_spec.rb +7 -7
  63. data/spec/lib/danica/wrapper/negative_spec.rb +7 -7
  64. data/spec/lib/danica/wrapper/number_spec.rb +5 -5
  65. data/spec/lib/danica/wrapper/plus_minus_spec.rb +7 -7
  66. data/spec/lib/danica/wrapper/variable_spec.rb +6 -4
  67. data/spec/lib/danica/wrapper_spec.rb +3 -3
  68. data/spec/spec_helper.rb +4 -3
  69. data/spec/support/models/dummy/dsl_dummy.rb +5 -0
  70. data/spec/support/models/function/my_function.rb +1 -1
  71. data/spec/support/models/variables_holder/dummy.rb +1 -1
  72. data/spec/support/shared_examples/operator/chained.rb +2 -1
  73. data/spec/support/shared_examples/operator/single_input.rb +2 -1
  74. metadata +24 -233
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  shared_examples 'an object that returns the default variables hash' do
6
6
  it 'returns the default variables hash' do
7
- expect(subject.variables_hash).to eq(
7
+ expect(holder.variables_hash).to eq(
8
8
  x: Danica::Wrapper::Variable.new(name: :x),
9
9
  y: Danica::Wrapper::Variable.new(latex: '\y'),
10
10
  z: Danica::Wrapper::Number.new(10)
@@ -22,24 +22,24 @@ shared_examples 'an object that returns the default variables' do
22
22
  end
23
23
 
24
24
  it 'returns the default variables hash' do
25
- expect(subject.variables).to eq(expected_variables)
25
+ expect(holder.variables).to eq(expected_variables)
26
26
  end
27
27
  end
28
28
 
29
29
  shared_examples 'an variable set that does not change the class variables' do
30
30
  it 'does not change the the class variables' do
31
31
  expect do
32
- subject.variables = variables
32
+ holder.variables = variables
33
33
  end.not_to change(clazz, :variables_hash)
34
34
  end
35
35
  end
36
36
 
37
37
  shared_examples 'a class with mapped variables' do
38
38
  context 'when initializing with an array' do
39
- subject { clazz.new(1, 2, 3) }
39
+ subject(:holder) { clazz.new(1, 2, 3) }
40
40
 
41
41
  it 'initialize variables in order of declaration' do
42
- expect(subject.variables_hash).to eq(
42
+ expect(holder.variables_hash).to eq(
43
43
  x: Danica::Wrapper::Number.new(1),
44
44
  y: Danica::Wrapper::Number.new(2),
45
45
  z: Danica::Wrapper::Number.new(3)
@@ -48,10 +48,10 @@ shared_examples 'a class with mapped variables' do
48
48
  end
49
49
 
50
50
  context 'when initialized with a hash' do
51
- subject { clazz.new(z: 1, y: 2) }
51
+ subject(:holder) { clazz.new(z: 1, y: 2) }
52
52
 
53
53
  it 'initialize variables with the map given' do
54
- expect(subject.variables_hash).to eq(
54
+ expect(holder.variables_hash).to eq(
55
55
  x: Danica::Wrapper::Variable.new(name: :x),
56
56
  y: Danica::Wrapper::Number.new(2),
57
57
  z: Danica::Wrapper::Number.new(1)
@@ -60,7 +60,7 @@ shared_examples 'a class with mapped variables' do
60
60
  end
61
61
 
62
62
  context 'when initializing with hashes' do
63
- subject do
63
+ subject(:holder) do
64
64
  clazz.new(
65
65
  { name: :xis, value: 1 },
66
66
  { name: :yps, value: 2 },
@@ -69,7 +69,7 @@ shared_examples 'a class with mapped variables' do
69
69
  end
70
70
 
71
71
  it 'initialize variables with the maps given' do
72
- expect(subject.variables_hash).to eq(
72
+ expect(holder.variables_hash).to eq(
73
73
  x: Danica::Wrapper::Variable.new(name: :xis, value: 1),
74
74
  y: Danica::Wrapper::Variable.new(name: :yps, value: 2),
75
75
  z: Danica::Wrapper::Variable.new(name: :zes, value: 3)
@@ -78,7 +78,7 @@ shared_examples 'a class with mapped variables' do
78
78
  end
79
79
 
80
80
  context 'when initializing with array of hashes' do
81
- subject do
81
+ subject(:holder) do
82
82
  clazz.new([
83
83
  { name: :xis, value: 1 },
84
84
  { name: :yps, value: 2 },
@@ -87,7 +87,7 @@ shared_examples 'a class with mapped variables' do
87
87
  end
88
88
 
89
89
  it 'initialize variables with the maps given' do
90
- expect(subject.variables_hash).to eq(
90
+ expect(holder.variables_hash).to eq(
91
91
  x: Danica::Wrapper::Variable.new(name: :xis, value: 1),
92
92
  y: Danica::Wrapper::Variable.new(name: :yps, value: 2),
93
93
  z: Danica::Wrapper::Variable.new(name: :zes, value: 3)
@@ -97,7 +97,7 @@ shared_examples 'a class with mapped variables' do
97
97
  end
98
98
 
99
99
  describe Danica::VariablesHolder do
100
- subject { clazz.new }
100
+ subject(:holder) { clazz.new }
101
101
 
102
102
  let(:clazz) { described_class::Dummy }
103
103
 
@@ -116,32 +116,32 @@ describe Danica::VariablesHolder do
116
116
  describe 'variables assignement' do
117
117
  it 'creates setters for the variables' do
118
118
  %i[x y z].each do |var|
119
- expect(subject).to respond_to("#{var}=")
119
+ expect(holder).to respond_to("#{var}=")
120
120
  end
121
121
  end
122
122
 
123
123
  it 'creates getters for the variables' do
124
124
  %i[x y z].each do |var|
125
- expect(subject).to respond_to(var)
125
+ expect(holder).to respond_to(var)
126
126
  end
127
127
  end
128
128
 
129
129
  it 'accepts variable assignment' do
130
130
  expect do
131
- subject.x = 1
132
- end.to change(subject.x, :content).to(Danica::Wrapper::Number.new(1))
131
+ holder.x = 1
132
+ end.to change(holder.x, :content).to(Danica::Wrapper::Number.new(1))
133
133
  end
134
134
 
135
135
  it 'variable assignemnt does not change the container' do
136
136
  expect do
137
- subject.x = 1
138
- end.not_to change(subject, :x)
137
+ holder.x = 1
138
+ end.not_to change(holder, :x)
139
139
  end
140
140
 
141
141
  xit 'accepts containter assignment' do
142
142
  expect do
143
- subject.x = Danica::Wrapper::Container.new(Danica::Wrapper::Number.new(1))
144
- end.to change(subject, :x)
143
+ holder.x = Danica::Wrapper::Container.new(Danica::Wrapper::Number.new(1))
144
+ end.to change(holder, :x)
145
145
  end
146
146
  end
147
147
 
@@ -177,37 +177,37 @@ describe Danica::VariablesHolder do
177
177
 
178
178
  context 'when original variable is set' do
179
179
  before do
180
- subject.x = 10
180
+ holder.x = 10
181
181
  end
182
182
 
183
183
  context 'when calling the alias variable' do
184
184
  it 'returns the aliased value' do
185
- expect(subject.a).to eq(subject.x)
185
+ expect(holder.a).to eq(holder.x)
186
186
  end
187
187
  end
188
188
 
189
189
  context 'when changing the new alias value' do
190
190
  it do
191
- expect { subject.a = 20 }.to(change { subject.x.content })
191
+ expect { holder.a = 20 }.to(change { holder.x.content })
192
192
  end
193
193
  end
194
194
  end
195
195
 
196
196
  context 'when alias variable is set' do
197
197
  before do
198
- subject.a = 10
198
+ holder.a = 10
199
199
  end
200
200
 
201
201
  context 'when calling the original variable' do
202
202
  it 'returns the aliased value' do
203
- expect(subject.x).to eq(subject.a)
203
+ expect(holder.x).to eq(holder.a)
204
204
  end
205
205
  end
206
206
 
207
207
  context 'when changing the original variable value' do
208
208
  it do
209
- expect { subject.x = 20 }
210
- .to(change { subject.a.content })
209
+ expect { holder.x = 20 }
210
+ .to(change { holder.a.content })
211
211
  end
212
212
  end
213
213
  end
@@ -243,13 +243,13 @@ describe Danica::VariablesHolder do
243
243
 
244
244
  context 'when setting the variables using a list' do
245
245
  before do
246
- subject.variables = variables
246
+ holder.variables = variables
247
247
  end
248
248
 
249
249
  let(:variables) { [1, 2, 3] }
250
250
 
251
251
  it 'changes the values of the variables' do
252
- expect(subject.x).to eq(Danica::Wrapper::Number.new(1))
252
+ expect(holder.x).to eq(Danica::Wrapper::Number.new(1))
253
253
  end
254
254
 
255
255
  context 'when the array is empty' do
@@ -261,13 +261,13 @@ describe Danica::VariablesHolder do
261
261
 
262
262
  context 'when setting the variales using a hash' do
263
263
  before do
264
- subject.variables = variables
264
+ holder.variables = variables
265
265
  end
266
266
 
267
267
  let(:variables) { { x: 1, y: 2, z: 3 } }
268
268
 
269
269
  it 'changes the values of the variables' do
270
- expect(subject.x).to eq(Danica::Wrapper::Number.new(1))
270
+ expect(holder.x).to eq(Danica::Wrapper::Number.new(1))
271
271
  end
272
272
 
273
273
  context 'when the hash is empty' do
@@ -281,7 +281,7 @@ describe Danica::VariablesHolder do
281
281
  describe '#variables' do
282
282
  context 'when instance has no variables defined' do
283
283
  it do
284
- expect(subject.variables).not_to be_empty
284
+ expect(holder.variables).not_to be_empty
285
285
  end
286
286
 
287
287
  it_behaves_like 'an object that returns the default variables'
@@ -289,20 +289,20 @@ describe Danica::VariablesHolder do
289
289
 
290
290
  context 'when some variables where defined' do
291
291
  before do
292
- subject.y = 1
292
+ holder.y = 1
293
293
  end
294
294
 
295
295
  it 'returns the default variables and the new set one' do
296
- expect(subject.variables).to eq([
297
- Danica::Wrapper::Variable.new(name: :x),
298
- Danica::Wrapper::Number.new(1),
299
- Danica::Wrapper::Number.new(10)
300
- ])
296
+ expect(holder.variables).to eq([
297
+ Danica::Wrapper::Variable.new(name: :x),
298
+ Danica::Wrapper::Number.new(1),
299
+ Danica::Wrapper::Number.new(10)
300
+ ])
301
301
  end
302
302
 
303
303
  it 'does not change the class variables' do
304
304
  expect do
305
- subject.z = 2
305
+ holder.z = 2
306
306
  end.not_to change(clazz, :variables_hash)
307
307
  end
308
308
  end
@@ -315,11 +315,11 @@ describe Danica::VariablesHolder do
315
315
 
316
316
  context 'when some variables where defined' do
317
317
  before do
318
- subject.y = 1
318
+ holder.y = 1
319
319
  end
320
320
 
321
321
  it 'returns the default hash with the set value' do
322
- expect(subject.variables_hash).to eq(
322
+ expect(holder.variables_hash).to eq(
323
323
  x: Danica::Wrapper::Variable.new(name: :x),
324
324
  y: Danica::Wrapper::Number.new(1),
325
325
  z: Danica::Wrapper::Number.new(10)
@@ -331,31 +331,31 @@ describe Danica::VariablesHolder do
331
331
  describe '#variables_value_hash' do
332
332
  context 'when instance has no variables defined' do
333
333
  it 'returns the default value' do
334
- expect(subject.variables_value_hash).to eq(x: nil, y: nil, z: 10)
334
+ expect(holder.variables_value_hash).to eq(x: nil, y: nil, z: 10)
335
335
  end
336
336
  end
337
337
 
338
338
  context 'when some of the variables have been valued' do
339
339
  before do
340
- subject.y = 1
340
+ holder.y = 1
341
341
  end
342
342
 
343
343
  it 'returns the values' do
344
- expect(subject.variables_value_hash).to eq(x: nil, y: 1, z: 10)
344
+ expect(holder.variables_value_hash).to eq(x: nil, y: 1, z: 10)
345
345
  end
346
346
  end
347
347
  end
348
348
 
349
349
  describe '#containers' do
350
350
  it 'is an array of Containers' do
351
- expect(subject.containers.first).to be_a(Danica::Wrapper::Container)
351
+ expect(holder.containers.first).to be_a(Danica::Wrapper::Container)
352
352
  end
353
353
 
354
354
  context 'when changing the variable on the object' do
355
- let(:containers) { subject.containers }
355
+ let(:containers) { holder.containers }
356
356
 
357
357
  it 'changes the variables in the containers' do
358
- expect { subject.x = 2 }
358
+ expect { holder.x = 2 }
359
359
  .to(change { containers.map(&:content) })
360
360
  end
361
361
  end
@@ -366,41 +366,42 @@ describe Danica::VariablesHolder do
366
366
 
367
367
  context 'when holder has straight variables' do
368
368
  it 'returns the variables hash' do
369
- expect(subject.extract_variables).to eq(subject.containers.as_hash(%i[x y zeta k]))
369
+ expect(holder.extract_variables).to eq(holder.containers.as_hash(%i[x y zeta k]))
370
370
  end
371
371
 
372
372
  context 'when one of them is a number' do
373
373
  let(:clazz) { described_class::Dummy }
374
374
  let(:expected) do
375
- subject.containers_hash.reject { |k, _v| k == :z }
375
+ holder.containers_hash.except(:z)
376
376
  end
377
377
 
378
378
  it 'returns only the variables' do
379
- expect(subject.extract_variables).to eq(expected)
379
+ expect(holder.extract_variables).to eq(expected)
380
380
  end
381
381
  end
382
382
  end
383
383
 
384
384
  context 'when variables names are different' do
385
- let(:subject) { clazz.new(x: :xis, y: :lambda, z: :zeta, k: :key) }
385
+ subject(:holder) { clazz.new(x: :xis, y: :lambda, z: :zeta, k: :key) }
386
386
 
387
387
  it 'returns the names as keys' do
388
- expect(subject.extract_variables.keys).to eq(%i[xis lambda zeta key])
388
+ expect(holder.extract_variables.keys).to eq(%i[xis lambda zeta key])
389
389
  end
390
390
  end
391
391
 
392
392
  context 'when a variable is another variable holder' do
393
- let(:inner) { Danica::Operator::Power.new }
394
- let(:subject) do
393
+ subject(:holder) do
395
394
  clazz.new(z: inner)
396
395
  end
396
+
397
+ let(:inner) { Danica::Operator::Power.new }
397
398
  let(:expected) do
398
- subject.containers_hash.reject { |k, _v| k == :z }
399
- .merge(inner.containers_hash)
399
+ holder.containers_hash.except(:z)
400
+ .merge(inner.containers_hash)
400
401
  end
401
402
 
402
403
  it 'returns the ineer variables of the inner holder as well' do
403
- expect(subject.extract_variables).to eq(expected)
404
+ expect(holder.extract_variables).to eq(expected)
404
405
  end
405
406
 
406
407
  context 'when inner holder has the same variables' do
@@ -410,7 +411,7 @@ describe Danica::VariablesHolder do
410
411
  end
411
412
 
412
413
  it 'merges them together in favor of the inner variables' do
413
- expect(subject.extract_variables).to eq(expected)
414
+ expect(holder.extract_variables).to eq(expected)
414
415
  end
415
416
  end
416
417
  end
@@ -420,12 +421,12 @@ describe Danica::VariablesHolder do
420
421
  context 'when object doesnt have the values defined' do
421
422
  context 'when trying to calculate without passing the values' do
422
423
  it do
423
- expect { subject.calculate }.to raise_error(Danica::Exception::NotDefined)
424
+ expect { holder.calculate }.to raise_error(Danica::Exception::NotDefined)
424
425
  end
425
426
 
426
427
  context 'when it does not complete the values' do
427
428
  it do
428
- expect { subject.calculate(2) }.to raise_error(Danica::Exception::NotDefined)
429
+ expect { holder.calculate(2) }.to raise_error(Danica::Exception::NotDefined)
429
430
  end
430
431
  end
431
432
  end
@@ -433,20 +434,20 @@ describe Danica::VariablesHolder do
433
434
  context 'when passing the values' do
434
435
  context 'when values are a list' do
435
436
  it do
436
- expect { subject.calculate(2, 4) }.not_to raise_error
437
+ expect { holder.calculate(2, 4) }.not_to raise_error
437
438
  end
438
439
 
439
440
  it 'calculates the expression' do
440
- expect(subject.calculate(2, 4)).to eq(26)
441
+ expect(holder.calculate(2, 4)).to eq(26)
441
442
  end
442
443
 
443
444
  context 'when replacing all the values' do
444
445
  it do
445
- expect { subject.calculate(2, 4, 5) }.not_to raise_error
446
+ expect { holder.calculate(2, 4, 5) }.not_to raise_error
446
447
  end
447
448
 
448
449
  it 'calculates the expression' do
449
- expect(subject.calculate(2, 4, 5)).to eq(21)
450
+ expect(holder.calculate(2, 4, 5)).to eq(21)
450
451
  end
451
452
  end
452
453
  end
@@ -454,17 +455,17 @@ describe Danica::VariablesHolder do
454
455
  context 'when the values are hash' do
455
456
  context 'when it completes the values' do
456
457
  it do
457
- expect { subject.calculate(x: 2, y: 4) }.not_to raise_error
458
+ expect { holder.calculate(x: 2, y: 4) }.not_to raise_error
458
459
  end
459
460
 
460
461
  it 'calculates the expression' do
461
- expect(subject.calculate(2, 4)).to eq(26)
462
+ expect(holder.calculate(2, 4)).to eq(26)
462
463
  end
463
464
  end
464
465
 
465
466
  context 'when it does not complete the values' do
466
467
  it do
467
- expect { subject.calculate(x: 2, z: 4) }.to raise_error(Danica::Exception::NotDefined)
468
+ expect { holder.calculate(x: 2, z: 4) }.to raise_error(Danica::Exception::NotDefined)
468
469
  end
469
470
  end
470
471
  end
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Danica::Wrapper::Constant do
6
- subject { described_class.new(2.5, :M, :m) }
6
+ subject(:constant) { described_class.new(2.5, :M, :m) }
7
7
 
8
8
  let(:other) { described_class.new(3, :N, :n) }
9
9
 
@@ -12,45 +12,45 @@ describe Danica::Wrapper::Constant do
12
12
 
13
13
  describe '#to_f' do
14
14
  it 'has a value' do
15
- expect(subject.to_f).to eq(2.5)
15
+ expect(constant.to_f).to eq(2.5)
16
16
  end
17
17
  end
18
18
 
19
19
  describe '#to_tex' do
20
20
  it 'has a string for latex' do
21
- expect(subject.to_tex).to eq('M')
21
+ expect(constant.to_tex).to eq('M')
22
22
  end
23
23
  end
24
24
 
25
25
  describe '#to' do
26
26
  context 'when requesting :tex' do
27
27
  it 'has a string for latex' do
28
- expect(subject.to(:tex)).to eq('M')
28
+ expect(constant.to(:tex)).to eq('M')
29
29
  end
30
30
  end
31
31
 
32
32
  context "when requesting 'tex'" do
33
33
  it 'has a string for latex' do
34
- expect(subject.to('tex')).to eq('M')
34
+ expect(constant.to('tex')).to eq('M')
35
35
  end
36
36
  end
37
37
 
38
38
  context 'when requesting :gnu' do
39
39
  it 'has a string for gnu' do
40
- expect(subject.to(:gnu)).to eq('m')
40
+ expect(constant.to(:gnu)).to eq('m')
41
41
  end
42
42
  end
43
43
 
44
44
  context "when requesting 'gnu'" do
45
45
  it 'has a string for gnu' do
46
- expect(subject.to('gnu')).to eq('m')
46
+ expect(constant.to('gnu')).to eq('m')
47
47
  end
48
48
  end
49
49
 
50
50
  context 'when requesting wrong format' do
51
51
  it do
52
52
  expect do
53
- subject.to('format')
53
+ constant.to('format')
54
54
  end.to raise_error(Danica::Exception::FormattedNotFound)
55
55
  end
56
56
  end
@@ -58,18 +58,18 @@ describe Danica::Wrapper::Constant do
58
58
 
59
59
  describe '#to_gnu' do
60
60
  it 'has a string for gnu' do
61
- expect(subject.to_gnu).to eq('m')
61
+ expect(constant.to_gnu).to eq('m')
62
62
  end
63
63
  end
64
64
 
65
65
  describe 'attr_setters' do
66
- it { expect(subject).not_to respond_to(:value=) }
67
- it { expect(subject).not_to respond_to(:latex=) }
68
- it { expect(subject).not_to respond_to(:gnu=) }
66
+ it { expect(constant).not_to respond_to(:value=) }
67
+ it { expect(constant).not_to respond_to(:latex=) }
68
+ it { expect(constant).not_to respond_to(:gnu=) }
69
69
  end
70
70
 
71
71
  context 'when initializing from hash' do
72
- subject { described_class.new(value: 2.5, latex: :M, gnuplot: :m) }
72
+ subject(:constant) { described_class.new(value: 2.5, latex: :M, gnuplot: :m) }
73
73
 
74
74
  it 'initialize normaly' do
75
75
  expect do
@@ -78,32 +78,32 @@ describe Danica::Wrapper::Constant do
78
78
  end
79
79
 
80
80
  it 'sets the value' do
81
- expect(subject.value).to eq(2.5)
81
+ expect(constant.value).to eq(2.5)
82
82
  end
83
83
 
84
84
  it 'sets the latex' do
85
- expect(subject.to_tex).to eq('M')
85
+ expect(constant.to_tex).to eq('M')
86
86
  end
87
87
 
88
88
  it 'sets the gnu' do
89
- expect(subject.to_gnu).to eq('m')
89
+ expect(constant.to_gnu).to eq('m')
90
90
  end
91
91
  end
92
92
 
93
93
  describe '==' do
94
94
  context 'when comparing with the same object' do
95
- it { expect(subject).to eq(subject) }
95
+ it { expect(constant).to eq(described_class.new(2.5, :M, :m)) }
96
96
  end
97
97
 
98
98
  context 'when comparing with a diferent object' do
99
99
  context 'with diferent values' do
100
- it { expect(subject).not_to eq(other) }
100
+ it { expect(constant).not_to eq(other) }
101
101
  end
102
102
 
103
103
  context 'with same values' do
104
104
  let(:other) { described_class.new(2.5, :M, :m) }
105
105
 
106
- it { expect(subject).to eq(other) }
106
+ it { expect(constant).to eq(other) }
107
107
  end
108
108
  end
109
109
  end
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Danica::Wrapper::Group do
6
- subject { described_class.new(value) }
6
+ subject(:group) { described_class.new(value) }
7
7
 
8
8
  let(:value) { 10 }
9
9
 
@@ -12,10 +12,10 @@ describe Danica::Wrapper::Group do
12
12
 
13
13
  describe '#to_f' do
14
14
  it 'returns the float of value' do
15
- expect(subject.to_f).to eq(10)
15
+ expect(group.to_f).to eq(10)
16
16
  end
17
17
 
18
- it { expect(subject.to_f).to be_a(Float) }
18
+ it { expect(group.to_f).to be_a(Float) }
19
19
  end
20
20
 
21
21
  describe '#to_tex' do
@@ -23,7 +23,7 @@ describe Danica::Wrapper::Group do
23
23
  let(:value) { 10.0 }
24
24
 
25
25
  it 'returns the positive negative string' do
26
- expect(subject.to_tex).to eq('\left(10\right)')
26
+ expect(group.to_tex).to eq('\left(10\right)')
27
27
  end
28
28
  end
29
29
 
@@ -31,7 +31,7 @@ describe Danica::Wrapper::Group do
31
31
  let(:value) { 10.5 }
32
32
 
33
33
  it 'returns the positive negative string' do
34
- expect(subject.to_tex).to eq('\left(10.5\right)')
34
+ expect(group.to_tex).to eq('\left(10.5\right)')
35
35
  end
36
36
  end
37
37
  end
@@ -41,7 +41,7 @@ describe Danica::Wrapper::Group do
41
41
  let(:value) { 10.0 }
42
42
 
43
43
  it 'returns the value integer string' do
44
- expect(subject.to_gnu).to eq('(10)')
44
+ expect(group.to_gnu).to eq('(10)')
45
45
  end
46
46
  end
47
47
 
@@ -49,7 +49,7 @@ describe Danica::Wrapper::Group do
49
49
  let(:value) { 10.5 }
50
50
 
51
51
  it 'returns the value float string' do
52
- expect(subject.to_gnu).to eq('(10.5)')
52
+ expect(group.to_gnu).to eq('(10.5)')
53
53
  end
54
54
  end
55
55
  end
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Danica::Wrapper::Negative do
6
- subject { described_class.new(value) }
6
+ subject(:wrapper) { described_class.new(value) }
7
7
 
8
8
  let(:value) { 10 }
9
9
 
@@ -12,10 +12,10 @@ describe Danica::Wrapper::Negative do
12
12
 
13
13
  describe '#to_f' do
14
14
  it 'returns the float of value' do
15
- expect(subject.to_f).to eq(-10)
15
+ expect(wrapper.to_f).to eq(-10)
16
16
  end
17
17
 
18
- it { expect(subject.to_f).to be_a(Float) }
18
+ it { expect(wrapper.to_f).to be_a(Float) }
19
19
  end
20
20
 
21
21
  describe '#to_tex' do
@@ -23,7 +23,7 @@ describe Danica::Wrapper::Negative do
23
23
  let(:value) { 10.0 }
24
24
 
25
25
  it 'returns the value integer string' do
26
- expect(subject.to_tex).to eq('-10')
26
+ expect(wrapper.to_tex).to eq('-10')
27
27
  end
28
28
  end
29
29
 
@@ -31,7 +31,7 @@ describe Danica::Wrapper::Negative do
31
31
  let(:value) { 10.5 }
32
32
 
33
33
  it 'returns the value float string' do
34
- expect(subject.to_tex).to eq('-10.5')
34
+ expect(wrapper.to_tex).to eq('-10.5')
35
35
  end
36
36
  end
37
37
  end
@@ -41,7 +41,7 @@ describe Danica::Wrapper::Negative do
41
41
  let(:value) { 10.0 }
42
42
 
43
43
  it 'returns the value integer string' do
44
- expect(subject.to_gnu).to eq('-10')
44
+ expect(wrapper.to_gnu).to eq('-10')
45
45
  end
46
46
  end
47
47
 
@@ -49,7 +49,7 @@ describe Danica::Wrapper::Negative do
49
49
  let(:value) { 10.5 }
50
50
 
51
51
  it 'returns the value float string' do
52
- expect(subject.to_gnu).to eq('-10.5')
52
+ expect(wrapper.to_gnu).to eq('-10.5')
53
53
  end
54
54
  end
55
55
  end