Sha256: 33020f6d9cfaae3b33f74a1f650dbf2c5208f0f35b3e75d6fa6d816515964540

Contents?: true

Size: 895 Bytes

Versions: 16

Compression:

Stored size: 895 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Unparser::Comments, '#take_eol_comments' do

  let(:ast_and_comments) do
    Parser::CurrentRuby.parse_with_comments(<<-RUBY)
def hi # EOL 1
=begin
doc comment
=end
end # EOL 2
    RUBY
  end
  let(:ast)              { ast_and_comments[0] }
  let(:comments)         { ast_and_comments[1] }
  let(:object)           { described_class.new(comments) }

  it 'should return no comments if nothing has been consumed' do
    expect(object.take_eol_comments).to eql([])
  end

  it 'should return comments once their line has been consumed' do
    object.consume(ast, :name)
    expect(object.take_eol_comments).to eql([comments[0]])
  end

  it 'should leave doc comments to be taken later' do
    object.consume(ast)
    expect(object.take_eol_comments).to eql([comments[0], comments[2]])
    expect(object.take_all).to eql([comments[1]])
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
unparser-0.2.4 spec/unit/unparser/comments/take_eol_comments_spec.rb
unparser-0.2.3 spec/unit/unparser/comments/take_eol_comments_spec.rb
unparser-0.2.2 spec/unit/unparser/comments/take_eol_comments_spec.rb
unparser-0.2.1 spec/unit/unparser/comments/take_eol_comments_spec.rb
unparser-0.2.0 spec/unit/unparser/comments/take_eol_comments_spec.rb
unparser-0.1.16 spec/unit/unparser/comments/take_eol_comments_spec.rb
unparser-0.1.15 spec/unit/unparser/comments/take_eol_comments_spec.rb
unparser-0.1.14 spec/unit/unparser/comments/take_eol_comments_spec.rb
unparser-0.1.13 spec/unit/unparser/comments/take_eol_comments_spec.rb
unparser-0.1.12 spec/unit/unparser/comments/take_eol_comments_spec.rb
unparser-0.1.11 spec/unit/unparser/comments/take_eol_comments_spec.rb
unparser-0.1.10 spec/unit/unparser/comments/take_eol_comments_spec.rb
unparser-0.1.9 spec/unit/unparser/comments/take_eol_comments_spec.rb
unparser-0.1.8 spec/unit/unparser/comments/take_eol_comments_spec.rb
unparser-0.1.7 spec/unit/unparser/comments/take_eol_comments_spec.rb
unparser-0.1.6 spec/unit/unparser/comments/take_eol_comments_spec.rb