<commit_before>require "test_helper"

describe "Pliny integration test" do
  before do
    FileUtils.rm_rf("/tmp/plinytest")
    FileUtils.mkdir_p("/tmp/plinytest")
    Dir.chdir("/tmp/plinytest")
  end

  it "works" do
    Pliny::Commands::Creator.run(["myapp"], StringIO.new)
    bash "bin/setup"
    assert File.exists?("./myapp/Gemfile.lock")
  end

  def bash(cmd)
    unless system("cd myapp && #{cmd} > /dev/null")
      raise "Failed to run #{cmd}"
    end
  end
end<commit_msg>tweak integration test further, use the actual bin file<commit_after>require "test_helper"

describe "Pliny integration test" do
  before do
    FileUtils.rm_rf("/tmp/plinytest")
    FileUtils.mkdir_p("/tmp/plinytest")
    Dir.chdir("/tmp/plinytest")
  end

  it "works" do
    bash "pliny-new myapp"
    bash_app "bin/setup"
    assert File.exists?("./myapp/Gemfile.lock")
    bash_app "pliny-generate model artist"
    assert File.exists?("./myapp/lib/models/artist.rb")
  end

  def bash(cmd)
    bin  = File.expand_path('../bin', File.dirname(__FILE__))
    path = "#{bin}:#{ENV["PATH"]}"
    env = { "PATH" => path }
    unless system(env, "#{cmd} > /dev/null")
      raise "Failed to run #{cmd}"
    end
  end

  def bash_app(cmd)
    bash "cd myapp && #{cmd}"
  end
end
{'fraction_non_alphanumeric': 0.15689381933438987, 'fraction_numerical': 0.0, 'mean_word_length': 3.21, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '5686128', 'n_tokens_mistral': 470, 'n_tokens_neox': 460, 'n_words': 104}