Sha256: 84df0005ab17854849b1463c5de622b06feb81163db66e458e69444efe8aa4fd

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

shared_examples_for "Clause" do |method,keyword,argument_or_block=nil|
  describe "##{method}" do
    case argument_or_block
    when Proc
      before { subject.send(method,&argument_or_block) }
    when Array
      let(:arguments) { argument_or_block }

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

      before { subject.send(method,argument) }
    end

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

    case argument_or_block
    when Proc
      it "should accept a block" do
        expect(clause.argument).not_to be_nil
      end
    when NilClass
      it "should not have an argument" do
        expect(clause.argument).to be_nil
      end
    when Array
      it "should accept an argument" do
        expect(clause.argument).to eq(arguments)
      end
    else
      it "should accept an argument" do
        expect(clause.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/clause_examples.rb