spec/writer/symbolmatrix_spec.rb in symbolmatrix-1.1.2 vs spec/writer/symbolmatrix_spec.rb in symbolmatrix-1.1.3
- old
+ new
@@ -41,11 +41,11 @@
writer.hash
end
end
end
- shared_examples_for 'any serialization' do
+ shared_examples_for 'any writer serialization' do
it 'should serialize "try: this" into "try:this"' do
s = SymbolMatrix try: "this"
writer = Writer::SymbolMatrix.new s
writer.send(@method).should == "try:this"
end
@@ -137,15 +137,40 @@
end
end
describe '#serialization' do
before { @method = :serialization }
- it_behaves_like 'any serialization'
+ it_behaves_like 'any writer serialization'
end
describe '#smas' do
before { @method = :smas }
- it_behaves_like 'any serialization'
+ it_behaves_like 'any writer serialization'
+ end
+
+ describe '#json' do
+ it 'should return a json serialization' do
+ sm = SymbolMatrix alpha: { beta: "gamma" }
+ writer = Writer::SymbolMatrix.new sm
+ writer.json.should == '{"alpha":{"beta":"gamma"}}'
+ end
+ end
+
+ describe '#yaml' do
+ it 'should return a yaml serialization' do
+ sm = SymbolMatrix alpha: { beta: "gamma" }
+ writer = Writer::SymbolMatrix.new sm
+ writer.yaml.should include "alpha:\n beta: gamma"
+ end
+ end
+
+ describe '#string_key_hash' do
+ it 'should convert a SymbolMatrix to a multidimentional hash with all string keys' do
+ sm = SymbolMatrix alpha: { beta: "gamma" }
+ writer = Writer::SymbolMatrix.new sm
+ writer.string_key_hash
+ .should == { "alpha" => { "beta" => "gamma"} }
+ end
end
end
describe SymbolMatrix do
it 'should include the Discoverer for Writer' do