<commit_before>require 'spec_helper'

describe Generator::BinaryRelation, '#to_s' do
  subject { object.to_s }

  let(:object) { described_class.new }

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

    it { should respond_to(:to_s) }

    it { should be_frozen }

    its(:to_s) { should == '' }
  end
end
<commit_msg>Added more specs for BinaryRelation#to_s<commit_after>require 'spec_helper'

describe Generator::BinaryRelation, '#to_s' do
  subject { object.to_s }

  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, '<NAME>', 35 ] ].each                   }
  let(:base_relation) { BaseRelation.new('users', header, body)          }
  let(:object)        { described_class.new                              }

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

    it { should respond_to(:to_s) }

    it { should be_frozen }

    its(:to_s) { should == '' }
  end

  context 'when a difference is visited' do
    before do
      object.visit(base_relation.difference(base_relation))
    end

    it_should_behave_like 'a generated SQL expression'

    its(:to_s) { should eql('SELECT "id", "name", "age" FROM "users" EXCEPT SELECT "id", "name", "age" FROM "users"') }
  end

  context 'when an intersection is visited' do
    before do
      object.visit(base_relation.intersect(base_relation))
    end

    it_should_behave_like 'a generated SQL expression'

    its(:to_s) { should eql('SELECT "id", "name", "age" FROM "users" INTERSECT SELECT "id", "name", "age" FROM "users"') }
  end

  context 'when a union is visited' do
    before do
      object.visit(base_relation.union(base_relation))
    end

    it_should_behave_like 'a generated SQL expression'

    its(:to_s) { should eql('SELECT "id", "name", "age" FROM "users" UNION SELECT "id", "name", "age" FROM "users"') }
  end
end

{'fraction_non_alphanumeric': 0.12621809744779583, 'fraction_numerical': 0.0013921113689095127, 'mean_word_length': 2.6854700854700853, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5326483', 'n_tokens_mistral': 716, 'n_tokens_neox': 677, 'n_words': 181}