Sha256: 7d015a35f0e4b324328eeb93eaef04ee81f3092e58a4ffadd452c918095a7610

Contents?: true

Size: 947 Bytes

Versions: 2

Compression:

Stored size: 947 Bytes

Contents

require 'spec_helper'
require 'ronin/sql/emittable'
require 'ronin/sql/literal'

describe SQL::Emittable do
  subject { SQL::Literal.new('hello') }

  describe "#emitter" do
    it "should return an SQL::Emitter" do
      subject.emitter.should be_kind_of(SQL::Emitter)
    end

    it "should accept Emitter options" do
      subject.emitter(:case => :lower).case.should == :lower
    end
  end

  describe "#to_sql" do
    it "should emit the object" do
      subject.to_sql.should == "'hello'"
    end

    context "when given options" do
      it "should pass them to #emitter" do
        subject.to_sql(quotes: :double).should == '"hello"'
      end
    end
  end

  describe "#to_s" do
    it "should call #to_sql with no arguments" do
      subject.to_s.should == subject.to_sql
    end
  end

  describe "#inspect" do
    it "should call #to_sql with no arguments" do
      subject.inspect.should include(subject.to_sql)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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