Skip to content
This repository has been archived by the owner on Sep 19, 2020. It is now read-only.

Commit

Permalink
FC003: Recognise new chef-solo-search, refs #17.
Browse files Browse the repository at this point in the history
The chef-solo-search library changed the location of search in commit f6f6e49.
  • Loading branch information
Andrew Crump committed Mar 3, 2012
1 parent 3417d3f commit a06bf31
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
8 changes: 7 additions & 1 deletion features/003_check_for_chef_server.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Feature: Check for Chef Server
When I check the cookbook
Then the check for server warning 003 should be displayed

Scenario: Search with older chef-solo-search
Given a cookbook with a single recipe that searches without checking if this is server
And another cookbook that has an older chef-solo-search installed
When I check the cookbook
Then the check for server warning 003 should not be displayed

Scenario: Search with chef-solo-search
Given a cookbook with a single recipe that searches without checking if this is server
And another cookbook that has chef-solo-search installed
Expand All @@ -18,4 +24,4 @@ Feature: Check for Chef Server
Scenario: Search checking for server
Given a cookbook with a single recipe that searches but checks first to see if this is server
When I check the cookbook
Then the check for server warning 003 should not be displayed given we have checked
Then the check for server warning 003 should not be displayed given we have checked
30 changes: 22 additions & 8 deletions features/step_definitions/cookbook_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -534,16 +534,30 @@
}
end

Given 'another cookbook that has chef-solo-search installed' do
write_library 'search', %q{
class Chef
class Recipe
def search(bag_name, query=nil, sort=nil, start=0, rows=1000, &block)
# https://github.com/edelight/chef-solo-search
Given /^another cookbook that has (an older )?chef-solo-search installed$/ do |older|
if older.nil?
write_library 'search', %q{
class Chef
module Mixin
module Language
def search(bag_name, query=nil, sort=nil, start=0, rows=1000, &block)
# https://github.com/edelight/chef-solo-search
end
end
end
end
end
}
}
else
write_library 'search', %q{
class Chef
class Recipe
def search(bag_name, query=nil, sort=nil, start=0, rows=1000, &block)
# https://github.com/edelight/chef-solo-search
end
end
end
}
end
end

Given 'I have installed the lint tool' do
Expand Down
4 changes: 2 additions & 2 deletions lib/foodcritic/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def chef_solo_search_supported?(recipe_path)
cbk_tree_path = Pathname.new(File.join(recipe_path, '../../..'))
search_libs = Dir[File.join(cbk_tree_path.realpath, "*/libraries/search.rb")]
search_libs.any? do |lib|
! read_file(lib).xpath(%q{//class[count(descendant::const[@value='Chef'
or @value='Recipe']) = 2]/descendant::def/ident[@value='search']}).empty?
! read_file(lib).xpath(%q{//class[count(descendant::const[@value='Chef']
) = 1]/descendant::def/ident[@value='search']}).empty?
end
end

Expand Down

0 comments on commit a06bf31

Please sign in to comment.