Sha256: 069c8baf7ef586196665753b5e10f277b2b2f3dc647075c690f2e90305675c51

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

require "spec_helper"

RSpec.describe ::Code::Parser do
  subject { ::Code::Parser.parse(input) }

  [
    "a",
    "admin?",
    "update!",
    "*args",
    "**kargs",
    "&block",
    "update!(user)",
    "puts(1)",
    "print(1)",
    "defined?(a)",
    "each{}",
    "each do end",
    "render(a, *b, **c, &d) { |e, *f, **g, &h| puts(e) }",
    "&render {}"
  ].each do |input|
    context input do
      let!(:input) { input }

      it { expect { subject }.to_not raise_error }
    end
  end

  [
    "update! /* cool */ { }",
    "each{/* cool */}",
    "render(/* cool */ a)",
    "render(a /* cool */)",
    "render(a, /* cool */ b)",
    "render(a, b /* cool */)",
    "render(/* cool */ a: 1)",
    "render(a: 1 /* cool */)",
    "render(a: 1, /* cool */ b: 2)",
    "render(a: 1, b: 2 /* cool */)",
    "render { /* cool */ |a, b| }",
    "render { |/* cool */ a, b| }",
    "render { |a /* cool */, b| }",
    "render { |a: 1, /* cool */ b: 2| }",
    "render { |a: 1, b: 2 /* cool */| }"
  ].each do |input|
    context input do
      let!(:input) { input }

      it { expect(subject.to_json).to include("cool") }
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
template-ruby-parser-0.1.2 spec/code/parser/call_spec.rb
code-ruby-parser-0.1.2 spec/code/parser/call_spec.rb
template-ruby-parser-0.1.1 spec/code/parser/call_spec.rb
code-ruby-parser-0.1.1 spec/code/parser/call_spec.rb
template-ruby-parser-0.1.0 spec/code/parser/call_spec.rb
code-ruby-parser-0.1.0 spec/code/parser/call_spec.rb