0
0
Fork 0

Add tests for Rubella::Storage.data, Rubella::Storage.new

This commit is contained in:
Stormwind 2015-05-01 11:18:56 +02:00
parent 366cd8aa45
commit 13397ccfe7
4 changed files with 57 additions and 1 deletions

View File

@ -24,6 +24,8 @@ module Rubella
#
# Setting the length to 0 will disable this feature
#
# TODO fill up with 0 values, if data is not multidemensional
#
# @param length Integer The size of the storage
# @return Integer The new size
#

View File

@ -0,0 +1,11 @@
require 'spec_helper'
describe Rubella::Storage, '.data' do
it "retuns the stored data" do
storage = Rubella::Storage.new [3, 4, 5]
expect(storage.data).to eq([3, 4, 5])
end
end

View File

@ -65,4 +65,4 @@ describe Rubella::Storage, '.length=' do
expect(storage.data.length).to eq(0)
end
end
end

View File

@ -0,0 +1,43 @@
require 'spec_helper'
describe Rubella::Storage, '.new' do
it "creates a new Storage" do
storage = Rubella::Storage.new []
expect(storage).to be_an_instance_of(Rubella::Storage)
end
it "fills the Storage with the given data" do
storage = Rubella::Storage.new [1, 2, 3]
expect(storage.data).to eq([1, 2, 3])
end
it "disable length feature, if no length is given" do
storage = Rubella::Storage.new [1, 2, 3]
expect(storage.length).to eq(3)
expect(storage.data.length).to eq(3)
end
it "disable length feature, if length is 0" do
storage = Rubella::Storage.new [1, 2, 3], 0
expect(storage.length).to eq(3)
expect(storage.data.length).to eq(3)
end
it "sets the length" do
storage = Rubella::Storage.new [1, 2, 3], 2
expect(storage.length).to eq(2)
end
it "uses length feature, if length is given" do
storage = Rubella::Storage.new [1, 2, 3], 2
expect(storage.data.length).to eq(2)
end
end