Sha256: 027a438c974592dbcd2de64fe7b042cc29eb5faba26879734f94a54220e47e83

Contents?: true

Size: 1.11 KB

Versions: 16

Compression:

Stored size: 1.11 KB

Contents

require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
require 'pp'
require 'stringio'

include YARD::Parser::Ruby

if RUBY19
  describe YARD::Parser::Ruby::AstNode do
    describe "#jump" do
      it "should jump to the first specific inner node if found" do
        ast = s(:paren, s(:paren, s(:params, s(s(:ident, "hi"), s(:ident, "bye")))))
        ast.jump(:params)[0][0].type.should equal(:ident)
      end
  
      it "should return the original ast if no inner node is found" do
        ast = s(:paren, s(:list, s(:list, s(s(:ident, "hi"), s(:ident, "bye")))))
        ast.jump(:params).object_id.should == ast.object_id
      end
    end
    
    describe '#pretty_print' do
      it "should show a list of nodes" do
        obj = YARD::Parser::Ruby::RubyParser.parse("# x\nbye", "x").ast
        out = StringIO.new
        PP.pp(obj, out)
        out.rewind
        out.read.should == "s(s(:var_ref,\n" +
          "      s(:ident, \"bye\", line: 2..2, source: 4..6),\n" +
          "      docstring: \"x\",\n" +
          "      line: 2..2,\n" +
          "      source: 4..6))\n"
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
yard-0.6.4 spec/parser/ruby/ast_node_spec.rb
yard-0.6.3 spec/parser/ruby/ast_node_spec.rb
yard-0.6.2 spec/parser/ruby/ast_node_spec.rb
yard-0.6.1 spec/parser/ruby/ast_node_spec.rb
yard-0.6.0 spec/parser/ruby/ast_node_spec.rb
yard-0.5.8 spec/parser/ruby/ast_node_spec.rb
yard-0.5.7 spec/parser/ruby/ast_node_spec.rb
yard-0.5.6 spec/parser/ruby/ast_node_spec.rb
yard-0.5.5 spec/parser/ruby/ast_node_spec.rb
yard-0.5.4 spec/parser/ruby/ast_node_spec.rb
yard-0.5.3 spec/parser/ruby/ast_node_spec.rb
yard-0.5.2 spec/parser/ruby/ast_node_spec.rb
yard-0.5.1p1 spec/parser/ruby/ast_node_spec.rb
yard-0.5.1 spec/parser/ruby/ast_node_spec.rb
yard-0.5.0 spec/parser/ruby/ast_node_spec.rb
yard-0.4.0 spec/parser/ruby/ast_node_spec.rb