Permalink
Browse files

! fixing error messages

  • Loading branch information...
1 parent 12c79fe commit a6938e604e07b4d54ce30dbbc758ed1aa5fa7677 @kschiess committed Feb 3, 2011
Showing with 17 additions and 2 deletions.
  1. +1 −0 Gemfile
  2. +3 −0 Gemfile.lock
  3. +3 −2 lib/parslet/atoms/base.rb
  4. +10 −0 spec/parslet/atoms/base_spec.rb
View
@@ -10,5 +10,6 @@ group :development do
gem 'sdoc'
gem 'guard'
+ gem 'guard-rspec'
gem 'growl'
end
View
@@ -9,6 +9,8 @@ GEM
guard (0.3.0)
open_gem (~> 1.4.2)
thor (~> 0.14.6)
+ guard-rspec (0.1.9)
+ guard (>= 0.2.2)
json (1.5.0)
launchy (0.3.7)
configuration (>= 0.0.5)
@@ -38,5 +40,6 @@ DEPENDENCIES
flexmock
growl
guard
+ guard-rspec
rspec
sdoc
@@ -33,7 +33,7 @@ def parse(io)
# Stack trace will be off, but the error tree should explain the reason
# it failed.
if value.error?
- raise Parslet::ParseFailed, value.message
+ parse_failed(value.message)
end
# assert: value is a success answer
@@ -85,7 +85,8 @@ def apply(source, context) # :nodoc:
# behaviour.
#
def try(source, context)
- raise NotImplementedError, "Atoms::Base doesn't have behaviour, please implement #try(io)."
+ raise NotImplementedError, \
+ "Atoms::Base doesn't have behaviour, please implement #try(source, context)."
end
# Construct a new atom that repeats the current atom min times at least and
@@ -47,6 +47,16 @@
end
end
end
+
+ context "when the parse fails, the exception" do
+ it "should contain a string" do
+ begin
+ Parslet.str('foo').parse('bar')
+ rescue Parslet::ParseFailed => ex
+ ex.message.should be_kind_of(String)
+ end
+ end
+ end
context "when not all input is consumed" do
let(:parslet) { Parslet.str('foo') }
it "should raise with a proper error message" do

0 comments on commit a6938e6

Please sign in to comment.