Add tests for Rubella::Input::JSON
This commit is contained in:
parent
ce6cfb7977
commit
ebd5b88861
|
@ -0,0 +1 @@
|
|||
[1, 2, 3]
|
|
@ -0,0 +1,11 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Rubella::Input::JSON, '.data' do
|
||||
|
||||
it "returns the stored data" do
|
||||
input = Rubella::Input::JSON.string "[3, 4, 5]"
|
||||
|
||||
expect(input.data).to eq([3, 4, 5])
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Rubella::Input::JSON, '.each' do
|
||||
|
||||
it "passes the data through the given block" do
|
||||
input = Rubella::Input::JSON.string "[3, 4, 5]"
|
||||
|
||||
sum = 0
|
||||
input.each do |value|
|
||||
sum = sum + value
|
||||
end
|
||||
|
||||
expect(sum).to eq(12)
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Rubella::Input::JSON, '#self.file' do
|
||||
|
||||
it 'returns a Rubella::Input::JSON object' do
|
||||
input = Rubella::Input::JSON.file 'spec/fixtures/json/test_01.json'
|
||||
|
||||
expect(input).to be_instance_of(Rubella::Input::JSON)
|
||||
end
|
||||
|
||||
it "uses the given data" do
|
||||
input = Rubella::Input::JSON.file 'spec/fixtures/json/test_01.json'
|
||||
|
||||
expect(input.data).to eq([1, 2, 3])
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Rubella::Input::JSON, '#self.string' do
|
||||
|
||||
it 'returns a Rubella::Input::JSON object' do
|
||||
input = Rubella::Input::JSON.string '[]'
|
||||
|
||||
expect(input).to be_instance_of(Rubella::Input::JSON)
|
||||
end
|
||||
|
||||
it "uses the given data" do
|
||||
input = Rubella::Input::JSON.string '[1, 2, 3]'
|
||||
|
||||
expect(input.data).to eq([1, 2, 3])
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue