Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Commit

Permalink
Extract UI object tests to shared example group
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsdeleo committed Dec 9, 2014
1 parent d3d6da5 commit 6a4dd5d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
11 changes: 11 additions & 0 deletions spec/shared/command_with_ui_object.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
shared_examples_for "a command with a UI object" do

subject(:command) { described_class.new }

it "configures a default UI component" do
ui = command.ui
expect(ui.out_stream).to eq($stdout)
expect(ui.err_stream).to eq($stderr)
end

end
9 changes: 3 additions & 6 deletions spec/unit/command/export_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
#

require 'spec_helper'
require 'shared/command_with_ui_object'
require 'chef-dk/command/export'

describe ChefDK::Command::Export do

it_behaves_like "a command with a UI object"

let(:params) { [] }

let(:command) do
Expand Down Expand Up @@ -47,12 +50,6 @@
expect(command.debug?).to be(false)
end

it "configures a default UI component" do
ui = command.ui
expect(ui.out_stream).to eq($stdout)
expect(ui.err_stream).to eq($stderr)
end

context "when debug mode is set" do

let(:params) { [ "path/to/export", "-D" ] }
Expand Down
9 changes: 3 additions & 6 deletions spec/unit/command/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
#

require 'spec_helper'
require 'shared/command_with_ui_object'
require 'chef-dk/command/install'

describe ChefDK::Command::Install do

it_behaves_like "a command with a UI object"

let(:params) { [] }

let(:command) do
Expand All @@ -34,12 +37,6 @@
expect(command.debug?).to be(false)
end

it "configures a default UI component" do
ui = command.ui
expect(ui.out_stream).to eq($stdout)
expect(ui.err_stream).to eq($stderr)
end

context "when debug mode is set" do

let(:params) { [ "-D" ] }
Expand Down
9 changes: 3 additions & 6 deletions spec/unit/command/push_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
#

require 'spec_helper'
require 'shared/command_with_ui_object'
require 'chef-dk/command/push'

describe ChefDK::Command::Push do

it_behaves_like "a command with a UI object"

let(:policy_group) { "dev" }

let(:params) { [policy_group] }
Expand Down Expand Up @@ -51,12 +54,6 @@
expect(command.debug?).to be(false)
end

it "configures a default UI component" do
ui = command.ui
expect(ui.out_stream).to eq($stdout)
expect(ui.err_stream).to eq($stderr)
end

describe "when configuring components that depend on chef config" do

before do
Expand Down
9 changes: 3 additions & 6 deletions spec/unit/command/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
#

require 'spec_helper'
require 'shared/command_with_ui_object'
require 'chef-dk/command/update'

describe ChefDK::Command::Update do

it_behaves_like "a command with a UI object"

let(:params) { [] }

let(:command) do
Expand All @@ -34,12 +37,6 @@
expect(command.debug?).to be(false)
end

it "configures a default UI component" do
ui = command.ui
expect(ui.out_stream).to eq($stdout)
expect(ui.err_stream).to eq($stderr)
end

context "when debug mode is set" do

let(:params) { [ "-D" ] }
Expand Down

0 comments on commit 6a4dd5d

Please sign in to comment.