Sha256: fe36256fe3d1370243b1840f56261f3f7ca53e624fbca7a622e6773c854e4eda

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

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

    case argument_or_block
    when Proc
      it "should accept a block" do
        clause.argument.should_not be_nil
      end
    when NilClass
      it "should not have an argument" do
        clause.argument.should be_nil
      end
    when Array
      it "should accept an argument" do
        clause.argument.should == arguments
      end
    else
      it "should accept an argument" do
        clause.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/clause_examples.rb
ronin-sql-1.0.0 spec/sql/clause_examples.rb