<commit_before>require "spec_helper"

require "tempfile"

module Figs
  describe Application do
    before do
      Application.any_instance.stub(
        default_figfile: "",
        default_path: "/path/to/app/config/application.yml",
        default_stage: "development"
      )
    end

    describe "#path" do
      it "uses the default" do
        application = Application.new
        expect(application.path).to eq("/path/to/app/config/application.yml")
      end
    
      it "is configurable via initialization" do
        application = Application.new(file: YAML.load("location: /app/env.yml\nmethod: path"))
      
        expect(application.path).to eq("/app/env.yml")
      end
    
      it "is configurable via setter" do
        application = Application.new
        application.path = "/app/env.yml"
      
        expect(application.path).to eq("/app/env.yml")
      end
    
      it "casts to string" do
        application = Application.new(file: YAML.load("location: /app/env.yml\nmethod: path"))
      
        expect(application.path).to eq("/app/env.yml")
        expect(application.stage).not_to be_a(Pathname)
      end
    
      it "follows a changing default" do
        application = Application.new
    
        expect {
          application.stub(default_path: "/app/env.yml")
        }.to change {
          application.path
        }.from("/path/to/app/config/application.yml").to("/app/env.yml")
      end
      
      it "allows multiple files" do
        application = Application.new(file: YAML.load("location:\n- /app/env1.yml\n- /app/env2.yml\nmethod: path"))
        
        expect(application.path).to eq(["/app/env1.yml","/app/env2.yml"])
      end
      
      describe "git" do
        it "allows for a git repo" do
          application = Application.new(file: YAML.load("location:\n- <EMAIL>:NYULibraries/xCite_settings.git\n- testing.yml\nmethod: git"))

          expect(application.path).to_not eq(:default_path)
        end
      end
    end

    describe "#stage" do
      it "uses the default" do<commit_msg>Use Open Source repo for testing.<commit_after>require "spec_helper"

require "tempfile"

module Figs
  describe Application do
    before do
      Application.any_instance.stub(
        default_figfile: "",
        default_path: "/path/to/app/config/application.yml",
        default_stage: "development"
      )
    end

    describe "#path" do
      it "uses the default" do
        application = Application.new
        expect(application.path).to eq("/path/to/app/config/application.yml")
      end
    
      it "is configurable via initialization" do
        application = Application.new(file: YAML.load("location: /app/env.yml\nmethod: path"))
      
        expect(application.path).to eq("/app/env.yml")
      end
    
      it "is configurable via setter" do
        application = Application.new
        application.path = "/app/env.yml"
      
        expect(application.path).to eq("/app/env.yml")
      end
    
      it "casts to string" do
        application = Application.new(file: YAML.load("location: /app/env.yml\nmethod: path"))
      
        expect(application.path).to eq("/app/env.yml")
        expect(application.stage).not_to be_a(Pathname)
      end
    
      it "follows a changing default" do
        application = Application.new
    
        expect {
          application.stub(default_path: "/app/env.yml")
        }.to change {
          application.path
        }.from("/path/to/app/config/application.yml").to("/app/env.yml")
      end
      
      it "allows multiple files" do
        application = Application.new(file: YAML.load("location:\n- /app/env1.yml\n- /app/env2.yml\nmethod: path"))
        
        expect(application.path).to eq(["/app/env1.yml","/app/env2.yml"])
      end
      
      describe "git" do
        it "allows for a git repo" do
          application = Application.new(file: YAML.load("location:\n- <EMAIL>:hab278/test-figs.git\n- testing.yml\n- test.yml\nmethod: git"))

          expect(application.path).to_not eq(:default_path)
        end
      end
    end

    describe "#stage" do
      it "uses the default" do
{'fraction_non_alphanumeric': 0.1245483016140689, 'fraction_numerical': 0.0026499638641291254, 'mean_word_length': 2.1598173515981736, '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': '750782', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1232, 'n_words': 269}