summaryrefslogtreecommitdiff
path: root/spec/unit/knife
diff options
context:
space:
mode:
authorSteven Danna <steve@opscode.com>2014-11-14 13:52:39 +0000
committerLamont Granquist <lamont@scriptkiddie.org>2015-01-25 13:27:02 -0800
commitb4fb60423d51e87303808a55f7a90bf8b86b9b94 (patch)
tree5da53a80d3d1e5036db353890e2fc800d429a84f /spec/unit/knife
parent508f14aec1f6e4b02233f4deefa3b93f019c59a4 (diff)
downloadchef-b4fb60423d51e87303808a55f7a90bf8b86b9b94.tar.gz
Use `let` rather than `before` in rspec tests
Diffstat (limited to 'spec/unit/knife')
-rw-r--r--spec/unit/knife/raw_spec.rb23
1 files changed, 14 insertions, 9 deletions
diff --git a/spec/unit/knife/raw_spec.rb b/spec/unit/knife/raw_spec.rb
index 547ddee992..ab929abd39 100644
--- a/spec/unit/knife/raw_spec.rb
+++ b/spec/unit/knife/raw_spec.rb
@@ -18,21 +18,26 @@
require 'spec_helper'
describe Chef::Knife::Raw do
- before(:each) do
- @rest = double('Chef::Knife::Raw::RawInputServerAPI')
- allow(Chef::Knife::Raw::RawInputServerAPI).to receive(:new).and_return(@rest)
- @knife = Chef::Knife::Raw.new
- @knife.config[:method] = "GET"
- @knife.name_args = [ "/nodes" ]
+ let(:rest) do
+ r = double('Chef::Knife::Raw::RawInputServerAPI')
+ allow(Chef::Knife::Raw::RawInputServerAPI).to receive(:new).and_return(r)
+ r
+ end
+
+ let(:knife) do
+ k = Chef::Knife::Raw.new
+ k.config[:method] = "GET"
+ k.name_args = [ "/nodes" ]
+ k
end
describe "run" do
it "should set the x-ops-request-source header when --proxy-auth is set" do
- @knife.config[:proxy_auth] = true
- expect(@rest).to receive(:request).with(:GET, "/nodes",
+ knife.config[:proxy_auth] = true
+ expect(rest).to receive(:request).with(:GET, "/nodes",
{ 'Content-Type' => 'application/json',
'x-ops-request-source' => 'web'}, false)
- @knife.run
+ knife.run
end
end
end