summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Hudson <jhudson@chef.io>2017-03-30 18:16:56 -0600
committerJosh Hudson <jhudson@chef.io>2017-03-30 18:24:47 -0600
commitf56e407d6cfc20fec74d36fd995496544d101f4e (patch)
tree363ceaec83c2c47bd253133536f03530244d8aa2
parent3e94e03785ac01a1953ab20a150ac05fdd3ab1cd (diff)
downloadchef-f56e407d6cfc20fec74d36fd995496544d101f4e.tar.gz
YUNO like cookstyle, Travis?
Signed-off-by: Josh Hudson <jhudson@chef.io>
-rw-r--r--spec/unit/data_collector/messages_spec.rb126
1 files changed, 63 insertions, 63 deletions
diff --git a/spec/unit/data_collector/messages_spec.rb b/spec/unit/data_collector/messages_spec.rb
index d1feafaef8..f5df85a988 100644
--- a/spec/unit/data_collector/messages_spec.rb
+++ b/spec/unit/data_collector/messages_spec.rb
@@ -17,15 +17,15 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ffi_yajl'
-require 'chef/data_collector/messages/helpers'
+require "spec_helper"
+require "ffi_yajl"
+require "chef/data_collector/messages/helpers"
describe Chef::DataCollector::Messages do
- describe '#run_start_message' do
+ describe "#run_start_message" do
let(:run_status) { Chef::RunStatus.new(Chef::Node.new, Chef::EventDispatch::Dispatcher.new) }
let(:required_fields) do
- %w(
+ %w{
chef_server_fqdn
entity_uuid
id
@@ -36,7 +36,7 @@ describe Chef::DataCollector::Messages do
run_id
source
start_time
- )
+ }
end
let(:optional_fields) { [] }
@@ -44,7 +44,7 @@ describe Chef::DataCollector::Messages do
allow(run_status).to receive(:start_time).and_return(Time.now)
end
- it 'is not missing any required fields' do
+ it "is not missing any required fields" do
missing_fields = required_fields.select do |key|
!Chef::DataCollector::Messages.run_start_message(run_status).key?(key)
end
@@ -52,7 +52,7 @@ describe Chef::DataCollector::Messages do
expect(missing_fields).to eq([])
end
- it 'does not have any extra fields' do
+ it "does not have any extra fields" do
extra_fields = Chef::DataCollector::Messages.run_start_message(run_status).keys.select do |key|
!required_fields.include?(key) && !optional_fields.include?(key)
end
@@ -61,11 +61,11 @@ describe Chef::DataCollector::Messages do
end
end
- describe '#run_end_message' do
+ describe "#run_end_message" do
let(:node) { Chef::Node.new }
let(:run_status) { Chef::RunStatus.new(node, Chef::EventDispatch::Dispatcher.new) }
- let(:report1) { double('report1', report_data: { 'status' => 'updated' }) }
- let(:report2) { double('report2', report_data: { 'status' => 'skipped' }) }
+ let(:report1) { double("report1", report_data: { "status" => "updated" }) }
+ let(:report2) { double("report2", report_data: { "status" => "skipped" }) }
let(:reporter_data) do
{
run_status: run_status,
@@ -78,23 +78,23 @@ describe Chef::DataCollector::Messages do
allow(run_status).to receive(:end_time).and_return(Time.now)
end
- it 'includes a valid node object in the payload' do
+ it "includes a valid node object in the payload" do
message = Chef::DataCollector::Messages.run_end_message(reporter_data)
- expect(message['node']).to be_an_instance_of(Chef::Node)
+ expect(message["node"]).to be_an_instance_of(Chef::Node)
end
- it 'returns a sane JSON representation of the node object' do
- node.chef_environment = 'my_test_environment'
- node.run_list.add('recipe[my_test_cookbook::default]')
+ it "returns a sane JSON representation of the node object" do
+ node.chef_environment = "my_test_environment"
+ node.run_list.add("recipe[my_test_cookbook::default]")
message = FFI_Yajl::Parser.parse(Chef::DataCollector::Messages.run_end_message(reporter_data).to_json)
- expect(message['node']['chef_environment']).to eq('my_test_environment')
- expect(message['node']['run_list']).to eq(['recipe[my_test_cookbook::default]'])
+ expect(message["node"]["chef_environment"]).to eq("my_test_environment")
+ expect(message["node"]["run_list"]).to eq(["recipe[my_test_cookbook::default]"])
end
- context 'when the run was successful' do
+ context "when the run was successful" do
let(:required_fields) do
- %w(
+ %w{
chef_server_fqdn
entity_uuid
id
@@ -114,38 +114,38 @@ describe Chef::DataCollector::Messages do
total_resource_count
updated_resource_count
deprecations
- )
+ }
end
- let(:optional_fields) { %w(error policy_group policy_name) }
+ let(:optional_fields) { %w{error policy_group policy_name} }
before do
allow(run_status).to receive(:exception).and_return(nil)
end
- it 'is not missing any required fields' do
+ it "is not missing any required fields" do
missing_fields = required_fields.select do |key|
!Chef::DataCollector::Messages.run_end_message(reporter_data).key?(key)
end
expect(missing_fields).to eq([])
end
- it 'does not have any extra fields' do
+ it "does not have any extra fields" do
extra_fields = Chef::DataCollector::Messages.run_end_message(reporter_data).keys.select do |key|
!required_fields.include?(key) && !optional_fields.include?(key)
end
expect(extra_fields).to eq([])
end
- it 'only includes updated resources in its count' do
+ it "only includes updated resources in its count" do
message = Chef::DataCollector::Messages.run_end_message(reporter_data)
- expect(message['total_resource_count']).to eq(2)
- expect(message['updated_resource_count']).to eq(1)
+ expect(message["total_resource_count"]).to eq(2)
+ expect(message["updated_resource_count"]).to eq(1)
end
end
- context 'when the run was not successful' do
+ context "when the run was not successful" do
let(:required_fields) do
- %w(
+ %w{
chef_server_fqdn
entity_uuid
id
@@ -166,22 +166,22 @@ describe Chef::DataCollector::Messages do
total_resource_count
updated_resource_count
deprecations
- )
+ }
end
- let(:optional_fields) { %w(policy_group policy_name) }
+ let(:optional_fields) { %w{policy_group policy_name} }
before do
- allow(run_status).to receive(:exception).and_return(RuntimeError.new('an error happened'))
+ allow(run_status).to receive(:exception).and_return(RuntimeError.new("an error happened"))
end
- it 'is not missing any required fields' do
+ it "is not missing any required fields" do
missing_fields = required_fields.select do |key|
!Chef::DataCollector::Messages.run_end_message(reporter_data).key?(key)
end
expect(missing_fields).to eq([])
end
- it 'does not have any extra fields' do
+ it "does not have any extra fields" do
extra_fields = Chef::DataCollector::Messages.run_end_message(reporter_data).keys.select do |key|
!required_fields.include?(key) && !optional_fields.include?(key)
end
@@ -190,11 +190,11 @@ describe Chef::DataCollector::Messages do
end
end
- describe '#run_end_message in policy mode' do
+ describe "#run_end_message in policy mode" do
let(:node) { Chef::Node.new }
let(:run_status) { Chef::RunStatus.new(node, Chef::EventDispatch::Dispatcher.new) }
- let(:report1) { double('report1', report_data: { 'status' => 'updated' }) }
- let(:report2) { double('report2', report_data: { 'status' => 'skipped' }) }
+ let(:report1) { double("report1", report_data: { "status" => "updated" }) }
+ let(:report2) { double("report2", report_data: { "status" => "skipped" }) }
let(:reporter_data) do
{
run_status: run_status,
@@ -205,29 +205,29 @@ describe Chef::DataCollector::Messages do
before do
allow(run_status).to receive(:start_time).and_return(Time.now)
allow(run_status).to receive(:end_time).and_return(Time.now)
- node.policy_group = 'test'
- node.policy_name = 'policy-test'
+ node.policy_group = "test"
+ node.policy_name = "policy-test"
end
- it 'includes a valid node object in the payload' do
+ it "includes a valid node object in the payload" do
message = Chef::DataCollector::Messages.run_end_message(reporter_data)
- expect(message['node']).to be_an_instance_of(Chef::Node)
+ expect(message["node"]).to be_an_instance_of(Chef::Node)
end
- it 'returns a sane JSON representation of the node object' do
- node.chef_environment = 'my_test_environment'
- node.run_list.add('recipe[my_test_cookbook::default]')
+ it "returns a sane JSON representation of the node object" do
+ node.chef_environment = "my_test_environment"
+ node.run_list.add("recipe[my_test_cookbook::default]")
message = FFI_Yajl::Parser.parse(Chef::DataCollector::Messages.run_end_message(reporter_data).to_json)
- expect(message['node']['chef_environment']).to eq('my_test_environment')
- expect(message['node']['run_list']).to eq(['recipe[my_test_cookbook::default]'])
- expect(message['node']['policy_name']).to eq('policy-test')
- expect(message['node']['policy_group']).to eq('test')
+ expect(message["node"]["chef_environment"]).to eq("my_test_environment")
+ expect(message["node"]["run_list"]).to eq(["recipe[my_test_cookbook::default]"])
+ expect(message["node"]["policy_name"]).to eq("policy-test")
+ expect(message["node"]["policy_group"]).to eq("test")
end
- context 'when the run was successful' do
+ context "when the run was successful" do
let(:required_fields) do
- %w(
+ %w{
chef_server_fqdn
entity_uuid
id
@@ -249,38 +249,38 @@ describe Chef::DataCollector::Messages do
deprecations
policy_name
policy_group
- )
+ }
end
- let(:optional_fields) { %w(error) }
+ let(:optional_fields) { %w{error} }
before do
allow(run_status).to receive(:exception).and_return(nil)
end
- it 'is not missing any required fields' do
+ it "is not missing any required fields" do
missing_fields = required_fields.select do |key|
!Chef::DataCollector::Messages.run_end_message(reporter_data).key?(key)
end
expect(missing_fields).to eq([])
end
- it 'does not have any extra fields' do
+ it "does not have any extra fields" do
extra_fields = Chef::DataCollector::Messages.run_end_message(reporter_data).keys.select do |key|
!required_fields.include?(key) && !optional_fields.include?(key)
end
expect(extra_fields).to eq([])
end
- it 'only includes updated resources in its count' do
+ it "only includes updated resources in its count" do
message = Chef::DataCollector::Messages.run_end_message(reporter_data)
- expect(message['total_resource_count']).to eq(2)
- expect(message['updated_resource_count']).to eq(1)
+ expect(message["total_resource_count"]).to eq(2)
+ expect(message["updated_resource_count"]).to eq(1)
end
end
- context 'when the run was not successful' do
+ context "when the run was not successful" do
let(:required_fields) do
- %w(
+ %w{
chef_server_fqdn
entity_uuid
id
@@ -303,22 +303,22 @@ describe Chef::DataCollector::Messages do
deprecations
policy_name
policy_group
- )
+ }
end
let(:optional_fields) { [] }
before do
- allow(run_status).to receive(:exception).and_return(RuntimeError.new('an error happened'))
+ allow(run_status).to receive(:exception).and_return(RuntimeError.new("an error happened"))
end
- it 'is not missing any required fields' do
+ it "is not missing any required fields" do
missing_fields = required_fields.select do |key|
!Chef::DataCollector::Messages.run_end_message(reporter_data).key?(key)
end
expect(missing_fields).to eq([])
end
- it 'does not have any extra fields' do
+ it "does not have any extra fields" do
extra_fields = Chef::DataCollector::Messages.run_end_message(reporter_data).keys.select do |key|
!required_fields.include?(key) && !optional_fields.include?(key)
end