lib/test-kitchen/scaffold.rb in test-kitchen-0.7.0.beta.1 vs lib/test-kitchen/scaffold.rb in test-kitchen-0.7.0.rc.1
- old
+ new
@@ -15,10 +15,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
require 'fileutils'
+require 'chef/cookbook/metadata'
module TestKitchen
class Scaffold
@@ -48,14 +49,28 @@
end
private
def project_name(output_dir)
- File.basename(output_dir)
+ if has_metadata?(output_dir)
+ get_cookbook_name(output_dir)
+ else
+ File.basename(output_dir)
+ end
end
+ def get_cookbook_name(output_dir)
+ md = Chef::Cookbook::Metadata.new
+ md.from_file(File.join(output_dir, 'metadata.rb'))
+ md.name
+ end
+
+ def has_metadata?(output_dir)
+ File.exists?(File.join(output_dir, 'metadata.rb'))
+ end
+
def project_type(output_dir)
- if File.exists?(File.join(output_dir, 'metadata.rb'))
+ if has_metadata?(output_dir)
'cookbook'
else
'integration_test'
end
end