0
0
Fork 0

Add tests for Rubella::Input::Base

This commit is contained in:
Stormwind 2015-05-01 12:43:01 +02:00
parent 13397ccfe7
commit ce6cfb7977
4 changed files with 54 additions and 0 deletions

View File

@ -9,6 +9,16 @@ module Rubella
class Base
attr_reader :data
# Constructor
# Create a new Rubella::Input::Base object using the given data
#
# @param var Input data
# @return Rubell::Input::Base
#
def initialize data
@data = data
end
# Passes each dataset trought the given block.
#
# @param pointer to block

View File

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

View File

@ -0,0 +1,16 @@
require 'spec_helper'
describe Rubella::Input::Base, '.each' do
it "passes the data through the given block" do
storage = Rubella::Input::Base.new [3, 4, 5]
sum = 0
storage.each do |value|
sum = sum + value
end
expect(sum).to eq(12)
end
end

View File

@ -0,0 +1,17 @@
require 'spec_helper'
describe Rubella::Input::Base, '.new' do
it "creates a new Input instance" do
input = Rubella::Input::Base.new nil
expect(input).to be_instance_of(Rubella::Input::Base)
end
it "uses the given data" do
input = Rubella::Input::Base.new 54
expect(input.data).to eq(54)
end
end