Sha256: 50bc06362af832e7ddb621c6f4ead42c4ffc6b5cfb23db0cf91d1fc236a1f39e

Contents?: true

Size: 1011 Bytes

Versions: 7

Compression:

Stored size: 1011 Bytes

Contents

require "spec_helper"
require "expressir/express_exp/parser"

RSpec.describe Expressir::Model::Scope do
  describe ".source" do
    it "contains original source" do
      input = File.read(sample_file)
      repo = Expressir::ExpressExp::Parser.from_exp(sample_file)

      expected_result = input
      expect(repo.source).to eq(expected_result)

      schema = repo.schemas.first
      start_index = input.index("SCHEMA")
      stop_index = input.index("END_SCHEMA;") + "END_SCHEMA;".length - 1
      expected_result = input[start_index..stop_index]
      expect(schema.source).to eq(expected_result)

      entity = schema.entities.first
      start_index = input.index("ENTITY")
      stop_index = input.index("END_ENTITY;") + "END_ENTITY;".length - 1
      expected_result = input[start_index..stop_index]
      expect(entity.source).to eq(expected_result)
    end
  end

  def sample_file
    @sample_file ||= Expressir.root_path.join(
      "original", "examples", "syntax", "syntax.exp"
    )
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
expressir-0.2.8 spec/expressir/express_exp/source_spec.rb
expressir-0.2.8-x86_64-linux spec/expressir/express_exp/source_spec.rb
expressir-0.2.8-x86_64-darwin spec/expressir/express_exp/source_spec.rb
expressir-0.2.8-x86-mingw32 spec/expressir/express_exp/source_spec.rb
expressir-0.2.8-x86-linux spec/expressir/express_exp/source_spec.rb
expressir-0.2.8-x64-mingw32 spec/expressir/express_exp/source_spec.rb
expressir-0.2.8-arm64-darwin spec/expressir/express_exp/source_spec.rb