Permalink
Browse files

First few tests.

  • Loading branch information...
1 parent 01be781 commit 7c72689267954c5bf70ee3c4c11a4c67305db945 rking committed May 2, 2012
Showing with 29 additions and 0 deletions.
  1. +29 −0 spec/parser_spec.rb
View
@@ -0,0 +1,29 @@
+require 'helper'
+require 'pegex/parser'
+
+describe Pegex::Parser do
+ it "new should handle explicit receiver" do
+ prs = described_class.new grammar: {}, receiver: :yep
+ prs.receiver.should eq :yep
+ end
+ it "new should default receiver" do
+ expect { Pegex::Receiver }.to raise_error NameError
+ prs = described_class.new grammar: {}
+ prs.receiver.class.should eq Pegex::Receiver
+ end
+end
+
+describe Pegex::Parser do
+ before(:each) do
+ @prs = Pegex::Parser.new grammar: {}
+ @input = 'XXX' # XXX
+ end
+ # TODO:
+ # it "should parse correct types of 'input'" do
+ # ...
+ # end
+ it 'should require grammar' do
+ @prs.grammar = nil
+ expect { @prs.parse @input }.to raise_error RuntimeError
+ end
+end

0 comments on commit 7c72689

Please sign in to comment.