spec/lib/danica/constant_spec.rb in danica-2.0.1 vs spec/lib/danica/constant_spec.rb in danica-2.0.2
- old
+ new
@@ -1,10 +1,13 @@
require 'spec_helper'
describe Danica::Constant do
- let(:subject) { described_class.new(2.5, :M, :m) }
+ subject { described_class.new(2.5, :M, :m) }
+ let(:other) { described_class.new(3, :N, :n) }
+ it_behaves_like 'an object with + operation'
+
describe '#to_f' do
it 'has a value' do
expect(subject.to_f).to eq(2.5)
end
end
@@ -23,8 +26,25 @@
describe 'variables' do
it { expect(subject).not_to respond_to(:value=) }
it { expect(subject).not_to respond_to(:latex=) }
it { expect(subject).not_to respond_to(:gnu=) }
+ end
+
+ describe '==' do
+ context 'when comparing with the same object' do
+ it { expect(subject).to eq(subject) }
+ end
+
+ context 'when comparing with a diferent object' do
+ context 'with diferent values' do
+ it { expect(subject).not_to eq(other) }
+ end
+
+ context 'with same values' do
+ let(:other) { described_class.new(2.5, :M, :m) }
+ it { expect(subject).to eq(other) }
+ end
+ end
end
end