Add tests for Rubella::Input::Base
This commit is contained in:
parent
13397ccfe7
commit
ce6cfb7977
|
@ -9,6 +9,16 @@ module Rubella
|
||||||
class Base
|
class Base
|
||||||
attr_reader :data
|
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.
|
# Passes each dataset trought the given block.
|
||||||
#
|
#
|
||||||
# @param pointer to block
|
# @param pointer to block
|
||||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue