Permalink
Browse files

Remove remaining references to FC001, refs #86.

  • Loading branch information...
1 parent 8dedb46 commit 418df2a65fbf9dae8d7db9618c9651470728e4b6 @acrmp committed Oct 30, 2012
View
60 features/001_check_node_access.feature
@@ -1,60 +0,0 @@
-Feature: Check Node Access
-
- In order to be consistent in the way I access node attributes and to avoid confusing people new to Ruby
- As a developer
- I want to identify if the cookbooks access node attributes with symbols rather than strings
-
- Scenario: Cookbook recipe accesses attributes via symbols
- Given a cookbook with a single recipe that reads node attributes via symbols
- When I check the cookbook
- Then the node access warning 001 should be displayed
-
- Scenario: Cookbook recipe accesses multiple attributes via symbols
- Given a cookbook with a single recipe that accesses multiple node attributes via symbols
- When I check the cookbook
- Then the node access warning 001 should be displayed for each match
-
- Scenario: Assignment of node attributes accessed via symbols
- Given a cookbook with a single recipe that assigns node attributes accessed via symbols to a local variable
- When I check the cookbook
- Then the node access warning 001 should be displayed
-
- Scenario: Cookbook recipe accesses nested attributes via symbols
- Given a cookbook with a single recipe that accesses nested node attributes via symbols
- When I check the cookbook
- Then the node access warning 001 should be displayed twice for the same line
-
- Scenario: Cookbook recipe accesses attributes via strings
- Given a cookbook with a single recipe that reads node attributes via strings
- When I check the cookbook
- Then the node access warning 001 should not be displayed
-
- Scenario: Cookbook recipe access attributes via strings and searches
- Given a cookbook with a single recipe that searches based on a node attribute accessed via strings
- When I check the cookbook
- Then the node access warning 001 should not be displayed
-
- Scenario: Cookbook recipe access attributes via symbols for template
- Given a cookbook with a single recipe that passes node attributes accessed via symbols to a template
- When I check the cookbook
- Then the node access warning 001 should be displayed against the variables
-
- Scenario: Cookbook recipe sets default attributes via symbols
- Given a cookbook that declares default attributes via symbols
- When I check the cookbook
- Then the node access warning 001 should be displayed against the attributes file
-
- Scenario: Cookbook recipe overrides attributes via symbols
- Given a cookbook that declares override attributes via symbols
- When I check the cookbook
- Then the node access warning 001 should be displayed against the attributes file
-
- Scenario: Cookbook recipe sets attributes via symbols
- Given a cookbook that declares set attributes via symbols
- When I check the cookbook
- Then the node access warning 001 should be displayed against the attributes file
-
- Scenario: Cookbook recipe sets normal attributes via symbols
- Given a cookbook that declares normal attributes via symbols
- When I check the cookbook
- Then the node access warning 001 should be displayed against the attributes file
View
6 features/individual_file.feature
@@ -5,8 +5,8 @@ Feature: Individual file
I want to lint individual files in a cookbook
Scenario: Linting an individual file shows warnings only from that file
- Given a cookbook with a single recipe that reads node attributes via symbols
+ Given a cookbook with a single recipe that reads node attributes via symbols,strings
And a cookbook that declares normal attributes via symbols
When I check the recipe
- Then the node access warning 001 should be displayed for the recipe
- And the node access warning 001 should not be displayed for the attributes
+ Then the attribute consistency warning 019 should be displayed for the recipe
+ And the attribute consistency warning 019 should not be displayed for the attributes
View
6 features/multiple_paths.feature
@@ -5,7 +5,7 @@ Feature: Multiple paths
I want to lint multiple paths at once
Scenario: Linting multiple individual cookbooks
- Given a cookbook with a single recipe that reads node attributes via symbols only
- And another cookbook with a single recipe that reads node attributes via strings only
+ Given a cookbook with a single recipe that reads node attributes via symbols,strings
+ And another cookbook with a single recipe that reads node attributes via strings
When I check both cookbooks
- Then the node access warning 001 should be displayed
+ Then the attribute consistency warning 019 should be shown
View
8 features/show_lines_matched.feature
@@ -6,15 +6,15 @@ Feature: Show Lines Matched
I want to be able to see the lines the warning matches against, with context
Scenario: Recipe with a single warning
- Given a cookbook with a single recipe that reads node attributes via symbols
+ Given a cookbook with a single recipe that reads node attributes via symbols,strings
When I check the cookbook, specifying that context should be shown
Then the recipe filename should be displayed
- And the node access warning 001 should be displayed below
+ And the attribute consistency warning 019 should be displayed below
And the line number and line of code that triggered the warning should be displayed
Scenario: Recipe with a multiple warnings of the same type
- Given a cookbook with a single recipe that accesses multiple node attributes via symbols
+ Given a cookbook with a single recipe that reads multiple node attributes via symbols,strings
When I check the cookbook, specifying that context should be shown
Then the recipe filename should be displayed
- And the node access warning 001 should be displayed below
+ And the attribute consistency warning 019 should be displayed below
And the line number and line of code that triggered the warnings should be displayed
View
2 features/sort_warnings.feature
@@ -7,4 +7,4 @@ Feature: Sort warnings
Scenario: Recipe has warnings on lines that don't sort non-numerically
Given a cookbook with a single recipe which accesses node attributes with symbols on lines 2 and 10
When I check the cookbook
- Then the node access warning 001 should warn on lines 2 and 10 in that order
+ Then the attribute consistency warning 019 should warn on lines 2 and 10 in that order
View
38 features/step_definitions/cookbook_steps.rb
@@ -880,10 +880,13 @@
end
end
-Given 'a cookbook with a single recipe that accesses multiple node attributes via symbols' do
+Given 'a cookbook with a single recipe that reads multiple node attributes via symbols,strings' do
write_recipe %q{
node[:foo] = 'bar'
- node[:testing] = 'bar'
+ node[:baz] = 'foo'
+ node[:wham] = 'shazam'
+ node['testing'] = 'bar'
+ node['testing2'] = 'bar2'
}
end
@@ -978,12 +981,12 @@ def in_tier?(*tier)
# Here we access the node attributes via a symbol
foo = node[:foo]
- directory "/tmp/foo" do
- owner "root"
- group "root"
- action :create
- end
+ # String access is in the majority
+ node['foo']
+ node['bar']
+ node['baz']
+ # Second access via a symbol
bar = node[:bar]
}
end
@@ -1372,6 +1375,21 @@ def search(bag_name, query=nil, sort=nil, start=0, rows=1000, &block)
assert_no_test_warnings
end
+Then 'the attribute consistency warning 019 should warn on lines 2 and 10 in that order' do
+ expected_warnings = [2, 10].map do |line|
+ "FC019: Access node attributes in a consistent manner: cookbooks/example/recipes/default.rb:#{line}"
+ end
+ expect_output(expected_warnings.join("\n"))
+end
+
+Then 'the attribute consistency warning 019 should be displayed for the recipe' do
+ expect_warning('FC019', :line => 2)
+end
+
+Then 'the attribute consistency warning 019 should not be displayed for the attributes' do
+ expect_warning('FC019', :file_type => :attributes, :line => 1, :expect_warning => false)
+end
+
Then /^the warning should (not )?be displayed$/ do |should_not|
expect_warning 'FCTEST001', {:expect_warning => should_not.nil?}
end
@@ -1455,10 +1473,10 @@ def search(bag_name, query=nil, sort=nil, start=0, rows=1000, &block)
Then /^the line number and line of code that triggered the warning(s)? should be displayed$/ do |multiple|
if multiple.nil?
- expect_line_shown 1, "log node[:foo]"
+ expect_line_shown 2, "log node['foo']"
else
- expect_line_shown 1, "node[:foo] = 'bar'"
- expect_line_shown 2, " node[:testing] = 'bar'"
+ expect_line_shown 4, " node['testing'] = 'bar'"
+ expect_line_shown 5, " node['testing2'] = 'bar2'"
end
end

0 comments on commit 418df2a

Please sign in to comment.