Sha256: 11ca36985cd9d8ea7209b54c3687a7c12e88a6a07009c8c0b6c7cdfbd5c72718

Contents?: true

Size: 909 Bytes

Versions: 5

Compression:

Stored size: 909 Bytes

Contents

# encoding: utf-8

require_relative '../../minitest_helper'
require 'strike/interpreter'

class Strike::InterpreterTest < MiniTest::Unit::TestCase
  def setup
    @interpreter = Strike::Interpreter.new(table_source)
    @profile = <<-PROFILE
    table :users do |t|
      t.name :first_name
    end

    table :movies
    PROFILE
  end

  def test_should_parse_a_profile_into_tables
    tables = @interpreter.parse(@profile)

    assert_equal 2, tables.count
    assert tables[:users]
    assert tables[:movies]

    table_mock.verify
  end

  def test_should_have_default_tables
    tables = @interpreter.tables

    assert_equal :keep, tables[:test].call
    assert_equal :keep, tables[:test2].call
  end

  private

  def table_source
    ->(&block) { block ? block.call(table_mock) : table_mock }
  end

  def table_mock
    @table_mock ||= MiniTest::Mock.new.expect(:name, true, [:first_name])
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
strike-0.3.6 test/lib/strike/interpreter_test.rb
strike-0.3.5 test/lib/strike/interpreter_test.rb
strike-0.3.3 test/lib/strike/interpreter_test.rb
strike-0.3.2 test/lib/strike/interpreter_test.rb
strike-0.3.1 test/lib/strike/interpreter_test.rb