<commit_before>require 'spec_helper'

RSpec.describe MultitenancyTools::SchemaSwitcher do
  subject { described_class.new('foobar', Db.connection) }

  describe '#execute' do
    before do
      Db.connection.schema_search_path = 'something'
    end

    it 'receives and executes a block' do
      expect do |b|
        subject.run(&b)
      end.to yield_control
    end

    it 'sets the correct search path when executing the block' do
      subject.run do
        expect(Db.connection.schema_search_path).to eql("'foobar'")
      end
    end

    it 'sets the search path back to its previous value' do
      subject.run {}
      expect(Db.connection.schema_search_path).to eql("something")
    end

    it 'sets the search path back to its previous value when an error occurs' do
      subject.run { fail 'OMG' } rescue
      expect(Db.connection.schema_search_path).to eql("something")
    end
  end
end<commit_msg>Fix wrong usage of rescue<commit_after>require 'spec_helper'

RSpec.describe MultitenancyTools::SchemaSwitcher do
  subject { described_class.new('foobar', Db.connection) }

  describe '#execute' do
    before do
      Db.connection.schema_search_path = 'something'
    end

    it 'receives and executes a block' do
      expect do |b|
        subject.run(&b)
      end.to yield_control
    end

    it 'sets the correct search path when executing the block' do
      subject.run do
        expect(Db.connection.schema_search_path).to eql("'foobar'")
      end
    end

    it 'sets the search path back to its previous value' do
      subject.run {}
      expect(Db.connection.schema_search_path).to eql("something")
    end

    it 'sets the search path back to its previous value when an error occurs' do
      expect do
        subject.run { fail 'OMG' }
      end.to raise_error(/OMG/)
      expect(Db.connection.schema_search_path).to eql('something')
    end
  end
end
{'fraction_non_alphanumeric': 0.08487084870848709, 'fraction_numerical': 0.0, 'mean_word_length': 2.8813905930470347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2360051', 'n_tokens_mistral': 582, 'n_tokens_neox': 559, 'n_words': 178}