<commit_before># Please note: cannot test, if it really accesses your platform clipboard.

require File.expand_path('spec/spec_helper')

$os = RbConfig::CONFIG['host_os']

describe Clipboard do
  before do
    RbConfig::CONFIG['host_os'] = $os
  end

  it "has a VERSION" do
    Clipboard::VERSION.should =~ /^\d+\.\d+\.\d+$/
  end

  it "can copy & paste" do
    Clipboard.copy("FOO\nBAR")
    Clipboard.paste.should == "FOO\nBAR"
  end

  it "returns data on copy" do
    Clipboard.copy('xxx').should == 'xxx'
  end

  it "can clear" do
    Clipboard.copy('xxx')
    Clipboard.clear
    Clipboard.paste.should == ''
  end

  describe "when included" do
    class A
      include Clipboard
    end

    it "can copy & paste & clear" do
      a = A.new
      a.send(:copy, "XXX").should == 'XXX'
      a.send(:paste).should == "XXX"
      a.send(:clear)
      a.send(:paste).should == ''
    end
  end

  describe 'Clipboard::File' do
    before :all do
      Clipboard.implementation = Clipboard::File
      cache = Clipboard::File::FILE
      FileUtils.rm cache if File.exist?(cache)
    end

    it "can paste with empty file" do
      Clipboard.paste.should == ''
    end

    it "can copy & paste" do
      Clipboard.copy('xxx').should == 'xxx'
      Clipboard.paste.should == 'xxx'
    end

    it "can clear" do
      Clipboard.copy('xxx').should == 'xxx'
      Clipboard.clear
      Clipboard.paste.should == ''
    end
  end

  describe :implementation do
    before do
      $VERBOSE = true
      Clipboard.implementation = nil
    end

    it "does not warn on normal detection" do
      $stderr.should_not_receive(:puts)
      Clipboard.implementation
    end

    it "warns when OS is unknown" do
      RbConfig::CONFIG['host_os'] = 'Fooo OS'
      $stderr.should_receive(:puts)
      Clipboard.implementation.should == Clipboard::File
    end

    it "does not warn when $VERBOSE is false" do
      $VERBOSE = false
      RbConfig::CONFIG['host_os'] = 'Fooo OS'
      $stderr.should_not_receive(:puts)
      Clipboard.implementation
    end
  end
end<commit_msg>tweak spec suite<commit_after># Please note: cannot test, if it really accesses your platform clipboard.

require File.expand_path('spec/spec_helper')

$os = RbConfig::CONFIG['host_os']

describe Clipboard do
  before do
    RbConfig::CONFIG['host_os'] = $os
  end

  it "has a VERSION" do
    Clipboard::VERSION.should =~ /^\d+\.\d+\.\d+$/
  end

  it "can copy & paste" do
    Clipboard.copy("FOO\nBAR")
    Clipboard.paste.should == "FOO\nBAR"
  end

  it "returns data on copy" do
    Clipboard.copy('xxx').should == 'xxx'
  end

  it "can clear" do
    Clipboard.copy('xxx')
    Clipboard.clear
    Clipboard.paste.should == ''
  end

  describe "when included" do
    class A
      include Clipboard
    end

    it "can copy & paste & clear" do
      a = A.new
      a.send(:copy, "XXX").should == 'XXX'
      a.send(:paste).should == "XXX"
      a.send(:clear)
      a.send(:paste).should == ''
    end
  end

  describe 'Clipboard::File' do
    before :all do
      Clipboard.implementation = Clipboard::File
      cache = Clipboard::File::FILE
      FileUtils.rm cache if File.exist?(cache)
    end

    it "can paste with empty file" do
      Clipboard.paste.should == ''
    end

    it "can copy & paste" do
      Clipboard.copy('xxx').should == 'xxx'
      Clipboard.paste.should == 'xxx'
    end

    it "can clear" do
      Clipboard.copy('xxx').should == 'xxx'
      Clipboard.clear
      Clipboard.paste.should == ''
    end
  end

  describe :implementation do
    before do
      $VERBOSE = true
      Clipboard.implementation = nil
    end

    it "does not warn on normal detection" do
      if system('which xclip >/dev/null 2>&1') || system('which xsel >/dev/null 2>&1')
        $stderr.should_not_receive(:puts)
      end
      Clipboard.implementation
    end

    it "warns when OS is unknown" do
      RbConfig::CONFIG['host_os'] = 'Fooo OS'
      $stderr.should_receive(:puts)
      Clipboard.implementation.should == Clipboard::File
    end

    it "does not warn when $VERBOSE is false" do
      $VERBOSE = false
      RbConfig::CONFIG['host_os'] = 'Fooo OS'
      $stderr.should_not_receive(:puts)
      Clipboard.implementation
    end
  end
end
{'fraction_non_alphanumeric': 0.12411847672778561, 'fraction_numerical': 0.0009402914903620122, 'mean_word_length': 2.551752921535893, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6575643', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1382, 'n_words': 377}