Sha256: f5c1b6151b4a57b673b75dc6e521708c0e845e439f175446754e31e47481f60b

Contents?: true

Size: 748 Bytes

Versions: 4

Compression:

Stored size: 748 Bytes

Contents

require_relative '../spec_helper'
require 'sql/query_maker'
require 'sql/maker/helper'

def test(src, expected_term, expected_bind)
  describe 'SQL::QueryMaker' do
    include SQL::Maker::Helper

    it src do
      term = instance_eval src
      sql = term.as_sql
      bind = term.bind
      expect(sql).to be == expected_term
      expect(bind).to be == expected_bind
    end
  end
end

begin
  file = File.open("#{ROOT}/doc/sql/query_maker.md")
  while line = file.gets
    break if line =~ /CHEAT SHEET/
  end
  while line = file.gets
    src = $1 if line =~ /IN:\s*(.+)\s*$/
    query = eval($1, binding) if line =~ /OUT QUERY:(.+)/
    if line =~ /OUT BIND:(.+)/
      bind = eval($1, binding)
      test(src, query, bind)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sql-maker-1.0.0 spec/query_maker/cheatsheet_spec.rb
sql-maker-0.0.5 spec/query_maker/cheatsheet_spec.rb
sql-maker-0.0.4 spec/query_maker/cheatsheet_spec.rb
sql-maker-0.0.3 spec/query_maker/cheatsheet_spec.rb