require 'test/spec' require 'pyrosoma' context "Pyrosoma::Frame rendering" do db = Pyrosoma::Database.new(:dir => Ferret::Store::RAMDirectory.new) simple = Pyrosoma::Frame.new({:id => "simple", :foo => "bar", :quux => "zing"}) db << simple complex = Pyrosoma::Frame.new({:id => "complex", :foo => ["bar", "baz"], :quux => "@simple", :content => "blah."}) db << complex templatetest = Pyrosoma::Frame.new({:id => "templatetest", :title => "wow", :template => "Title: ${self[:title]}"}) db << templatetest # context "using Pryosoma::Template" do # specify "works" do # db["templatetest"].render.should.equal "Title: wow" # # lambda { db["simple"].render }.should.raise(NoMethodError) # end # end context "using XOXO" do specify "works for simple structures" do xoxo = db["simple"].to_xoxo xoxo.should.include "
id
simple
" xoxo.should.include "
foo
bar
" xoxo.should.include "
quux
zing
" end specify "works for complex structures" do xoxo = db["complex"].to_xoxo xoxo.should.include "
id
complex
" xoxo.should.include "
foo
  1. bar
  2. baz
" xoxo.should.include "
quux
simple" xoxo.should.include "
content
blah.
" end specify "can roundtrip" do Pyrosoma::Frame.from_xoxo(db["complex"].to_xoxo).should.equal db["complex"] end specify "can DWIM on loading" do Pyrosoma::Frame.from_xoxo(< "test"})
  1. test
EOF Pyrosoma::Frame.from_xoxo(< ["1", "2", "3"]})
  1. 1
  2. 2
  3. 3
EOF end end context "using Microformats" do specify "works for simple structures" do db["simple"].to_microformat.should.equal <simplebarzing EOF end specify "works for complex structures" do mf = db["complex"].to_microformat mf.should.include "" mf.should.include "complex" mf.should.include "barbaz" mf.should.include "blah." mf.should.include "simple" mf.should =~ /<\/span>\Z/ end end end