Sha256: 81ca8dd3ee47ca298f3cd8906717ca870b47c38be45b4514afe8ebc98165024d

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

require File.join(File.dirname(__FILE__), %w[.. spec_helper])

require TireSwing.path(%w(spec grammars magic))

describe MagicAssignments::GrammarParser do
  describe ".ast" do
    before(:each) do
      @input = File.read(TireSwing.path(%w(spec fixtures assignments.txt)))
      @result = MagicAssignments::GrammarParser.ast(@input)
    end

    it "returns an AST" do
      @result.should be_an_instance_of(MagicAssignments::AST::Assignments)
    end

    it "has the right number of assignments" do
      @result.should have(3).assignments
    end

    it "has an assignment with correct values" do
      @result.assignments.first.should be_an_instance_of(MagicAssignments::AST::Assignment)
      @result.assignments.first.lhs.should == "foo"
      @result.assignments.first.rhs.should == "bar"
    end

  end
end

describe MagicAssignments::HashVisitor do
  describe ".visit" do
    it "returns a hash representation of the assignments" do
      ast = MagicAssignments::GrammarParser.ast(File.read(TireSwing.path(%w(spec fixtures assignments.txt))))
      MagicAssignments::HashVisitor.visit(ast).should == {
        "foo" => "bar",
        "baz" => "blech",
        "no" => "way"
      }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aniero-tire_swing-0.0.3 spec/integration/magic_spec.rb
aniero-tire_swing-0.0.4 spec/integration/magic_spec.rb
aniero-tire_swing-0.0.5 spec/integration/magic_spec.rb
aniero-tire_swing-0.0.6 spec/integration/magic_spec.rb