diff --git a/spec/unit/rubella/storage/add_spec.rb b/spec/unit/rubella/storage/add_spec.rb index 2bb4e10..f16645c 100644 --- a/spec/unit/rubella/storage/add_spec.rb +++ b/spec/unit/rubella/storage/add_spec.rb @@ -10,4 +10,20 @@ describe Rubella::Storage, '.add' do expect(storage_new.data).to eq([0, 1, 2, 3, 4, 5]) end + it "uses the length of the first given Storage" do + storage_1 = Rubella::Storage.new [3, 4, 5, 6, 7], 4 + storage_2 = Rubella::Storage.new [0, 1, 2], 3 + + storage_new = storage_1.add storage_2 + expect(storage_new.length).to eq 4 + end + + it "chops the data to the given length" do + storage_1 = Rubella::Storage.new [3, 4, 5, 6, 7], 4 + storage_2 = Rubella::Storage.new [0, 1, 2], 3 + + storage_new = storage_1.add storage_2 + expect(storage_new.data).to eq([0, 1, 2, 3]) + end + end diff --git a/spec/unit/rubella/storage/length_spec.rb b/spec/unit/rubella/storage/length_spec.rb new file mode 100644 index 0000000..579a54a --- /dev/null +++ b/spec/unit/rubella/storage/length_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe Rubella::Storage, '.length' do + + it "returns the current length" do + storage = Rubella::Storage.new [3, 4, 5] + + expect(storage.length).to eq 3 + end + +end \ No newline at end of file