require 'spec_helper'
module Diagnostics
describe DataGroup do
describe '#attributes' do
context 'with no attributes set' do
it 'returns an empty array' do
subject.attributes.should eq([])
end
end
context 'given :plain format' do
let(:data_group) { create_data_group }
specify do
data_group.attributes(:plain).should eq(['a: 1', 'b: 2'])
end
end
context 'given :html format' do
let(:data_group) { create_data_group }
specify do
data_group.attributes(:html).should eq(
['a: 1', 'b: 2']
)
end
end
def create_data_group
data_group = subject
data_group['a'] = 1
data_group['b'] = 2
data_group
end
end
describe '#lists' do
context 'with no lists added' do
it 'returns an empty array' do
subject.lists.should eq([])
end
end
context 'given :plain format' do
let(:data_group) { create_data_group }
specify do
data_group.lists(:plain).should eq(
["a\nb\nc", "1\n2\n3"]
)
end
end
context 'given :html format' do
let(:data_group) { create_data_group }
specify do
data_group.lists(:html).should eq(
['a
b
c', '1
2
3']
)
end
end
def create_data_group
data_group = subject
data_group << ['a', 'b', 'c']
data_group << [1, 2, 3]
data_group
end
end
describe '#texts' do
context 'with no texts added' do
it 'returns an empty array' do
subject.texts.should eq([])
end
end
context 'given :plain format' do
let(:data_group) { create_data_group }
specify do
data_group.texts(:plain).should eq(['a', 'b'])
end
end
context 'given :html format' do
let(:data_group) { create_data_group }
specify do
data_group.texts(:html).should eq(
['
a
', 'b
'] ) end end def create_data_group data_group = subject data_group << 'a' data_group << 'b' data_group end end describe '#tables' do context 'with no texts added' do it 'returns an empty array' do subject.tables.should eq([]) end end context 'given :html format' do let(:data_group) { create_data_group } specify do data_group.tables(:html).should eq( [ 'heading 1 | ' \ 'heading 2 | ' \ '
---|---|
1 | ' \ '3 | ' \ '
2 | ' \ '' \ ' |