Sha256: a7afabc99430cf671ac91a42d9d96f280f39d9d7ec6629c68cb2a2934461fded

Contents?: true

Size: 944 Bytes

Versions: 2

Compression:

Stored size: 944 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
      statement.keyword.should == keyword
    end

    case argument
    when Proc
      it "should accept a block" do
        statement.argument.should_not be_nil
      end
    when NilClass
      it "should not have an argument" do
        statement.argument.should be_nil
      end
    when Array
      it "should accept an argument" do
        statement.argument.should == arguments
      end
    else
      it "should accept an argument" do
        statement.argument.should == argument
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ronin-sql-1.1.0 spec/sql/statement_examples.rb
ronin-sql-1.0.0 spec/sql/statement_examples.rb