require 'spec_helper'

describe Petroglyph::Engine do
  specify "#to_hash" do
    engine = Petroglyph::Engine.new('node :whatever => thing')
    engine.to_hash({:thing => 'stuff'}).should eq({:whatever => 'stuff'})
  end

  it "takes a template" do
    engine = Petroglyph::Engine.new('node :whatever => "nevermind"')
    engine.render.should eq({:whatever => "nevermind"}.to_json)
  end

  it "takes a block" do
    Petroglyph::Engine.new.render do
      node :whatever => "nevermind"
    end.should eq({:whatever => "nevermind"}.to_json)
  end

  it "passes the locals" do
    engine = Petroglyph::Engine.new('node :whatever => thing')
    engine.render(nil, {:thing => 'stuff'}).should eq({:whatever => 'stuff'}.to_json)
  end
end

require 'spec_helper'

describe Petroglyph::Engine do
  specify "#to_hash" do
    engine = Petroglyph::Engine.new('node :beverage => drink')
    engine.to_hash({:drink => 'espresso'}).should eq({:beverage => 'espresso'})
  end

  it "takes a template" do
    engine = Petroglyph::Engine.new('node :beverage => "no, thanks"')
    engine.render.should eq({:beverage => "no, thanks"}.to_json)
  end

  it "takes a block" do
    Petroglyph::Engine.new.render do
      node :beverage => "hot chocolate"
    end.should eq({:beverage => "hot chocolate"}.to_json)
  end

  it "passes the locals" do
    engine = Petroglyph::Engine.new('node :beverage => drink')
    engine.render(nil, {:drink => 'bai mu cha'}).should eq({:beverage => 'bai mu cha'}.to_json)
  end
end

Use different test data in each engine test.
Use different test data in each engine test.
