spec/lib/danica/formatted_spec.rb in danica-2.7.2 vs spec/lib/danica/formatted_spec.rb in danica-2.7.3

- old
+ new

@@ -1,8 +1,7 @@ require 'spec_helper' - shared_examples 'a formatted result' do |output| it do expect(result).to be_a(described_class) end @@ -27,10 +26,26 @@ describe Danica::Formatted do let(:content) { Danica::Wrapper::Variable.new(latex: :V, gnuplot: :v) } let(:format) { :tex } let(:options) { {} } subject do - described_class.new(content, format, options) + described_class.new(content, format: format, **options) + end + + describe '#repack' do + let(:expression) { Danica::Wrapper::Number.new(1.0 / 3) } + + it do + expect(subject.repack(expression)).to be_a(Danica::Formatted) + end + + context 'when there are options' do + let(:options) { { decimals: 3 } } + + it 'wraps expression with options' do + expect(subject.repack(expression).to_s).to eq('0.333') + end + end end describe '#to_s' do context 'when format is tex' do it 'return the expected tex string' do