spec/lib/danica/function_spec.rb in danica-2.4.3 vs spec/lib/danica/function_spec.rb in danica-2.4.4
- old
+ new
@@ -108,19 +108,45 @@
end
end
it_behaves_like 'a generically generated function'
end
+ describe '#name' do
+ let(:function) do
+ function_class.new(name: :f)
+ end
+
+ it do
+ expect(function.name).to be_a(Danica::Function::Name)
+ end
+
+ context 'when changing the function variables' do
+ it 'changes the name variables' do
+ expect do
+ function.x = 2
+ end.to change { function.name.variables.map(&:content) }
+ end
+ end
+ end
+
describe '#describe_tex' do
context 'when function has a name' do
let(:function) do
function_class.new(name: :f)
end
it 'returns the full function description' do
expect(function.describe_tex).to eq('f(x, y) = x^{y}')
end
+
+ context 'and one of the variables is changed' do
+ it 'uses the new variable value' do
+ expect do
+ function.y = 2
+ end.to change(function, :describe_tex).to('f(x, 2) = x^{2}')
+ end
+ end
end
context 'when a variable is set as a constant' do
let(:function) do
function_class.new(name: :f, x: Danica::PI)
@@ -326,10 +352,10 @@
end
describe '#variables' do
context 'when initialized with an array of variables' do
subject { described_class::Spatial.new(variables: variables.values) }
- let(:expected) { variables.values.map { |v| subject.send(:wrap_value, v)} }
+ let(:expected) { variables.values.map { |v| Danica::Wrapper::Variable.new(v.is_a?(Hash) ? v : { name: v }) } }
it do
expect(subject.variables.compact).to eq(expected)
end
end