chefspec 3.4.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -19
  3. data/CHANGELOG.md +32 -1
  4. data/CONTRIBUTING.md +1 -1
  5. data/README.md +37 -9
  6. data/chefspec.gemspec +2 -3
  7. data/examples/render_file/spec/default_spec.rb +32 -17
  8. data/examples/server/recipes/render_with_cached.rb +3 -0
  9. data/examples/server/spec/client_spec.rb +1 -1
  10. data/examples/server/spec/data_bag_spec.rb +1 -1
  11. data/examples/server/spec/environment_spec.rb +1 -1
  12. data/examples/server/spec/node_spec.rb +1 -1
  13. data/examples/server/spec/render_with_cached_spec.rb +16 -0
  14. data/examples/server/spec/role_spec.rb +1 -1
  15. data/features/server.feature +10 -12
  16. data/features/support/executor.rb +2 -0
  17. data/gemfiles/{chef-11.0.0.gemfile → chef-11.12.0.gemfile} +1 -1
  18. data/gemfiles/chef-master.gemfile +1 -1
  19. data/lib/chefspec.rb +1 -0
  20. data/lib/chefspec/api/erl_call.rb +5 -5
  21. data/lib/chefspec/api/execute.rb +5 -5
  22. data/lib/chefspec/api/powershell_script.rb +5 -5
  23. data/lib/chefspec/api/ruby_block.rb +2 -2
  24. data/lib/chefspec/api/script.rb +13 -2
  25. data/lib/chefspec/cacher.rb +2 -1
  26. data/lib/chefspec/coverage.rb +10 -2
  27. data/lib/chefspec/expect_exception.rb +0 -2
  28. data/lib/chefspec/extensions/chef/lwrp_base.rb +5 -1
  29. data/lib/chefspec/extensions/chef/resource/freebsd_package.rb +19 -0
  30. data/lib/chefspec/librarian.rb +5 -2
  31. data/lib/chefspec/macros.rb +3 -3
  32. data/lib/chefspec/matchers/do_nothing_matcher.rb +4 -2
  33. data/lib/chefspec/matchers/include_recipe_matcher.rb +2 -2
  34. data/lib/chefspec/matchers/link_to_matcher.rb +11 -5
  35. data/lib/chefspec/matchers/notifications_matcher.rb +2 -2
  36. data/lib/chefspec/matchers/render_file_matcher.rb +9 -3
  37. data/lib/chefspec/matchers/resource_matcher.rb +2 -2
  38. data/lib/chefspec/matchers/state_attrs_matcher.rb +2 -2
  39. data/lib/chefspec/matchers/subscribes_matcher.rb +4 -4
  40. data/lib/chefspec/renderer.rb +1 -1
  41. data/lib/chefspec/rspec.rb +1 -0
  42. data/lib/chefspec/runner.rb +2 -1
  43. data/lib/chefspec/server.rb +90 -19
  44. data/lib/chefspec/version.rb +1 -1
  45. data/spec/unit/cacher_spec.rb +1 -1
  46. data/spec/unit/expect_exception_spec.rb +6 -6
  47. data/spec/unit/extensions/lwrp_base_spec.rb +9 -1
  48. data/spec/unit/macros_spec.rb +6 -6
  49. data/spec/unit/matchers/include_recipe_matcher_spec.rb +6 -6
  50. data/spec/unit/matchers/link_to_matcher_spec.rb +31 -15
  51. data/spec/unit/matchers/notifications_matcher_spec.rb +4 -4
  52. data/spec/unit/matchers/render_file_matcher_spec.rb +19 -10
  53. data/spec/unit/matchers/state_attrs_matcher_spec.rb +28 -24
  54. data/spec/unit/matchers/subscribes_matcher_spec.rb +7 -7
  55. data/spec/unit/renderer_spec.rb +7 -7
  56. data/spec/unit/runner_spec.rb +39 -9
  57. metadata +10 -25
  58. data/gemfiles/chef-11.2.0.gemfile +0 -5
  59. data/gemfiles/chef-11.4.4.gemfile +0 -5
  60. data/gemfiles/chef-11.6.0.gemfile +0 -5
  61. data/gemfiles/chef-11.8.0.gemfile +0 -5
@@ -2,11 +2,29 @@ require 'spec_helper'
2
2
 
3
3
  describe ChefSpec::Runner do
4
4
  before do
5
- ChefSpec::Runner.any_instance.stub(:dry_run?).and_return(true)
5
+ allow_any_instance_of(ChefSpec::Runner).to receive(:dry_run?).and_return(true)
6
6
  end
7
7
 
8
8
  describe '#initialize' do
9
9
  subject {} # need to explicitly control the creation
10
+ let(:windows_caller_stack) {
11
+ ["C:/cookbooks/Temp/spec/test_spec.rb:11:in `block (2 levels) in <top (required)>'",
12
+ "C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:114:in `instance_eval'",
13
+ "C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:114:in `block in run'",
14
+ "C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:254:in `with_around_each_hooks'",
15
+ "C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:111:in `run'",
16
+ "C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:390:in `block in run_examples'",
17
+ "C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:386:in `map'",
18
+ "C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:386:in `run_examples'",
19
+ "C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:371:in `run'",
20
+ "C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'",
21
+ "C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:28:in `map'",
22
+ "C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:28:in `block in run'",
23
+ "C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.14.8/lib/rspec/core/reporter.rb:58:in `report'",
24
+ "C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:25:in `run'",
25
+ "C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:80:in `run'",
26
+ "C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:17:in `block in autorun'"]
27
+ }
10
28
 
11
29
  it 'defaults the log level to :warn' do
12
30
  described_class.new
@@ -23,6 +41,17 @@ describe ChefSpec::Runner do
23
41
  expect(Chef::Config.cookbook_path).to eq([File.expand_path('../../../..', __FILE__)])
24
42
  end
25
43
 
44
+ it 'defaults the cookbook_path to the calling spec when using windows paths' do
45
+ runner = described_class.new
46
+ windows_path = runner.instance_exec(windows_caller_stack) { |callstack|
47
+ calling_cookbook_path(callstack)
48
+ }
49
+ # There's got to be a better way to do this the File.expand_path returns
50
+ # something like /home/user/repos/chefspec/C:/cookbooks" which is less
51
+ # than ideal as a robust test
52
+ expect(windows_path).to end_with("C:/cookbooks")
53
+ end
54
+
26
55
  it 'sets the cookbook path' do
27
56
  described_class.new(cookbook_path: '/tmp/bacon')
28
57
  expect(Chef::Config.cookbook_path).to eq(['/tmp/bacon'])
@@ -30,8 +59,9 @@ describe ChefSpec::Runner do
30
59
 
31
60
  it 'sets the Chef::Config' do
32
61
  expect(Chef::Config.cache_type).to eq('Memory')
33
- expect(Chef::Config.force_logger).to be_true
34
- expect(Chef::Config.solo).to be_true
62
+ expect(Chef::Config.force_logger).to be_truthy
63
+ expect(Chef::Config.no_lazy_load).to be_truthy
64
+ expect(Chef::Config.solo).to be_truthy
35
65
  end
36
66
 
37
67
  it 'yields a block to set node attributes' do
@@ -43,7 +73,7 @@ describe ChefSpec::Runner do
43
73
 
44
74
  it 'sets the default attributes' do
45
75
  expect(hash['os']).to eq('chefspec')
46
- expect(hash['languages']['ruby']).to eq('/usr/somewhere')
76
+ expect(hash['languages']['ruby']['bin_dir']).to eq('/usr/local/bin')
47
77
  expect(hash['os_version']).to eq('0.6.1')
48
78
  expect(hash['fqdn']).to eq('chefspec.local')
49
79
  expect(hash['domain']).to eq('local')
@@ -70,11 +100,11 @@ describe ChefSpec::Runner do
70
100
 
71
101
  context 'RSpec global configuration' do
72
102
  before do
73
- RSpec.configuration.stub(:cookbook_path).and_return('./path')
74
- RSpec.configuration.stub(:log_level).and_return(:fatal)
75
- RSpec.configuration.stub(:path).and_return('ohai.json')
76
- RSpec.configuration.stub(:platform).and_return('ubuntu')
77
- RSpec.configuration.stub(:version).and_return('12.04')
103
+ allow(RSpec.configuration).to receive(:cookbook_path).and_return('./path')
104
+ allow(RSpec.configuration).to receive(:log_level).and_return(:fatal)
105
+ allow(RSpec.configuration).to receive(:path).and_return('ohai.json')
106
+ allow(RSpec.configuration).to receive(:platform).and_return('ubuntu')
107
+ allow(RSpec.configuration).to receive(:version).and_return('12.04')
78
108
  end
79
109
 
80
110
  it 'uses the RSpec values' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chefspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Crump
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-16 00:00:00.000000000 Z
12
+ date: 2014-06-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '11.0'
20
+ version: '11.12'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '11.0'
27
+ version: '11.12'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: fauxhai
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -45,28 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '2.14'
48
+ version: '3.0'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '2.14'
56
- - !ruby/object:Gem::Dependency
57
- name: chef-zero
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '1.7'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '1.7'
55
+ version: '3.0'
70
56
  - !ruby/object:Gem::Dependency
71
57
  name: rake
72
58
  requirement: !ruby/object:Gem::Requirement
@@ -446,12 +432,14 @@ files:
446
432
  - examples/server/recipes/data_bag.rb
447
433
  - examples/server/recipes/environment.rb
448
434
  - examples/server/recipes/node.rb
435
+ - examples/server/recipes/render_with_cached.rb
449
436
  - examples/server/recipes/role.rb
450
437
  - examples/server/recipes/search.rb
451
438
  - examples/server/spec/client_spec.rb
452
439
  - examples/server/spec/data_bag_spec.rb
453
440
  - examples/server/spec/environment_spec.rb
454
441
  - examples/server/spec/node_spec.rb
442
+ - examples/server/spec/render_with_cached_spec.rb
455
443
  - examples/server/spec/role_spec.rb
456
444
  - examples/server/spec/search_spec.rb
457
445
  - examples/service/recipes/disable.rb
@@ -616,11 +604,7 @@ files:
616
604
  - features/use_inline_resources.feature
617
605
  - features/user.feature
618
606
  - features/yum_package.feature
619
- - gemfiles/chef-11.0.0.gemfile
620
- - gemfiles/chef-11.2.0.gemfile
621
- - gemfiles/chef-11.4.4.gemfile
622
- - gemfiles/chef-11.6.0.gemfile
623
- - gemfiles/chef-11.8.0.gemfile
607
+ - gemfiles/chef-11.12.0.gemfile
624
608
  - gemfiles/chef-master.gemfile
625
609
  - lib/chefspec.rb
626
610
  - lib/chefspec/api.rb
@@ -686,6 +670,7 @@ files:
686
670
  - lib/chefspec/extensions/chef/data_query.rb
687
671
  - lib/chefspec/extensions/chef/lwrp_base.rb
688
672
  - lib/chefspec/extensions/chef/resource.rb
673
+ - lib/chefspec/extensions/chef/resource/freebsd_package.rb
689
674
  - lib/chefspec/extensions/chef/securable.rb
690
675
  - lib/chefspec/formatter.rb
691
676
  - lib/chefspec/librarian.rb
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'chef', '11.2.0'
4
-
5
- gemspec :path => '..'
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'chef', '11.4.4'
4
-
5
- gemspec :path => '..'
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'chef', '11.6.0'
4
-
5
- gemspec :path => '..'
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'chef', '11.8.0'
4
-
5
- gemspec :path => '..'