Sha256: 76b40feaa76bb099a6f7c49fcf96e9ece85a53c92df91e620718a44af7eb254c

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  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(:base_relation) { Relation::Base.new('users', header, body)        }
  let(:object)        { described_class.new                              }

  context 'when name is nil' do
    it_should_behave_like 'an idempotent method'

    it { should be(false) }
  end

  context 'when name is set' do
    let(:name) { 'test' }

    before do
      # subclasses set @name, but nothing in this class
      # does does so simulate it being set
      object.instance_variable_set(:@name, name)
    end

    it_should_behave_like 'an idempotent method'

    it { should be(true) }
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
axiom-sql-generator-0.1.0 spec/unit/axiom/sql/generator/relation/visited_spec.rb
veritas-sql-generator-0.0.7 spec/unit/veritas/sql/generator/relation/visited_spec.rb
veritas-sql-generator-0.0.6 spec/unit/veritas/sql/generator/relation/visited_spec.rb
veritas-sql-generator-0.0.5 spec/unit/veritas/sql/generator/relation/visited_spec.rb
veritas-sql-generator-0.0.4 spec/unit/veritas/sql/generator/relation/visited_spec.rb