danica 2.7.4 → 2.7.5

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 (121) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +28 -0
  3. data/.gitignore +6 -1
  4. data/.rubocop.yml +9 -0
  5. data/.rubocop_todo.yml +100 -0
  6. data/Dockerfile +26 -0
  7. data/Gemfile +2 -1
  8. data/Rakefile +4 -0
  9. data/config/rubycritc.rb +12 -0
  10. data/config/yardstick.rb +13 -0
  11. data/config/yardstick.yml +33 -0
  12. data/danica.gemspec +14 -7
  13. data/docker-compose.yml +14 -9
  14. data/lib/danica.rb +2 -1
  15. data/lib/danica/base_operations.rb +2 -0
  16. data/lib/danica/builder.rb +2 -0
  17. data/lib/danica/common.rb +5 -2
  18. data/lib/danica/dsl.rb +8 -6
  19. data/lib/danica/dsl/builder.rb +3 -1
  20. data/lib/danica/equation.rb +3 -3
  21. data/lib/danica/equation/builder.rb +2 -0
  22. data/lib/danica/exception.rb +3 -2
  23. data/lib/danica/expressable.rb +14 -8
  24. data/lib/danica/expression.rb +4 -2
  25. data/lib/danica/expression/gauss.rb +5 -5
  26. data/lib/danica/formatted.rb +4 -2
  27. data/lib/danica/function.rb +5 -3
  28. data/lib/danica/function/name.rb +2 -0
  29. data/lib/danica/operator.rb +12 -9
  30. data/lib/danica/operator/addition.rb +4 -3
  31. data/lib/danica/operator/chained.rb +4 -3
  32. data/lib/danica/operator/cos.rb +2 -1
  33. data/lib/danica/operator/division.rb +2 -1
  34. data/lib/danica/operator/exponential.rb +2 -1
  35. data/lib/danica/operator/functional.rb +3 -2
  36. data/lib/danica/operator/multiplication.rb +4 -2
  37. data/lib/danica/operator/power.rb +4 -3
  38. data/lib/danica/operator/sin.rb +2 -1
  39. data/lib/danica/operator/squared_root.rb +2 -1
  40. data/lib/danica/variables_holder.rb +7 -4
  41. data/lib/danica/variables_holder/alias_builder.rb +4 -4
  42. data/lib/danica/variables_holder/calculator.rb +2 -0
  43. data/lib/danica/variables_holder/store.rb +3 -2
  44. data/lib/danica/variables_holder/variables_builder.rb +2 -1
  45. data/lib/danica/version.rb +3 -1
  46. data/lib/danica/wrapper.rb +11 -9
  47. data/lib/danica/wrapper/constant.rb +9 -14
  48. data/lib/danica/wrapper/container.rb +2 -3
  49. data/lib/danica/wrapper/group.rb +2 -2
  50. data/lib/danica/wrapper/negative.rb +2 -1
  51. data/lib/danica/wrapper/number.rb +4 -3
  52. data/lib/danica/wrapper/plus_minus.rb +2 -1
  53. data/lib/danica/wrapper/variable.rb +10 -8
  54. data/scripts/check_readme.sh +6 -0
  55. data/scripts/rubycritic.sh +10 -0
  56. data/spec/integration/global/danica/formatted_spec.rb +87 -0
  57. data/spec/integration/global/danica/operator/addition_spec.rb +32 -0
  58. data/spec/integration/{multiplication_spec.rb → global/danica/operator/multiplication_spec.rb} +12 -9
  59. data/spec/integration/{power_spec.rb → global/danica/operator/power_spec.rb} +4 -2
  60. data/spec/integration/{negative_spec.rb → global/danica/wrapper/negative_spec.rb} +9 -8
  61. data/spec/integration/{plus_minus_spec.rb → global/danica/wrapper/plus_minus_spec.rb} +5 -4
  62. data/spec/integration/readme/constant_spec.rb +4 -1
  63. data/spec/integration/readme/danica/formatted_spec.rb +24 -0
  64. data/spec/integration/readme/danica_spec.rb +20 -4
  65. data/spec/integration/readme/equation_spec.rb +4 -2
  66. data/spec/integration/readme/expression_spec.rb +11 -8
  67. data/spec/integration/readme/function_spec.rb +11 -7
  68. data/spec/integration/readme/number_spec.rb +9 -8
  69. data/spec/integration/readme/operator_spec.rb +3 -1
  70. data/spec/integration/readme/variables_spec.rb +8 -6
  71. data/spec/lib/danica/common_spec.rb +23 -9
  72. data/spec/lib/danica/dsl_spec.rb +5 -2
  73. data/spec/lib/danica/equation_spec.rb +10 -8
  74. data/spec/lib/danica/expressable_spec.rb +5 -2
  75. data/spec/lib/danica/expression/gauss_spec.rb +6 -3
  76. data/spec/lib/danica/expression_spec.rb +48 -26
  77. data/spec/lib/danica/formatted_spec.rb +20 -14
  78. data/spec/lib/danica/function/name_spec.rb +3 -1
  79. data/spec/lib/danica/function_spec.rb +14 -10
  80. data/spec/lib/danica/operator/addition_spec.rb +16 -15
  81. data/spec/lib/danica/operator/cos_spec.rb +9 -8
  82. data/spec/lib/danica/operator/division_spec.rb +18 -17
  83. data/spec/lib/danica/operator/exponential_spec.rb +9 -8
  84. data/spec/lib/danica/operator/multiplication_spec.rb +16 -15
  85. data/spec/lib/danica/operator/power_spec.rb +17 -16
  86. data/spec/lib/danica/operator/sin_spec.rb +9 -8
  87. data/spec/lib/danica/operator/squared_root_spec.rb +9 -8
  88. data/spec/lib/danica/operator_spec.rb +13 -4
  89. data/spec/lib/danica/variables_holder/store_spec.rb +19 -13
  90. data/spec/lib/danica/variables_holder_spec.rb +76 -59
  91. data/spec/lib/danica/wrapper/constant_spec.rb +9 -2
  92. data/spec/lib/danica/wrapper/group_spec.rb +4 -1
  93. data/spec/lib/danica/wrapper/negative_spec.rb +4 -1
  94. data/spec/lib/danica/wrapper/number_spec.rb +8 -3
  95. data/spec/lib/danica/wrapper/plus_minus_spec.rb +4 -1
  96. data/spec/lib/danica/wrapper/variable_spec.rb +6 -3
  97. data/spec/lib/danica/wrapper_spec.rb +14 -12
  98. data/spec/lib/danica_spec.rb +6 -5
  99. data/spec/spec_helper.rb +2 -1
  100. data/spec/support/models/expression/baskara.rb +3 -3
  101. data/spec/support/models/expression/parabole.rb +2 -0
  102. data/spec/support/models/expression/quadratic_sum.rb +3 -1
  103. data/spec/support/models/expression/spatial.rb +2 -1
  104. data/spec/support/models/function/my_function.rb +3 -1
  105. data/spec/support/models/function/parabole.rb +1 -1
  106. data/spec/support/models/function/quadratic_sum.rb +2 -0
  107. data/spec/support/models/function/spatial.rb +2 -0
  108. data/spec/support/models/operator/inverse.rb +3 -1
  109. data/spec/support/models/operator/my_operator.rb +3 -1
  110. data/spec/support/models/variables_holder/dummy.rb +3 -1
  111. data/spec/support/shared_contexts/common.rb +4 -2
  112. data/spec/support/shared_examples/base_operations.rb +7 -4
  113. data/spec/support/shared_examples/common.rb +3 -1
  114. data/spec/support/shared_examples/operator/chained.rb +12 -6
  115. data/spec/support/shared_examples/operator/dual_term.rb +9 -8
  116. data/spec/support/shared_examples/operator/single_input.rb +7 -2
  117. data/spec/support/shared_examples/variable.rb +8 -4
  118. metadata +109 -30
  119. data/spec/integration/addition_spec.rb +0 -28
  120. data/spec/integration/formatted_spec.rb +0 -75
  121. data/spec/integration/readme/formatting_spec.rb +0 -34
@@ -1,9 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Danica::Wrapper::Negative 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
 
@@ -1,20 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Danica::Wrapper::Number 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
 
9
12
  it_behaves_like 'an object with basic operation'
10
13
 
11
14
  describe '#valued?' do
12
15
  context 'when value is present' do
13
- it { expect(subject.valued?).to be_truthy }
16
+ it { expect(subject).to be_valued }
14
17
  end
18
+
15
19
  context 'when value is not present' do
16
20
  let(:value) { false }
17
- it { expect(subject.valued?).to be_falsey }
21
+
22
+ it { expect(subject).not_to be_valued }
18
23
  end
19
24
  end
20
25
 
@@ -1,9 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Danica::Wrapper::PlusMinus 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
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Danica::Wrapper::Variable do
@@ -10,13 +12,13 @@ describe Danica::Wrapper::Variable do
10
12
  it 'can be initialize from nil value' do
11
13
  expect do
12
14
  described_class.new(nil)
13
- end
15
+ end.not_to raise_error
14
16
  end
15
17
 
16
18
  it 'can be initialize from nil name' do
17
19
  expect do
18
20
  described_class.new(name: nil)
19
- end
21
+ end.not_to raise_error
20
22
  end
21
23
 
22
24
  describe '#to_f' do
@@ -25,9 +27,10 @@ describe Danica::Wrapper::Variable do
25
27
  end
26
28
 
27
29
  context 'when variable has value' do
28
- let(:value) { 100 }
29
30
  subject { described_class.new(value: value) }
30
31
 
32
+ let(:value) { 100 }
33
+
31
34
  it 'returns the value' do
32
35
  expect(subject.to_f).to eq(value)
33
36
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  class Danica::Wrapper::Dummy
@@ -24,21 +26,21 @@ shared_examples 'a value wrapper' do |examples|
24
26
  end
25
27
 
26
28
  describe Danica::Wrapper do
27
- let(:clazz) { described_class::Dummy }
28
29
  subject { clazz.new(value) }
29
30
 
31
+ let(:clazz) { described_class::Dummy }
32
+
30
33
  describe 'wrap_value' do
31
- it_behaves_like 'a value wrapper', {
32
- x: Danica::Wrapper::Variable,
33
- 'x' => Danica::Wrapper::Variable,
34
- 10 => Danica::Wrapper::Number,
35
- 10.5 => Danica::Wrapper::Number,
36
- -10 => Danica::Wrapper::Negative,
37
- { name: :x } => Danica::Wrapper::Variable,
38
- { value: 10, latex: :x, gnuplot: :X } => Danica::Wrapper::Constant,
39
- Danica::Wrapper::Variable.new(:x).tex => Danica::Wrapper::Variable,
40
- Danica.build(:x) { x } => Danica::Expression
41
- }
34
+ it_behaves_like 'a value wrapper',
35
+ x: Danica::Wrapper::Variable,
36
+ 'x' => Danica::Wrapper::Variable,
37
+ 10 => Danica::Wrapper::Number,
38
+ 10.5 => Danica::Wrapper::Number,
39
+ -10 => Danica::Wrapper::Negative,
40
+ { name: :x } => Danica::Wrapper::Variable,
41
+ { value: 10, latex: :x, gnuplot: :X } => Danica::Wrapper::Constant,
42
+ Danica::Wrapper::Variable.new(:x).tex => Danica::Wrapper::Variable,
43
+ Danica.build(:x) { x } => Danica::Expression
42
44
 
43
45
  context 'when value is non accepted' do
44
46
  let(:value) { Object.new }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Danica do
@@ -10,13 +12,13 @@ describe Danica do
10
12
  end
11
13
 
12
14
  it 'returns the expected addition' do
13
- expect(result.expression_block).to eq(Danica::Operator::Addition.new(1,2))
15
+ expect(result.expression_block).to eq(Danica::Operator::Addition.new(1, 2))
14
16
  end
15
17
  end
16
18
 
17
19
  context 'when creating a power of addition and multiplication' do
18
20
  let(:block) do
19
- proc { power(addition(1, 2), multiplication(2,3)) }
21
+ proc { power(addition(1, 2), multiplication(2, 3)) }
20
22
  end
21
23
  let(:expected) do
22
24
  Danica::Operator::Power.new(
@@ -70,7 +72,7 @@ describe Danica do
70
72
 
71
73
  context 'when defining a negative output' do
72
74
  let(:block) do
73
- proc { -(sum(2, 3)) }
75
+ proc { -sum(2, 3) }
74
76
  end
75
77
 
76
78
  let(:expected) do
@@ -83,7 +85,7 @@ describe Danica do
83
85
  expect(result.expression_block).to eq(expected)
84
86
  end
85
87
 
86
- context 'for a number' do
88
+ context 'when it is a number' do
87
89
  let(:block) do
88
90
  proc { -num(2) }
89
91
  end
@@ -99,4 +101,3 @@ describe Danica do
99
101
  end
100
102
  end
101
103
  end
102
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'simplecov'
2
4
 
3
5
  SimpleCov.profiles.define 'gem' do
@@ -8,7 +10,6 @@ SimpleCov.start 'gem'
8
10
  require 'pry-nav'
9
11
  require 'danica'
10
12
 
11
-
12
13
  # This file was generated by the `rspec --init` command. Conventionally, all
13
14
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
14
15
  # Require this file using `require "spec_helper"` to ensure that it is only
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Danica
2
4
  class Expression::Baskara < Expression.build(:a, :b, :c) { numerator / denominator }
3
-
4
5
  private
5
6
 
6
7
  def numerator
7
- negative(b) + Wrapper::PlusMinus.new(squared_root(delta))
8
+ negative(b) + Wrapper::PlusMinus.new(squared_root(delta))
8
9
  end
9
10
 
10
11
  def denominator
@@ -16,4 +17,3 @@ module Danica
16
17
  end
17
18
  end
18
19
  end
19
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Danica
2
4
  class Parabole < Expression.build(:x) { power(x, 2) }
3
5
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Danica
2
4
  class Expression
3
- class QuadraticSum < build(:x, :y) { (x + y) ** 2 }
5
+ class QuadraticSum < build(:x, :y) { (x + y)**2 }
4
6
  end
5
7
  end
6
8
  end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Danica
2
4
  class Expression::Spatial < Expression.build(:time, :acceleration, :initial_space, :initial_velocity) { addition(parcels) }
3
-
4
5
  private
5
6
 
6
7
  def parcels
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Danica::Function::MyFunction < Danica::Function
2
4
  variables :x, :y
3
5
 
4
6
  def function_block
5
- x ** 2 + y
7
+ x**2 + y
6
8
  end
7
9
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module Danica
3
4
  class Function::Parabole < Function.build(:x) { Danica::Parabole.new }
@@ -13,4 +14,3 @@ module Danica
13
14
  end
14
15
  end
15
16
  end
16
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../expression/quadratic_sum'
2
4
 
3
5
  module Danica
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Danica
2
4
  class Function::Spatial < Function
3
5
  variables :time, :acceleration, :initial_space, :initial_velocity
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Danica::Operator::Inverse < Danica::Operator
2
4
  variables :value
3
5
 
4
6
  def to_f
5
- value.to_f ** -1 #Do not worry with nil value as this has been implemented already raising Danica::Exception::NotDefined
7
+ value.to_f**-1 # Do not worry with nil value as this has been implemented already raising Danica::Exception::NotDefined
6
8
  end
7
9
 
8
10
  def to_tex
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class MyOperator < Danica::Operator
2
4
  variables :x
3
5
 
4
6
  def to_f
5
- (x ** Danica::PI).to_f
7
+ (x**Danica::PI).to_f
6
8
  end
7
9
 
8
10
  def to_tex
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Danica
2
4
  module VariablesHolder
3
5
  class Dummy
@@ -9,7 +11,7 @@ module Danica
9
11
  delegate :to, :to_f, to: :block
10
12
 
11
13
  def block
12
- x ** y + z
14
+ x**y + z
13
15
  end
14
16
  end
15
17
 
@@ -1,5 +1,7 @@
1
- shared_context 'variables are initialized' do |arguments, *names|
1
+ # frozen_string_literal: true
2
+
3
+ shared_context 'when variables are initialized' do |arguments, *names|
2
4
  names.each do |key|
3
- let(key) { arguments[key.to_sym] }
5
+ let(key) { arguments[key.to_sym] }
4
6
  end
5
7
  end
@@ -1,5 +1,7 @@
1
- shared_examples 'an object with basic operation' do |operations:%i(+ - * / **), ignore:[]|
2
- (operations - [ ignore ].flatten).each do |operation|
1
+ # frozen_string_literal: true
2
+
3
+ shared_examples 'an object with basic operation' do |operations: %i[+ - * / **], ignore: []|
4
+ (operations - [ignore].flatten).each do |operation|
3
5
  it_behaves_like "an object with #{operation} operation"
4
6
  end
5
7
  end
@@ -25,6 +27,7 @@ shared_examples 'an object with + operation' do
25
27
 
26
28
  context 'when operating as reverse' do
27
29
  let(:result) { Danica::Wrapper::Number.new(other) + subject }
30
+
28
31
  it_behaves_like 'an object with an operation', Danica::Operator::Addition
29
32
  end
30
33
  end
@@ -38,6 +41,7 @@ shared_examples 'an object with * operation' do
38
41
 
39
42
  context 'when operating as reverse' do
40
43
  let(:result) { Danica::Wrapper::Number.new(other) * subject }
44
+
41
45
  it_behaves_like 'an object with an operation', Danica::Operator::Multiplication
42
46
  end
43
47
  end
@@ -77,7 +81,7 @@ end
77
81
 
78
82
  shared_examples 'an object with ** operation' do
79
83
  let(:other) { 104 }
80
- let(:result) { subject ** other }
84
+ let(:result) { subject**other }
81
85
 
82
86
  it { expect(result).to be_a(Danica::Operator::Power) }
83
87
 
@@ -89,4 +93,3 @@ shared_examples 'an object with ** operation' do
89
93
  expect(result.exponent).to eq(Danica::Wrapper::Number.new(other))
90
94
  end
91
95
  end
92
-
@@ -1,4 +1,6 @@
1
- shared_examples 'an object that respond to basic_methods' do |ignore: [], methods: %i(to_f to_tex to_gnu priority valued? container? variable? variable_holder?)|
1
+ # frozen_string_literal: true
2
+
3
+ shared_examples 'an object that respond to basic_methods' do |ignore: [], methods: %i[to_f to_tex to_gnu priority valued? container? variable? variable_holder?]|
2
4
  (methods - ignore).each do |method|
3
5
  it { expect(subject).to respond_to(method) }
4
6
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  shared_examples 'a operator that joins many variables with same operation' do |arguments|
2
4
  it_behaves_like 'a operator that knows how to calculate', arguments
3
5
  it_behaves_like 'a operator that knows how to write to tex', arguments
@@ -5,14 +7,15 @@ shared_examples 'a operator that joins many variables with same operation' do |a
5
7
  end
6
8
 
7
9
  shared_examples 'a operator that knows how to calculate' do |arguments|
8
- include_context 'variables are initialized', arguments, 'calculated'
10
+ include_context 'when variables are initialized', arguments, 'calculated'
11
+ subject { described_class.new(*variables) }
12
+
9
13
  let(:variables) do
10
14
  (1..4).map do |i|
11
- { name: "X#{i}", value: numeric_variables[i-1] }
15
+ { name: "X#{i}", value: numeric_variables[i - 1] }
12
16
  end
13
17
  end
14
- let(:numeric_variables){ (1..4).to_a }
15
- subject { described_class.new(*variables) }
18
+ let(:numeric_variables) { (1..4).to_a }
16
19
 
17
20
  describe 'to_f' do
18
21
  it 'returns the addition of variables value' do
@@ -46,10 +49,11 @@ shared_examples 'a operator that knows how to write to gnu' do |arguments|
46
49
  end
47
50
 
48
51
  shared_examples 'a operator that knows how to write to a string' do |format, arguments|
49
- let(:numeric_variables) { arguments[:numeric_variables] }
50
- include_context 'variables are initialized', arguments[format], *%w(integer_expected string_expected float_expected)
51
52
  subject { described_class.new(*variables) }
52
53
 
54
+ let(:numeric_variables) { arguments[:numeric_variables] }
55
+ include_context 'when variables are initialized', arguments[format], 'integer_expected', 'string_expected', 'float_expected'
56
+
53
57
  describe "#to(#{format})" do
54
58
  let(:variables) do
55
59
  (1..4).map { |i| "X#{i}" }
@@ -63,6 +67,7 @@ shared_examples 'a operator that knows how to write to a string' do |format, arg
63
67
 
64
68
  context 'when some variables have values' do
65
69
  let(:numeric_variables_index) { 1 }
70
+
66
71
  before do
67
72
  (0..numeric_variables_index).each do |i|
68
73
  subject.variables[i].value = numeric_variables[i]
@@ -84,6 +89,7 @@ shared_examples 'a operator that knows how to write to a string' do |format, arg
84
89
 
85
90
  context 'when some variables are numbers' do
86
91
  let(:numeric_variables_index) { 1 }
92
+
87
93
  before do
88
94
  (0..numeric_variables_index).each do |i|
89
95
  variables[i] = numeric_variables[i]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  shared_examples 'a operator that has two terms' do |name, arguments|
2
4
  it_behaves_like 'a operator that has two terms and knows how to calculate it', name, arguments
3
5
  it_behaves_like 'a operator that has two terms and knows how to call to_tex', arguments
@@ -5,11 +7,11 @@ shared_examples 'a operator that has two terms' do |name, arguments|
5
7
  end
6
8
 
7
9
  shared_examples 'a operator that has two terms and knows how to calculate it' do |name, arguments|
8
- include_context 'variables are initialized', arguments, *%w(values calculated)
10
+ include_context 'when variables are initialized', arguments, 'values', 'calculated'
9
11
 
10
12
  let(:variables) do
11
- [ 1, 2 ].map do |i|
12
- { name: "X#{i}", value: values[i-1] }
13
+ [1, 2].map do |i|
14
+ { name: "X#{i}", value: values[i - 1] }
13
15
  end
14
16
  end
15
17
 
@@ -63,17 +65,17 @@ end
63
65
  shared_examples 'a operator that has two terms and knows how to return a string out of it' do |command, arguments|
64
66
  let(:values) { arguments[:values] }
65
67
 
66
- include_context 'variables are initialized', arguments[command], *%w(string_expected numeric_string_expected partial_string_expected)
68
+ include_context 'when variables are initialized', arguments[command], 'string_expected', 'numeric_string_expected', 'partial_string_expected'
67
69
  describe "##{command}" do
68
70
  let(:variables) do
69
- [ 1, 2 ].map do |i|
70
- { name: "X#{i}", value: values[i-1] }
71
+ [1, 2].map do |i|
72
+ { name: "X#{i}", value: values[i - 1] }
71
73
  end
72
74
  end
73
75
 
74
76
  context 'when variables have no value' do
75
77
  let(:variables) do
76
- [ 1,2 ].map { |i| "X#{i}" }
78
+ [1, 2].map { |i| "X#{i}" }
77
79
  end
78
80
 
79
81
  it 'returns a text format fraction' do
@@ -109,4 +111,3 @@ shared_examples 'a operator that has two terms and knows how to return a string
109
111
  end
110
112
  end
111
113
  end
112
-