Add tests for Rubella::Storage.data, Rubella::Storage.new
This commit is contained in:
parent
366cd8aa45
commit
13397ccfe7
|
@ -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
|
||||
#
|
||||
|
|
|
@ -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
|
|
@ -65,4 +65,4 @@ describe Rubella::Storage, '.length=' do
|
|||
expect(storage.data.length).to eq(0)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue