chef-gen-flavors 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 562095360336aa05b9852c336b8ed4039cfda565
4
- data.tar.gz: 08a2839dad35a4e412c74905f9e9b6a192dafb47
3
+ metadata.gz: f72906ef7e1128c8a165ff27e2552452e9dff66d
4
+ data.tar.gz: 52ff5b57d993cd32c412f05f74ad8f407b308d64
5
5
  SHA512:
6
- metadata.gz: 929b6174ccab2ec30537d317e6a9f9cb1279c738bb926521f1c5400f4428497fda54a773e0ee7e842afd32d0cddfb447aa70be36ef744e761bb4340fbb4b567f
7
- data.tar.gz: 28e725b716c9241b46eb68a01195183f42512adc10da09585e363d2169ed09aabd7b87476293910d2dd89eb115fb11a06cd5604161dc1bcf12af95085bf3cbf5
6
+ metadata.gz: 44a3d2d8706036b51de5769e26e8746e9a404949d6735563ddc7c23989aeac9dd13041f01fa09fc1a98fe5c1e73e73bed1a1282c381eeccd5227c3ffa4aa938c
7
+ data.tar.gz: 9350287247b69bcf12a3a80b7099c9cf965b2ca9cff1956958c80b08ce0cba13133d318a7cb8872a9ce22b80ba7f322c6bbff88d6d82c4b9f2b21a1560cd7ad4
@@ -21,3 +21,7 @@ Metrics/ClassLength:
21
21
  Lint/UnusedMethodArgument:
22
22
  Exclude:
23
23
  - 'lib/chef_gen/snippet/*.rb'
24
+
25
+ Metrics/LineLength:
26
+ Exclude:
27
+ - 'lib/chef_gen/flavors/cucumber/*.rb'
data/History.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog for chef-gen-template
2
2
 
3
+ ## 0.5.0
4
+
5
+ * provide some helpful Aruba step definitions for flavors to use in feature tests
6
+
7
+ ## 0.4.1
8
+
9
+ * declare the target path 'directory' before running snippets, which fixes the GitInit snippet trying to run in a directory that hasn't been created yet
10
+
3
11
  ## 0.4.0
4
12
 
5
13
  * added a GitInit snippet that runs 'git init .'
@@ -10,12 +10,17 @@ README.md
10
10
  Rakefile
11
11
  chef-gen-flavors.gemspec
12
12
  features/generate.feature
13
- features/step_definitions/chef.rb
14
- features/step_definitions/knife.rb
15
13
  features/support/env.rb
16
14
  lib/chef_gen/flavor.rb
17
15
  lib/chef_gen/flavor_base.rb
18
16
  lib/chef_gen/flavors.rb
17
+ lib/chef_gen/flavors/cucumber.rb
18
+ lib/chef_gen/flavors/cucumber/bundle.rb
19
+ lib/chef_gen/flavors/cucumber/chefdk.rb
20
+ lib/chef_gen/flavors/cucumber/kitchen.rb
21
+ lib/chef_gen/flavors/cucumber/knife.rb
22
+ lib/chef_gen/flavors/cucumber/rake.rb
23
+ lib/chef_gen/flavors/cucumber/regex.rb
19
24
  lib/chef_gen/snippet/attributes.rb
20
25
  lib/chef_gen/snippet/chef_spec.rb
21
26
  lib/chef_gen/snippet/cookbook_base.rb
data/README.md CHANGED
@@ -291,6 +291,19 @@ like this:
291
291
  end
292
292
  end
293
293
 
294
+ ## FEATURE TESTING FLAVORS
295
+
296
+ chef-gen-flavors provides a number of useful step definitions for Aruba (a CLI
297
+ driver for Cucumber) to make it easier to test flavors. To access these definitions,
298
+ add the following line to your `features/support/env.rb` file:
299
+
300
+ require 'chef_gen/flavors/cucumber'
301
+
302
+ For an example of how to use these steps in your features, refer to the reference
303
+ implementation of a flavor: [chef-gen-flavor-example](https://github.com/Nordstrom/chef-gen-flavor-example).
304
+
305
+ Documentation for the steps themselves is in the file `ARUBA_STEPS.md`
306
+
294
307
  ## AUTHOR
295
308
 
296
309
  James FitzGibbon - james.i.fitzgibbon@nordstrom.com - Nordstrom, Inc.
@@ -1,18 +1,18 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: chef-gen-flavors 0.4.0.20150515142632 ruby lib
2
+ # stub: chef-gen-flavors 0.5.0.20150518085211 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "chef-gen-flavors"
6
- s.version = "0.4.0.20150515142632"
6
+ s.version = "0.5.0.20150518085211"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
10
10
  s.authors = ["James FitzGibbon"]
11
- s.date = "2015-05-15"
11
+ s.date = "2015-05-18"
12
12
  s.description = "chef-gen-flavors is a framework for creating custom templates for the\n'chef generate' command provided by ChefDK.\n\nThis gem simply provides a framework; templates are provided by separate\ngems, which you can host privately for use within your organization or\npublicly for the Chef community to use.\n\nAt present this is focused primarily on providing templates for generation of\ncookbooks, as this is where most organization-specific customization takes place.\nSupport for the other artifacts that ChefDK can generate may work, but is not\nthe focus of early releases."
13
13
  s.email = ["james.i.fitzgibbon@nordstrom.com"]
14
14
  s.extra_rdoc_files = ["History.md", "Manifest.txt", "README.md"]
15
- s.files = [".rspec", ".rubocop.yml", ".travis.yml", "Gemfile", "Guardfile", "History.md", "LICENSE", "Manifest.txt", "README.md", "Rakefile", "chef-gen-flavors.gemspec", "features/generate.feature", "features/step_definitions/chef.rb", "features/step_definitions/knife.rb", "features/support/env.rb", "lib/chef_gen/flavor.rb", "lib/chef_gen/flavor_base.rb", "lib/chef_gen/flavors.rb", "lib/chef_gen/snippet/attributes.rb", "lib/chef_gen/snippet/chef_spec.rb", "lib/chef_gen/snippet/cookbook_base.rb", "lib/chef_gen/snippet/example_file.rb", "lib/chef_gen/snippet/example_template.rb", "lib/chef_gen/snippet/git_init.rb", "lib/chef_gen/snippet/recipes.rb", "lib/chef_gen/snippet/resource_provider.rb", "lib/chef_gen/snippet/standard_ignore.rb", "lib/chef_gen/snippet/style_rubocop.rb", "lib/chef_gen/snippet/test_kitchen.rb", "lib/chef_gen/snippets.rb", "spec/lib/chef_gen/flavor_base_spec.rb", "spec/lib/chef_gen/flavors_spec.rb", "spec/lib/chef_gen/snippet/attributes_spec.rb", "spec/lib/chef_gen/snippet/chef_spec_spec.rb", "spec/lib/chef_gen/snippet/cookbook_base_spec.rb", "spec/lib/chef_gen/snippet/example_file_spec.rb", "spec/lib/chef_gen/snippet/example_template_spec.rb", "spec/lib/chef_gen/snippet/git_init_spec.rb", "spec/lib/chef_gen/snippet/recipes_spec.rb", "spec/lib/chef_gen/snippet/resource_provider_spec.rb", "spec/lib/chef_gen/snippet/standard_ignore_spec.rb", "spec/lib/chef_gen/snippet/style_rubocop_spec.rb", "spec/lib/chef_gen/snippet/test_kitchen_spec.rb", "spec/spec_helper.rb", "spec/support/fixtures/code_generator/metadata.rb", "spec/support/fixtures/code_generator/recipes/cookbook.rb", "spec/support/fixtures/code_generator_2/metadata.rb", "spec/support/fixtures/code_generator_2/recipes/cookbook.rb", "spec/support/fixtures/code_generator_2/templates/default/README_md.erb", "spec/support/fixtures/lib/chef_gen/flavor/bar.rb", "spec/support/fixtures/lib/chef_gen/flavor/baz.rb", "spec/support/fixtures/lib/chef_gen/flavor/foo.rb"]
15
+ s.files = [".rspec", ".rubocop.yml", ".travis.yml", "Gemfile", "Guardfile", "History.md", "LICENSE", "Manifest.txt", "README.md", "Rakefile", "chef-gen-flavors.gemspec", "features/generate.feature", "features/support/env.rb", "lib/chef_gen/flavor.rb", "lib/chef_gen/flavor_base.rb", "lib/chef_gen/flavors.rb", "lib/chef_gen/flavors/cucumber.rb", "lib/chef_gen/flavors/cucumber/bundle.rb", "lib/chef_gen/flavors/cucumber/chefdk.rb", "lib/chef_gen/flavors/cucumber/kitchen.rb", "lib/chef_gen/flavors/cucumber/knife.rb", "lib/chef_gen/flavors/cucumber/rake.rb", "lib/chef_gen/flavors/cucumber/regex.rb", "lib/chef_gen/snippet/attributes.rb", "lib/chef_gen/snippet/chef_spec.rb", "lib/chef_gen/snippet/cookbook_base.rb", "lib/chef_gen/snippet/example_file.rb", "lib/chef_gen/snippet/example_template.rb", "lib/chef_gen/snippet/git_init.rb", "lib/chef_gen/snippet/recipes.rb", "lib/chef_gen/snippet/resource_provider.rb", "lib/chef_gen/snippet/standard_ignore.rb", "lib/chef_gen/snippet/style_rubocop.rb", "lib/chef_gen/snippet/test_kitchen.rb", "lib/chef_gen/snippets.rb", "spec/lib/chef_gen/flavor_base_spec.rb", "spec/lib/chef_gen/flavors_spec.rb", "spec/lib/chef_gen/snippet/attributes_spec.rb", "spec/lib/chef_gen/snippet/chef_spec_spec.rb", "spec/lib/chef_gen/snippet/cookbook_base_spec.rb", "spec/lib/chef_gen/snippet/example_file_spec.rb", "spec/lib/chef_gen/snippet/example_template_spec.rb", "spec/lib/chef_gen/snippet/git_init_spec.rb", "spec/lib/chef_gen/snippet/recipes_spec.rb", "spec/lib/chef_gen/snippet/resource_provider_spec.rb", "spec/lib/chef_gen/snippet/standard_ignore_spec.rb", "spec/lib/chef_gen/snippet/style_rubocop_spec.rb", "spec/lib/chef_gen/snippet/test_kitchen_spec.rb", "spec/spec_helper.rb", "spec/support/fixtures/code_generator/metadata.rb", "spec/support/fixtures/code_generator/recipes/cookbook.rb", "spec/support/fixtures/code_generator_2/metadata.rb", "spec/support/fixtures/code_generator_2/recipes/cookbook.rb", "spec/support/fixtures/code_generator_2/templates/default/README_md.erb", "spec/support/fixtures/lib/chef_gen/flavor/bar.rb", "spec/support/fixtures/lib/chef_gen/flavor/baz.rb", "spec/support/fixtures/lib/chef_gen/flavor/foo.rb"]
16
16
  s.homepage = "https://github.com/Nordstrom/chef-gen-flavors"
17
17
  s.licenses = ["apache2"]
18
18
  s.rdoc_options = ["--main", "README.md"]
@@ -10,7 +10,7 @@ Feature: chef generate
10
10
  |----------------|----------------------------------|
11
11
  | CHEFGEN_FLAVOR | bar |
12
12
  | RUBYLIB | ../../spec/support/fixtures/lib |
13
- When I generate a cookbook named 'foo'
13
+ When I generate a cookbook named "foo"
14
14
  Then the exit status should be 0
15
15
  And the output should match /using ChefGen flavor 'bar'/
16
16
  And the output should match /Recipe: code_generator_2::cookbook/
@@ -3,6 +3,7 @@ if ENV['COVERAGE']
3
3
  end
4
4
 
5
5
  require 'aruba/cucumber'
6
+ require 'chef_gen/flavors/cucumber'
6
7
 
7
8
  # Travis runs tests in a limited environment which takes a long time to invoke
8
9
  # the knife command. Up the timeout when we're in a travis build based on the
@@ -64,7 +64,7 @@ module ChefGen
64
64
  # set defaults
65
65
  @report_actions = true
66
66
  @fail_on_clobber = !ctx.respond_to?(:clobber)
67
- @directories = [''] # root directory
67
+ @directories = []
68
68
  %w(files files_if_missing templates templates_if_missing
69
69
  chefignore_files gitignore_files actions_taken failures)
70
70
  .each do |varname|
@@ -81,6 +81,7 @@ module ChefGen
81
81
  # generates the Chef resources that the plugin has declared
82
82
  # @return [void]
83
83
  def generate
84
+ add_target_path
84
85
  run_snippets
85
86
  add_directories
86
87
  add_files
@@ -108,6 +109,13 @@ module ChefGen
108
109
 
109
110
  private
110
111
 
112
+ # creates a directory resource for the target
113
+ # @return [void]
114
+ def add_target_path
115
+ @recipe.send(:directory, @target_path)
116
+ @actions_taken << "create directory #{@target_path}"
117
+ end
118
+
111
119
  # find all public methods of the plugin starting with snippet_
112
120
  # and calls them
113
121
  # @return [void]
@@ -7,7 +7,7 @@ module ChefGen
7
7
  # a plugin framework for creating ChefDK generator flavors
8
8
  class Flavors
9
9
  # the version of the gem
10
- VERSION = '0.4.0'
10
+ VERSION = '0.5.0'
11
11
 
12
12
  extend LittlePlugger path: 'chef_gen/flavor',
13
13
  module: ChefGen::Flavor
@@ -0,0 +1,6 @@
1
+ require 'chef_gen/flavors/cucumber/bundle'
2
+ require 'chef_gen/flavors/cucumber/chefdk'
3
+ require 'chef_gen/flavors/cucumber/kitchen'
4
+ require 'chef_gen/flavors/cucumber/knife'
5
+ require 'chef_gen/flavors/cucumber/rake'
6
+ require 'chef_gen/flavors/cucumber/regex'
@@ -0,0 +1,4 @@
1
+ Given(/^I bundle gems$/) do
2
+ unset_bundler_env_vars
3
+ run_simple 'bundle', true, 60
4
+ end
@@ -0,0 +1,3 @@
1
+ Given(/I generate a cookbook named "(.+)"(?: with the "(.+)" options?)?/) do |cbname, opts|
2
+ run_simple "chef generate cookbook #{cbname} #{opts}"
3
+ end
@@ -0,0 +1,4 @@
1
+ Given(/^I list the kitchen suites$/) do
2
+ unset_bundler_env_vars
3
+ run_simple 'bundle exec kitchen list'
4
+ end
@@ -1,5 +1,6 @@
1
1
  Given(/^a knife.rb that uses chef-gen-flavors$/) do
2
2
  write_file 'knife.rb', <<END
3
+ cookbook_path '#{File.expand_path(current_dir)}'
3
4
  require 'chef_gen/flavors'
4
5
  chefdk.generator_cookbook = ChefGen::Flavors.path
5
6
  END
@@ -0,0 +1,14 @@
1
+ Given(/^I run a style test$/) do
2
+ unset_bundler_env_vars
3
+ run_simple 'bundle exec rake style', true, 10
4
+ end
5
+
6
+ Given(/^I run a unit test$/) do
7
+ unset_bundler_env_vars
8
+ run_simple 'bundle exec rake spec', true, 10
9
+ end
10
+
11
+ Given(/^I list the rake tasks$/) do
12
+ unset_bundler_env_vars
13
+ run_simple 'bundle exec rake -T'
14
+ end
@@ -0,0 +1,3 @@
1
+ Given(/the output should match each of:/) do |regexes|
2
+ regexes.raw.map { |row| assert_matching_output(row[0], all_output) }
3
+ end
@@ -8,9 +8,10 @@ module ChefGen
8
8
  # @return [void]
9
9
  def snippet_gitinit(recipe)
10
10
  c = generator_context
11
+ target_path = @target_path
11
12
  recipe.send(:execute, 'initialize git repo') do
12
13
  command('git init .')
13
- cwd @target_path
14
+ cwd target_path
14
15
  end if c.have_git && !c.skip_git_init
15
16
  end
16
17
  end
@@ -130,7 +130,7 @@ RSpec.describe ChefGen::FlavorBase do
130
130
  end
131
131
 
132
132
  it 'calls mixin methods' do
133
- expect(@recipe).to receive(:directory).with(%r{foo/$})
133
+ expect(@recipe).to receive(:directory).with(/foo$/)
134
134
  expect(@recipe).to receive(:directory).with(%r{foo/bar$})
135
135
  template = ChefGen::Flavor::Amazing.new(@recipe)
136
136
  template.extend ChefGen::Snippet::Bar
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-gen-flavors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James FitzGibbon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-15 00:00:00.000000000 Z
11
+ date: 2015-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: little-plugger
@@ -267,12 +267,17 @@ files:
267
267
  - Rakefile
268
268
  - chef-gen-flavors.gemspec
269
269
  - features/generate.feature
270
- - features/step_definitions/chef.rb
271
- - features/step_definitions/knife.rb
272
270
  - features/support/env.rb
273
271
  - lib/chef_gen/flavor.rb
274
272
  - lib/chef_gen/flavor_base.rb
275
273
  - lib/chef_gen/flavors.rb
274
+ - lib/chef_gen/flavors/cucumber.rb
275
+ - lib/chef_gen/flavors/cucumber/bundle.rb
276
+ - lib/chef_gen/flavors/cucumber/chefdk.rb
277
+ - lib/chef_gen/flavors/cucumber/kitchen.rb
278
+ - lib/chef_gen/flavors/cucumber/knife.rb
279
+ - lib/chef_gen/flavors/cucumber/rake.rb
280
+ - lib/chef_gen/flavors/cucumber/regex.rb
276
281
  - lib/chef_gen/snippet/attributes.rb
277
282
  - lib/chef_gen/snippet/chef_spec.rb
278
283
  - lib/chef_gen/snippet/cookbook_base.rb
@@ -1,3 +0,0 @@
1
- Given(/I generate a cookbook named '(.+)'/) do |cbname|
2
- run_simple "chef generate cookbook #{cbname}"
3
- end