Sha256: a981f7eca6d1e821a7ffba776a3b1a1c100bab7bd3a39a3b03b1c001bbd38dce

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe SQL::Generator::Relation, '#to_sql' do
  subject { object.to_sql }

  let(:described_class) { Class.new(SQL::Generator::Relation)              }
  let(:id)              { Attribute::Integer.new(:id)                      }
  let(:name)            { Attribute::String.new(:name)                     }
  let(:age)             { Attribute::Integer.new(:age, :required => false) }
  let(:header)          { [ id, name, age ]                                }
  let(:body)            { [ [ 1, 'Dan Kubb', 35 ] ].each                   }
  let(:object)          { described_class.new                              }

  context 'when no object visited' do
    it_should_behave_like 'an idempotent method'

    it { should be_kind_of(String) }

    it { should be_frozen }

    it { should == '' }
  end

  context 'when an object is visited' do
    let(:visitable) { mock('Visitable') }

    before do
      described_class.class_eval do
        def visit_spec_mocks_mock(mock)
          mock
        end
      end
    end

    before do
      @original = object.to_sql
      object.visit(visitable)
    end

    it_should_behave_like 'an idempotent method'

    it { should be_kind_of(String) }

    it { should be_frozen }

    it { should_not equal(@original) }

    it { should eql(visitable.to_s) }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
veritas-sql-generator-0.0.7 spec/unit/veritas/sql/generator/relation/to_sql_spec.rb
veritas-sql-generator-0.0.6 spec/unit/veritas/sql/generator/relation/to_sql_spec.rb
veritas-sql-generator-0.0.5 spec/unit/veritas/sql/generator/relation/to_sql_spec.rb
veritas-sql-generator-0.0.4 spec/unit/veritas/sql/generator/relation/to_sql_spec.rb
veritas-sql-generator-0.0.3 spec/unit/veritas/sql/generator/relation/to_sql_spec.rb