Sha256: 8f6086116d49f710894f45c464ec3643ffec82254d8c7df335fce70a7b1729d6

Contents?: true

Size: 967 Bytes

Versions: 1

Compression:

Stored size: 967 Bytes

Contents

require 'spec_helper'

shared_examples_for "Statement" do |method,keyword,argument=nil|
  describe "##{method}" do
    case argument
    when Array
      let(:arguments) { argument }

      let(:statement) { subject.send(method,*arguments) }
    when NilClass
      let(:statement) { subject.send(method) }
    else
      let(:statement) { subject.send(method,argument) }
    end

    it "should add a #{keyword} clause" do
      expect(statement.keyword).to eq(keyword)
    end

    case argument
    when Proc
      it "should accept a block" do
        expect(statement.argument).not_to be_nil
      end
    when NilClass
      it "should not have an argument" do
        expect(statement.argument).to be_nil
      end
    when Array
      it "should accept an argument" do
        expect(statement.argument).to eq(arguments)
      end
    else
      it "should accept an argument" do
        expect(statement.argument).to eq(argument)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-code-sql-2.0.0.beta1 spec/sql/statement_examples.rb