On Oct 31, 2008, at 5:40 PM, Brice Figureau wrote:
>
>
> Signed-off-by: Brice Figureau <[EMAIL PROTECTED]>
> ---
> spec/unit/parser/ast.rb | 21 +++++++++++++++++++++
> spec/unit/parser/lexer.rb | 37 +++++++++++++++++++++++++++++++++++
> +-
> spec/unit/parser/parser.rb | 12 ++++++++++++
> 3 files changed, 69 insertions(+), 1 deletions(-)
> create mode 100644 spec/unit/parser/ast.rb
>
> diff --git a/spec/unit/parser/ast.rb b/spec/unit/parser/ast.rb
> new file mode 100644
> index 0000000..85be803
> --- /dev/null
> +++ b/spec/unit/parser/ast.rb
> @@ -0,0 +1,21 @@
> +#!/usr/bin/env ruby
> +
> +require File.dirname(__FILE__) + '/../../spec_helper'
> +
> +require 'puppet/parser/ast'
> +
> +describe Puppet::Parser::AST do
> +
> + it "should have a doc accessor" do
> + ast = Puppet::Parser::AST.new({})
> + ast.should be_respond_to(:doc)
> + end
RSpec comes with a 'respond_to' matcher, so you can just directly do
'should respond_to(:doc)'.
>
> + describe "when initializing" do
> + it "should store the doc argument" do
> + ast = Puppet::Parser::AST.new({ :doc =>
> "documentation" })
> + ast.doc.should == "documentation"
> + end
> + end
Doesn't really matter, but Ruby automatically turns hash-like
arguments into a hash. AST.new({:doc => "foo"}) is the same as
AST.new(:doc => "foo").
>
> +end
> \ No newline at end of file
> diff --git a/spec/unit/parser/lexer.rb b/spec/unit/parser/lexer.rb
> index 3b0df96..f67959f 100755
> --- a/spec/unit/parser/lexer.rb
> +++ b/spec/unit/parser/lexer.rb
> @@ -30,7 +30,7 @@ describe Puppet::Parser::Lexer::Token do
> @token =
> Puppet::Parser::Lexer::Token.new(%r{something}, :NAME)
> end
>
> - [:regex, :name, :string, :skip, :incr_line, :skip_text].each do
> |param|
> +
> [:regex
> , :name, :string, :skip, :incr_line, :skip_text, :accumulate].each
> do |param|
> it "should have a #{param.to_s} reader" do
> @token.should be_respond_to(param)
> end
> @@ -285,6 +285,14 @@ describe
> Puppet::Parser::Lexer::TOKENS[:COMMENT] do
> it "should be marked to get skipped" do
> @token.skip?.should be_true
> end
> +
> + it "should be marked to accumulate" do
> + @token.accumulate?.should be_true
> + end
> +
> + it "'s block should return the comment without the #" do
> + @token.convert(@lexer,"# this is a comment")[1].should == "
> this is a comment"
> + end
> end
Shouldn't it strip leading space, too?
[...]
--
To succeed in the world it is not enough to be stupid, you must also
be well-mannered. -- Voltaire
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---