Sha256: e0722770dc78e2b4e3e5b9e9d89d95fd5ad76444d36053984b5b5d638ab79027

Contents?: true

Size: 916 Bytes

Versions: 4

Compression:

Stored size: 916 Bytes

Contents

require "spec_helper"

class LuaLoopLuobo < Luobo
  attr_accessor :token_stack, :dumps

  def regex_line_comment; "\s*--+\s?" end # use # as line comments

  def dump contents;
    # p contents
    @dumps = Array.new unless @dumps 
    @dumps << contents 
  end

  def last_dump; @dumps[-1] if @dumps end
  
  def stack_size; @token_stack.size end

  def do_spec token
    "spec (#{token.line_code}, function()\n" + token.block_code + "\nend)"
  end
end

describe LuaLoopLuobo do

  context "Simple examples" do
    subject(:lb){ LuaLoopLuobo.new('examples/lua_loop.lua', STDOUT) }
    it "expands variables inside" do
      lb.process!
      lb.dumps[-3].should eq("spec (\"first test\", function()\n   local name = \"first\"\n   do_test()\nend)")
      lb.dumps[-2].should eq("spec (\"second test\", function()\n   local name = \"last\"\n   do_test()\nend)")
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
luobo-0.1.3 spec/lua_loop_spec.rb
luobo-0.1.2 spec/lua_loop_spec.rb
luobo-0.0.5 spec/lua_loop_spec.rb
luobo-0.1.0 spec/lua_loop_spec.rb