Sha256: 56b97bdbaaab88c2a28bb16fd012fad6b8db9a45934908c772d27adcfdf85ba5

Contents?: true

Size: 1.02 KB

Versions: 16

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

class PSWindowsUserTest
  include PSWindows::User
end

describe PSWindowsUserTest do
  let(:wmic_output) do
    <<~EOS
      Name=Administrator





      Name=bob foo





      Name=bob-dash





      Name=bob.foo





      Name=cyg_server








    EOS
  end
  let(:command) { 'cmd /c echo "" | wmic useraccount where localaccount="true" get name /format:value' }
  let(:host) { double.as_null_object }
  let(:result) { Beaker::Result.new(host, command) }

  describe '#user_list' do
    it 'returns user names list correctly' do
      result.stdout = wmic_output
      expect(subject).to receive(:execute).with(command).and_yield(result)
      expect(subject.user_list).to be === ['Administrator', 'bob foo', 'bob-dash', 'bob.foo', 'cyg_server']
    end

    it 'yields correctly with the result object' do
      result.stdout = wmic_output
      expect(subject).to receive(:execute).and_yield(result)
      subject.user_list do |result|
        expect(result.stdout).to be === wmic_output
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
beaker-6.4.1 spec/beaker/host/pswindows/user_spec.rb
beaker-6.4.0 spec/beaker/host/pswindows/user_spec.rb
beaker-6.3.0 spec/beaker/host/pswindows/user_spec.rb
beaker-6.2.0 spec/beaker/host/pswindows/user_spec.rb
beaker-6.1.0 spec/beaker/host/pswindows/user_spec.rb
beaker-5.8.1 spec/beaker/host/pswindows/user_spec.rb
beaker-5.8.0 spec/beaker/host/pswindows/user_spec.rb
beaker-5.7.0 spec/beaker/host/pswindows/user_spec.rb
beaker-5.6.0 spec/beaker/host/pswindows/user_spec.rb
beaker-5.5.0 spec/beaker/host/pswindows/user_spec.rb
beaker-5.4.0 spec/beaker/host/pswindows/user_spec.rb
beaker-5.3.1 spec/beaker/host/pswindows/user_spec.rb
beaker-5.3.0 spec/beaker/host/pswindows/user_spec.rb
beaker-5.2.0 spec/beaker/host/pswindows/user_spec.rb
beaker-5.1.0 spec/beaker/host/pswindows/user_spec.rb
beaker-5.0.0 spec/beaker/host/pswindows/user_spec.rb