<commit_before>require "_helpers"

describe "Wraith config to CLI argument mapping" do
  describe "construct_command" do
    it "passing variables to construct_command outputs correct command" do

    end
  end
end<commit_msg>started writing unit tests for construct_command<commit_after>require "_helpers"

describe "Wraith config to CLI argument mapping" do
  describe "passing variables to construct_command" do
    let(:config_name) { get_path_relative_to __FILE__, "./configs/test_config--phantom.yaml" }
    let(:saving) { Wraith::SaveImages.new(config_name) }

    it "should take a load of variables and construct a command" do
      width = saving.prepare_widths_for_cli(320)
      url = 'http://example.com/my-page'
      file_name = 'wraith/my-page/320_phantomjs_latest.png'
      selector = '.my_selector'
      global_before_capture = 'javascript/before_capture.js'
      path_before_capture = 'false'
      command = saving.construct_command(width, url, file_name, selector, global_before_capture, path_before_capture)
      expect(command).to eq "phantomjs  '/Users/ashton/Sites/bbc/wraith/lib/wraith/javascript/phantom.js' 'http://example.com/my-page' \"320\" 'wraith/my-page/320_phantomjs_latest.png' '.my_selector' 'javascript/before_capture.js' 'false'"
    end

    it "should allow hashtags in selectors" do
      width = 320
      url = 'http://example.com/my-page'
      file_name = 'wraith/my-page/320_phantomjs_latest.png'
      selector = '#some-id'
      global_before_capture = 'javascript/before_capture.js'
      path_before_capture = 'false'
      command = saving.construct_command(width, url, file_name, selector, global_before_capture, path_before_capture)
      expect(command).to eq "phantomjs  '/Users/ashton/Sites/bbc/wraith/lib/wraith/javascript/phantom.js' 'http://example.com/my-page' \"320\" 'wraith/my-page/320_phantomjs_latest.png' '#some-id' 'javascript/before_capture.js' 'false'"
    end

    it "should be able to pass multiple widths at once" do
      width = saving.prepare_widths_for_cli([320, 624, 976])
      url = 'http://example.com/my-page'
      file_name = 'wraith/my-page/320_phantomjs_latest.png'
      selector = '.my_selector'
      global_before_capture = 'javascript/before_capture.js'
      path_before_capture = 'false'
      command = saving.construct_command(width, url, file_name, selector, global_before_capture, path_before_capture)
      expect(command).to eq "phantomjs  '/Users/ashton/Sites/bbc/wraith/lib/wraith/javascript/phantom.js' 'http://example.com/my-page' \"'320','624','976'\" 'wraith/my-page/320_phantomjs_latest.png' '.my_selector' 'javascript/before_capture.js' 'false'"
    end
  end
end
{'fraction_non_alphanumeric': 0.11813084112149533, 'fraction_numerical': 0.01794392523364486, 'mean_word_length': 4.106870229007634, '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': '2738042', 'n_tokens_mistral': 920, 'n_tokens_neox': 860, 'n_words': 175}