<commit_before>describe "Test remote WQL features via WinRM", :integration => true do
  before(:all) do
    @winrm = winrm_connection
  end

  it 'should run a CMD command string' do
    output = @winrm.run_cmd('ipconfig /all')
    expect(output[:exitcode]).to eq(0)
    expect(output[:data]).to_not be_empty
  end

  it 'should run a CMD command with proper arguments' do
    output = @winrm.run_cmd('ipconfig', %w{/all})
    expect(output[:exitcode]).to eq(0)
    expect(output[:data]).to_not be_empty
  end

  it 'should run a CMD command with block' do
    outvar = ''
    @winrm.run_cmd('ipconfig', %w{/all}) do |stdout, stderr|
      outvar << stdout
    end
    expect(outvar).to match(/Windows IP Configuration/)
  end

  it 'should run a CMD command that contains an apostrophe' do
    output = @winrm.run_cmd(%q{echo 'hello world'})
    expect(output[:exitcode]).to eq(0)
    expect(output[:data][0][:stdout]).to match(/'hello world'/)
  end

  it 'should run a CMD command that is empty' do
    output = @winrm.run_cmd('')
    expect(output[:exitcode]).to eq(0)
  end

  it 'should run a CMD command that has bad arg and return non-zero exit code' do
    output = @winrm.run_cmd('dir /z')
    expect(output[:exitcode]).to eq(1)
  end

end<commit_msg>Cmd spec uses new output matchers<commit_after>describe 'winrm client cmd', :integration => true do
  before(:all) do
    @winrm = winrm_connection
  end

  describe 'empty string' do
    subject(:output) { @winrm.cmd('') }
    it { should have_exit_code 0 }
    it { should have_no_stdout }
    it { should have_no_stderr }
  end

  describe 'ipconfig' do
    subject(:output) { @winrm.cmd('ipconfig') }
    it { should have_exit_code 0 }
    it { should have_stdout_match /Windows IP Configuration/ }
    it { should have_no_stderr }
  end

  describe 'echo \'hello world\' using apostrophes' do
    subject(:output) { @winrm.cmd("echo 'hello world'") }
    it { should have_exit_code 0 }
    it { should have_stdout_match /'hello world'/ }
    it { should have_no_stderr }
  end

  describe 'ipconfig with /all argument' do
    subject(:output) { @winrm.cmd('ipconfig', %w{/all}) }
    it { should have_exit_code 0 }
    it { should have_stdout_match /Windows IP Configuration/ }
    it { should have_no_stderr }
  end

  describe 'dir with incorrect argument /z' do
    subject(:output) { @winrm.cmd('dir /z') }
    it { should have_exit_code 1 }
    it { should have_no_stdout }
    it { should have_stderr_match /Invalid switch/ }
  end

  describe 'ipconfig && echo error 1>&2' do
    subject(:output) { @winrm.cmd('ipconfig && echo error 1>&2') }
    it { should have_exit_code 0 }
    it { should have_stdout_match /Windows IP Configuration/ }
    it { should have_stderr_match /error/ }
  end

  describe 'ipconfig with a block' do
    subject(:stdout) do
      outvar = ''
      @winrm.cmd('ipconfig') do |stdout, stderr|
        outvar << stdout
      end
      outvar
    end
    it { should match(/Windows IP Configuration/) }
  end
end
{'fraction_non_alphanumeric': 0.1182331451345068, 'fraction_numerical': 0.005313849219528396, 'mean_word_length': 3.1949860724233985, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3575763', 'n_tokens_mistral': 1009, 'n_tokens_neox': 974, 'n_words': 304}