Skip to content

Commit

Permalink
No need for stubbing or mocking when we can just test the results.
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Davis <zenspider@chef.io>
  • Loading branch information
zenspider committed Jul 20, 2019
1 parent b92a82a commit ce75b6e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/unit/transports/cisco_ios_connection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
let(:cls) do
plat = Train::Platforms.name("mock").in_family("cisco_ios")
plat.add_platform_methods
plat.stubs(:cisco_ios?).returns(true)
def plat.cisco_ios?
true
end

Train::Platforms::Detect.stubs(:scan).returns(plat)
Train::Transports::SSH
end
Expand Down Expand Up @@ -42,10 +45,9 @@
end

describe "#format_result" do
it "returns correctly when result is `good`" do
output = "good"
Train::Extras::CommandResult.expects(:new).with(output, "", 0)
connection.send(:format_result, "good")
it "returns correctly when result is 'good'" do
exp = Train::Extras::CommandResult.new("good", "", 0)
assert_equal exp, connection.send(:format_result, "good")
end

it "returns correctly when result matches /Bad IP address/" do
Expand Down

0 comments on commit ce75b6e

Please sign in to comment.