Sha256: 2040a64024dd743b9f5688f60329ff082c8a716e578587e696759f9226648ab1

Contents?: true

Size: 844 Bytes

Versions: 4

Compression:

Stored size: 844 Bytes

Contents

require "spec_helper"

RSpec.describe Template do
  subject { described_class.render(input, input_context) }

  [
    ["Hello World", "", "Hello World"],
    ["1 + 1 = {2}", "", "1 + 1 = 2"],
    ["Hello {name}", '{ name: "Dorian" }', "Hello Dorian"],
    [
      "Hello {user.first_name}",
      '{ user: { first_name: "Dorian" } }',
      "Hello Dorian",
    ],
    [
      "{add(1, 2)",
      'add = (a, b) => { a + b } { add: context(:add) }',
      "3",
    ],
    ["Hello {", "", "Hello "],
    ["{{a: 1}.each { |k, v| print(k) } nothing", "", "a"],
    ["", "", ""],
  ].each do |(input, input_context, expected)|
    context "#{input.inspect} #{input_context.inspect}" do
      let(:input) { input }
      let(:input_context) { input_context }

      it "succeeds" do
        expect(subject).to eq(expected)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
template-ruby-0.3.1 spec/template_spec.rb
code-ruby-0.3.1 spec/template_spec.rb
template-ruby-0.3.0 spec/template_spec.rb
code-ruby-0.3.0 spec/template_spec.rb