<commit_before>#encoding: utf-8

require_relative '../spec_helper'
require_relative '../support/active_record'
require 'togglr/toggles'
require 'togglr/active_record/repository'

module Togglr
  describe Toggles do

    let(:file_contents) do
      %q{---
:category:
  :true_toggle:
    :value: true
  :false_toggle:
    :value: false
  :some_toggle:
    :value: false
      }
    end

    let(:temp_file) do
      t = Tempfile.new('yaml_repo')
      t.write(file_contents)
      t.rewind
      t
    end

    after do
      temp_file.close
      temp_file.unlink
    end

    context 'with the ActiveRecord repository' do
      before do
        Togglr.configure do |cfg|
          cfg.toggles_file = temp_file.path
          cfg.repositories = ['Togglr::ActiveRecord::Repository']
        end

        Toggles.register_toggles
      end


      describe '#<toggle_name>?' do
        context 'no value in database' do
          it 'returns the toggle value from the yaml file' do
            expect(Togglr::Toggles.true_toggle?).to be_true
          end
        end

        context 'value in the database' do
          it 'returns the value from the database' do
            Togglr::Toggles.true_toggle = false
            expect(Togglr::Toggles.true_toggle?).to be_false
          end
        end
      end
    end
  end


end # module Togglr
<commit_msg>Expand test to show prior data<commit_after>#encoding: utf-8

require_relative '../spec_helper'
require_relative '../support/active_record'
require 'togglr/toggles'
require 'togglr/active_record/repository'

module Togglr
  describe Toggles do

    let(:file_contents) do
      %q{---
:category:
  :true_toggle:
    :value: true
  :false_toggle:
    :value: false
  :some_toggle:
    :value: false
      }
    end

    let(:temp_file) do
      t = Tempfile.new('yaml_repo')
      t.write(file_contents)
      t.rewind
      t
    end

    after do
      temp_file.close
      temp_file.unlink
    end

    context 'with the ActiveRecord repository' do
      before do
        Togglr.configure do |cfg|
          cfg.toggles_file = temp_file.path
          cfg.repositories = ['Togglr::ActiveRecord::Repository']
        end

        Toggles.register_toggles
      end


      describe '#<toggle_name>?' do
        context 'no value in database' do
          it 'returns the toggle value from the yaml file' do
            expect(Togglr::Toggles.true_toggle?).to be_true
          end
        end

        context 'value in the database' do
          it 'returns the value from the database' do
            expect(Togglr::Toggles.true_toggle?).to be_true
            Togglr::Toggles.true_toggle = false
            expect(Togglr::Toggles.true_toggle?).to be_false
          end
        end
      end
    end
  end


end # module Togglr

{'fraction_non_alphanumeric': 0.08413891872538488, 'fraction_numerical': 0.0007160759040458289, 'mean_word_length': 2.1393258426966293, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6029990', 'n_tokens_mistral': 911, 'n_tokens_neox': 882, 'n_words': 225}