Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid using removed Utils class [fix #346] #347

Merged
merged 1 commit into from
Mar 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/aruba/platforms/command_monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def clear
# @param [String] cmd
# The command
def output_from(cmd)
cmd = Utils.detect_ruby(cmd)
cmd = Aruba.platform.detect_ruby(cmd)
find(cmd).output
end

Expand All @@ -112,7 +112,7 @@ def output_from(cmd)
# @param [String] cmd
# The command
def stdout_from(cmd)
cmd = Utils.detect_ruby(cmd)
cmd = Aruba.platform.detect_ruby(cmd)
find(cmd).stdout
end

Expand All @@ -122,7 +122,7 @@ def stdout_from(cmd)
# @param [String] cmd
# The command
def stderr_from(cmd)
cmd = Utils.detect_ruby(cmd)
cmd = Aruba.platform.detect_ruby(cmd)
find(cmd).stderr
end

Expand Down
41 changes: 41 additions & 0 deletions spec/aruba/api/deprecated_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require 'spec_helper'

if Aruba::VERSION <= '1.0.0'
RSpec.describe 'Deprecated API' do
include_context 'uses aruba API'

around do |example|
Aruba.platform.with_environment do
example.run
end
end

let(:monitor) { instance_double(Aruba::CommandMonitor) }

before do
allow(@aruba.aruba).to receive(:command_monitor).and_return(monitor)
allow(Aruba.platform).to receive(:deprecated)
end

describe "#output_from" do
it "works" do
allow(monitor).to receive(:stdout_from).with('foobar').and_return("foo")
expect(@aruba.stdout_from('foobar')).to eq('foo')
end
end

describe "#stdout_from" do
it "works" do
allow(monitor).to receive(:stdout_from).with('foobar').and_return("foo")
expect(@aruba.stdout_from('foobar')).to eq('foo')
end
end

describe "#stderr_from" do
it "works" do
allow(monitor).to receive(:stderr_from).with('foobar').and_return("foo")
expect(@aruba.stderr_from('foobar')).to eq('foo')
end
end
end
end
37 changes: 37 additions & 0 deletions spec/aruba/platforms/command_monitor_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
require 'spec_helper'

RSpec.describe Aruba::CommandMonitor do
subject do
described_class.new(announcer: announcer)
end

let(:announcer) { instance_double(Aruba::Platforms::Announcer) }

let(:process) { instance_double(Aruba::Processes::BasicProcess) }

before do
allow(process).to receive(:commandline).and_return('foobar')
subject.register_command(process)
end

describe "#output_from" do
it "works" do
allow(process).to receive(:output).and_return('foo')
expect(subject.output_from('foobar')).to eq('foo')
end
end

describe "#stdout_from" do
it "works" do
allow(process).to receive(:stdout).and_return('foo')
expect(subject.stdout_from('foobar')).to eq('foo')
end
end

describe "#stderr_from" do
it "works" do
allow(process).to receive(:stderr).and_return('foo')
expect(subject.stderr_from('foobar')).to eq('foo')
end
end
end