capsulecd 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +2 -0
  3. data/.dockerignore +5 -0
  4. data/.gitignore +95 -0
  5. data/.rspec +3 -0
  6. data/.simplecov +9 -0
  7. data/Dockerfile +16 -0
  8. data/Dockerfile.chef +26 -0
  9. data/Dockerfile.javascript +7 -0
  10. data/Dockerfile.node +7 -0
  11. data/Dockerfile.python +7 -0
  12. data/Dockerfile.ruby +4 -0
  13. data/FEATURES.md +12 -0
  14. data/Gemfile +26 -0
  15. data/LICENSE.md +22 -0
  16. data/README.md +227 -0
  17. data/Rakefile +43 -0
  18. data/bin/capsulecd +4 -0
  19. data/capsulecd.gemspec +27 -0
  20. data/circle.yml +24 -0
  21. data/lib/capsulecd/base/common/git_utils.rb +90 -0
  22. data/lib/capsulecd/base/common/validation_utils.rb +22 -0
  23. data/lib/capsulecd/base/configuration.rb +151 -0
  24. data/lib/capsulecd/base/engine.rb +163 -0
  25. data/lib/capsulecd/base/runner/circleci.rb +37 -0
  26. data/lib/capsulecd/base/runner/default.rb +38 -0
  27. data/lib/capsulecd/base/source/github.rb +183 -0
  28. data/lib/capsulecd/base/transform_engine.rb +62 -0
  29. data/lib/capsulecd/chef/chef_engine.rb +172 -0
  30. data/lib/capsulecd/chef/chef_helper.rb +29 -0
  31. data/lib/capsulecd/cli.rb +64 -0
  32. data/lib/capsulecd/error.rb +51 -0
  33. data/lib/capsulecd/javascript/javascript_engine.rb +213 -0
  34. data/lib/capsulecd/node/node_engine.rb +141 -0
  35. data/lib/capsulecd/python/python_engine.rb +157 -0
  36. data/lib/capsulecd/ruby/ruby_engine.rb +191 -0
  37. data/lib/capsulecd/ruby/ruby_helper.rb +60 -0
  38. data/lib/capsulecd/version.rb +3 -0
  39. data/lib/capsulecd.rb +16 -0
  40. data/logo.svg +1 -0
  41. data/spec/fixtures/chef/cookbook_analogj_test/CHANGELOG.md +3 -0
  42. data/spec/fixtures/chef/cookbook_analogj_test/Gemfile +18 -0
  43. data/spec/fixtures/chef/cookbook_analogj_test/LICENSE +21 -0
  44. data/spec/fixtures/chef/cookbook_analogj_test/README.md +13 -0
  45. data/spec/fixtures/chef/cookbook_analogj_test/Rakefile +1 -0
  46. data/spec/fixtures/chef/cookbook_analogj_test/Thorfile +12 -0
  47. data/spec/fixtures/chef/cookbook_analogj_test/chefignore +94 -0
  48. data/spec/fixtures/chef/cookbook_analogj_test/metadata.rb +5 -0
  49. data/spec/fixtures/chef/cookbook_analogj_test/recipes/default.rb +6 -0
  50. data/spec/fixtures/incorrect_configuration.yml +4 -0
  51. data/spec/fixtures/javascript/javascript_analogj_test/LICENSE +21 -0
  52. data/spec/fixtures/javascript/javascript_analogj_test/README.md +2 -0
  53. data/spec/fixtures/javascript/javascript_analogj_test/package.json +19 -0
  54. data/spec/fixtures/node/npm_analogj_test/LICENSE +21 -0
  55. data/spec/fixtures/node/npm_analogj_test/README.md +2 -0
  56. data/spec/fixtures/node/npm_analogj_test/package.json +19 -0
  57. data/spec/fixtures/python/pip_analogj_test/LICENSE +21 -0
  58. data/spec/fixtures/python/pip_analogj_test/MANIFEST.in +1 -0
  59. data/spec/fixtures/python/pip_analogj_test/README.md +1 -0
  60. data/spec/fixtures/python/pip_analogj_test/VERSION +1 -0
  61. data/spec/fixtures/python/pip_analogj_test/setup.cfg +5 -0
  62. data/spec/fixtures/python/pip_analogj_test/setup.py +80 -0
  63. data/spec/fixtures/python/pip_analogj_test/tox.ini +14 -0
  64. data/spec/fixtures/ruby/gem_analogj_test/Gemfile +4 -0
  65. data/spec/fixtures/ruby/gem_analogj_test/LICENSE.txt +21 -0
  66. data/spec/fixtures/ruby/gem_analogj_test/README.md +41 -0
  67. data/spec/fixtures/ruby/gem_analogj_test/Rakefile +6 -0
  68. data/spec/fixtures/ruby/gem_analogj_test/bin/console +14 -0
  69. data/spec/fixtures/ruby/gem_analogj_test/bin/setup +8 -0
  70. data/spec/fixtures/ruby/gem_analogj_test/gem_analogj_test.gemspec +25 -0
  71. data/spec/fixtures/ruby/gem_analogj_test/lib/gem_analogj_test/version.rb +3 -0
  72. data/spec/fixtures/ruby/gem_analogj_test/lib/gem_analogj_test.rb +5 -0
  73. data/spec/fixtures/ruby/gem_analogj_test/spec/gem_analogj_test_spec.rb +7 -0
  74. data/spec/fixtures/ruby/gem_analogj_test/spec/spec_helper.rb +2 -0
  75. data/spec/fixtures/ruby/gem_analogj_test-0.1.4.gem +0 -0
  76. data/spec/fixtures/sample_chef_configuration.yml +8 -0
  77. data/spec/fixtures/sample_configuration.yml +7 -0
  78. data/spec/fixtures/sample_global_configuration.yml +23 -0
  79. data/spec/fixtures/sample_node_configuration.yml +7 -0
  80. data/spec/fixtures/sample_python_configuration.yml +8 -0
  81. data/spec/fixtures/sample_repo_configuration.yml +22 -0
  82. data/spec/fixtures/sample_ruby_configuration.yml +5 -0
  83. data/spec/fixtures/vcr_cassettes/chef_build_step.yml +636 -0
  84. data/spec/fixtures/vcr_cassettes/gem_build_step.yml +653 -0
  85. data/spec/fixtures/vcr_cassettes/gem_build_step_without_version_rb.yml +653 -0
  86. data/spec/fixtures/vcr_cassettes/integration_chef.yml +1399 -0
  87. data/spec/fixtures/vcr_cassettes/integration_node.yml +1388 -0
  88. data/spec/fixtures/vcr_cassettes/integration_python.yml +1388 -0
  89. data/spec/fixtures/vcr_cassettes/integration_ruby.yml +1377 -0
  90. data/spec/fixtures/vcr_cassettes/node_build_step.yml +647 -0
  91. data/spec/fixtures/vcr_cassettes/pip_build_step.yml +653 -0
  92. data/spec/lib/capsulecd/base/configuration_spec.rb +75 -0
  93. data/spec/lib/capsulecd/base/engine_spec.rb +51 -0
  94. data/spec/lib/capsulecd/base/source/github_spec.rb +253 -0
  95. data/spec/lib/capsulecd/base/transform_engine_spec.rb +55 -0
  96. data/spec/lib/capsulecd/chef/chef_engine_spec.rb +114 -0
  97. data/spec/lib/capsulecd/cli_spec.rb +57 -0
  98. data/spec/lib/capsulecd/node/node_engine_spec.rb +113 -0
  99. data/spec/lib/capsulecd/python/python_engine_spec.rb +118 -0
  100. data/spec/lib/capsulecd/ruby/ruby_engine_spec.rb +128 -0
  101. data/spec/spec_helper.rb +105 -0
  102. data/spec/support/file_system.rb +21 -0
  103. data/spec/support/package_types.rb +11 -0
  104. metadata +281 -0
@@ -0,0 +1,113 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'CapsuleCD::Node::NodeEngine', :node do
4
+ describe '#build_step' do
5
+ describe 'when building an empty package' do
6
+ let(:engine) do
7
+ require 'capsulecd/node/node_engine'
8
+ CapsuleCD::Node::NodeEngine.new(source: :github,
9
+ package_type: :node)
10
+ end
11
+ it 'should raise an error' do
12
+ engine.instance_variable_set(:@source_git_local_path, test_directory )
13
+
14
+ expect { engine.build_step }.to raise_error(CapsuleCD::Error::BuildPackageInvalid)
15
+ end
16
+ end
17
+
18
+ describe 'when building a simple package ' do
19
+ let(:engine) do
20
+ require 'capsulecd/node/node_engine'
21
+ CapsuleCD::Node::NodeEngine.new(source: :github,
22
+ package_type: :node)
23
+ end
24
+ it 'should create a .gitignore file and tests folder' do
25
+ FileUtils.copy_entry('spec/fixtures/node/npm_analogj_test', test_directory)
26
+ engine.instance_variable_set(:@source_git_local_path, test_directory)
27
+
28
+ VCR.use_cassette('node_build_step',:tag => :chef) do
29
+ engine.build_step
30
+ end
31
+
32
+ File.exist?(test_directory+'/.gitignore')
33
+ end
34
+ end
35
+ end
36
+
37
+ describe '#test_step' do
38
+ let(:engine) do
39
+ require 'capsulecd/node/node_engine'
40
+ CapsuleCD::Node::NodeEngine.new(source: :github,
41
+ package_type: :node)
42
+ end
43
+ let(:config_double) { CapsuleCD::Configuration.new }
44
+ describe 'when testing node package' do
45
+ it 'should run install dependencies' do
46
+ FileUtils.copy_entry('spec/fixtures/node/npm_analogj_test', test_directory)
47
+ allow(Open3).to receive(:popen3).and_return(false)
48
+ allow(config_double).to receive(:engine_cmd_test).and_call_original
49
+ allow(config_double).to receive(:engine_disable_test).and_call_original
50
+ engine.instance_variable_set(:@source_git_local_path, test_directory)
51
+ engine.instance_variable_set(:@config, config_double)
52
+
53
+ engine.test_step
54
+
55
+ File.exist?(test_directory+'/npm-shrinkwrap.json')
56
+ end
57
+ end
58
+ end
59
+
60
+ describe 'integration tests' do
61
+ let(:engine) do
62
+ require 'capsulecd/node/node_engine'
63
+ CapsuleCD::Node::NodeEngine.new(source: :github,
64
+ runner: :default,
65
+ package_type: :node,
66
+ config_file: 'spec/fixtures/sample_node_configuration.yml'
67
+ # config_file: 'spec/fixtures/live_node_configuration.yml'
68
+ )
69
+ end
70
+ let(:git_commit_double) { instance_double(Git::Object::Commit) }
71
+ describe 'when testing node package' do
72
+ it 'should complete successfully' do
73
+ FileUtils.copy_entry('spec/fixtures/node/npm_analogj_test', test_directory)
74
+
75
+ VCR.use_cassette('integration_node',:tag => :node) do
76
+ #set defaults for stubbed classes
77
+ source_git_local_path = test_directory
78
+ allow(File).to receive(:exist?).and_call_original
79
+ allow(File).to receive(:open).and_call_original
80
+ allow(Open3).to receive(:popen3).and_call_original
81
+
82
+ #stub methods in source_process_pull_request_payload
83
+ allow(CapsuleCD::GitUtils).to receive(:clone).and_return(source_git_local_path)
84
+ allow(CapsuleCD::GitUtils).to receive(:fetch).and_return(true)
85
+ allow(CapsuleCD::GitUtils).to receive(:checkout).and_return(true)
86
+
87
+ #stub methods in build_step
88
+ allow(CapsuleCD::GitUtils).to receive(:create_gitignore).with(source_git_local_path, ['Node']).and_return(true)
89
+
90
+ #stub methods in package_step
91
+ allow(CapsuleCD::GitUtils).to receive(:commit).and_return(true)
92
+
93
+ allow(CapsuleCD::GitUtils).to receive(:get_latest_tag_commit).and_return(git_commit_double)
94
+ allow(git_commit_double).to receive(:sha).and_return('0a5948802a2bba02e019fd13bf3db3c5329faae6')
95
+ allow(git_commit_double).to receive(:name).and_return('v1.0.8')
96
+
97
+ #stub methods in release_step
98
+ allow(Open3).to receive(:popen3).with('npm publish .',{:chdir=>source_git_local_path}).and_return(true)
99
+ allow(File).to receive(:open).with(File.expand_path('~/.npmrc'), 'w+').and_return(true)
100
+
101
+ #stub methods in source_release
102
+ allow(CapsuleCD::GitUtils).to receive(:push).and_return(true)
103
+ allow(CapsuleCD::GitUtils).to receive(:generate_changelog).and_return('')
104
+
105
+ engine.start
106
+
107
+ end
108
+
109
+ end
110
+ end
111
+ end
112
+
113
+ end
@@ -0,0 +1,118 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'CapsuleCD::Python::PythonEngine', :python do
4
+ describe '#build_step' do
5
+ describe 'when building an empty package' do
6
+ let(:engine) do
7
+ require 'capsulecd/python/python_engine'
8
+ CapsuleCD::Python::PythonEngine.new(source: :github,
9
+ package_type: :python)
10
+ end
11
+ it 'should raise an error' do
12
+ engine.instance_variable_set(:@source_git_local_path, test_directory )
13
+
14
+ expect { engine.build_step }.to raise_error(CapsuleCD::Error::BuildPackageInvalid)
15
+ end
16
+ end
17
+
18
+ describe 'when building a simple package ' do
19
+ let(:engine) do
20
+ require 'capsulecd/python/python_engine'
21
+ CapsuleCD::Python::PythonEngine.new(source: :github,
22
+ package_type: :python)
23
+ end
24
+ it 'should create a VERSION file, requirements.txt file and tests folder' do
25
+ FileUtils.copy_entry('spec/fixtures/python/pip_analogj_test', test_directory)
26
+ engine.instance_variable_set(:@source_git_local_path, test_directory)
27
+
28
+ VCR.use_cassette('pip_build_step',:tag => :ruby) do
29
+ engine.build_step
30
+ end
31
+
32
+ File.exist?(test_directory+'/VERSION')
33
+ File.exist?(test_directory+'/requirements.txt')
34
+ File.exist?(test_directory+'/.gitignore')
35
+ end
36
+ end
37
+ end
38
+
39
+ describe '#test_step' do
40
+ before(:each) do
41
+ FileUtils.copy_entry('spec/fixtures/python/pip_analogj_test', test_directory)
42
+ end
43
+ let(:engine) do
44
+ require 'capsulecd/python/python_engine'
45
+ CapsuleCD::Python::PythonEngine.new(source: :github,
46
+ package_type: :python)
47
+ end
48
+ let(:config_double) { CapsuleCD::Configuration.new }
49
+ describe 'when testing python package' do
50
+ it 'should run install dependencies' do
51
+ allow(Open3).to receive(:popen3).and_return(false)
52
+ allow(config_double).to receive(:engine_cmd_test).and_call_original
53
+ allow(config_double).to receive(:engine_disable_test).and_call_original
54
+
55
+ engine.instance_variable_set(:@source_git_local_path, test_directory)
56
+ engine.instance_variable_set(:@config, config_double)
57
+
58
+ engine.test_step
59
+
60
+ File.exist?(test_directory+'/VERSION')
61
+ File.exist?(test_directory+'/requirements.txt')
62
+ end
63
+ end
64
+ end
65
+
66
+ describe 'integration tests' do
67
+ let(:engine) do
68
+ require 'capsulecd/python/python_engine'
69
+ CapsuleCD::Python::PythonEngine.new(source: :github,
70
+ runner: :default,
71
+ package_type: :python,
72
+ config_file: 'spec/fixtures/sample_python_configuration.yml'
73
+ # config_file: 'spec/fixtures/live_python_configuration.yml'
74
+ )
75
+ end
76
+ let(:git_commit_double) { instance_double(Git::Object::Commit) }
77
+ describe 'when testing python package' do
78
+ it 'should complete successfully' do
79
+ FileUtils.copy_entry('spec/fixtures/python/pip_analogj_test', test_directory)
80
+
81
+ VCR.use_cassette('integration_python',:tag => :python) do
82
+ #set defaults for stubbed classes
83
+ source_git_local_path = test_directory
84
+ allow(File).to receive(:exist?).and_call_original
85
+ allow(File).to receive(:open).and_call_original
86
+ allow(Open3).to receive(:popen3).and_call_original
87
+
88
+ #stub methods in source_process_pull_request_payload
89
+ allow(CapsuleCD::GitUtils).to receive(:clone).and_return(source_git_local_path)
90
+ allow(CapsuleCD::GitUtils).to receive(:fetch).and_return(true)
91
+ allow(CapsuleCD::GitUtils).to receive(:checkout).and_return(true)
92
+
93
+ #stub methods in build_step
94
+ allow(CapsuleCD::GitUtils).to receive(:create_gitignore).with(source_git_local_path, ['Python']).and_return(true)
95
+
96
+ #stub methods in package_step
97
+ allow(CapsuleCD::GitUtils).to receive(:commit).and_return(true)
98
+ allow(CapsuleCD::GitUtils).to receive(:tag).with(source_git_local_path,'v1.0.7').and_return(git_commit_double)
99
+ allow(git_commit_double).to receive(:sha).and_return('0a5948802a2bba02e019fd13bf3db3c5329faae6')
100
+ allow(git_commit_double).to receive(:name).and_return('v1.0.7')
101
+
102
+ #stub methods in release_step
103
+ allow(Open3).to receive(:popen3).with('python setup.py sdist upload',{:chdir=>source_git_local_path}).and_return(true)
104
+ allow(File).to receive(:open).with(File.expand_path('~/.pypirc'), 'w+').and_return(true)
105
+
106
+ #stub methods in source_release
107
+ allow(CapsuleCD::GitUtils).to receive(:push).and_return(true)
108
+ allow(CapsuleCD::GitUtils).to receive(:generate_changelog).and_return('')
109
+
110
+ engine.start
111
+
112
+ end
113
+
114
+ end
115
+ end
116
+ end
117
+
118
+ end
@@ -0,0 +1,128 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'CapsuleCD::Ruby::RubyEngine', :ruby do
4
+ describe '#build_step' do
5
+ describe 'when building an empty package' do
6
+ let(:engine) do
7
+ require 'capsulecd/ruby/ruby_engine'
8
+ CapsuleCD::Ruby::RubyEngine.new(source: :github,
9
+ package_type: :ruby)
10
+ end
11
+ it 'should raise an error' do
12
+ engine.instance_variable_set(:@source_git_local_path, test_directory )
13
+
14
+ expect { engine.build_step }.to raise_error(CapsuleCD::Error::BuildPackageInvalid)
15
+ end
16
+ end
17
+
18
+ describe 'when building a simple package ' do
19
+ let(:engine) do
20
+ require 'capsulecd/ruby/ruby_engine'
21
+ CapsuleCD::Ruby::RubyEngine.new(source: :github,
22
+ package_type: :ruby)
23
+ end
24
+ it 'should create a .gitignore file and spec folder' do
25
+ FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test', test_directory)
26
+
27
+ engine.instance_variable_set(:@source_git_local_path, test_directory)
28
+
29
+ VCR.use_cassette('gem_build_step',:tag => :ruby) do
30
+ engine.build_step
31
+ end
32
+
33
+ expect(File.exist?(test_directory+'/.gitignore')).to eql(true)
34
+ end
35
+
36
+ it 'should raise an error if version.rb is missing' do
37
+ FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test', test_directory)
38
+ FileUtils.rm(test_directory + '/lib/gem_analogj_test/version.rb')
39
+ engine.instance_variable_set(:@source_git_local_path, test_directory)
40
+
41
+ VCR.use_cassette('gem_build_step_without_version.rb',:tag => :ruby) do
42
+ expect{engine.build_step}.to raise_error(CapsuleCD::Error::BuildPackageInvalid)
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+
49
+ describe '#test_step' do
50
+ before(:each) do
51
+ FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test', test_directory)
52
+ FileUtils.cp('spec/fixtures/ruby/gem_analogj_test-0.1.4.gem', test_directory)
53
+
54
+ end
55
+ let(:engine) do
56
+ require 'capsulecd/ruby/ruby_engine'
57
+ CapsuleCD::Ruby::RubyEngine.new(source: :github,
58
+ package_type: :ruby)
59
+ end
60
+ let(:config_double) { CapsuleCD::Configuration.new }
61
+ describe 'when testing ruby package' do
62
+ it 'should run install dependencies' do
63
+ allow(Open3).to receive(:popen3).and_return(false)
64
+ allow(config_double).to receive(:engine_cmd_test).and_call_original
65
+ allow(config_double).to receive(:engine_disable_test).and_call_original
66
+
67
+ engine.instance_variable_set(:@source_git_local_path, test_directory)
68
+ engine.instance_variable_set(:@config, config_double)
69
+
70
+ engine.test_step
71
+ end
72
+ end
73
+ end
74
+
75
+ describe 'integration tests' do
76
+ let(:engine) do
77
+ require 'capsulecd/ruby/ruby_engine'
78
+ CapsuleCD::Ruby::RubyEngine.new(source: :github,
79
+ runner: :default,
80
+ package_type: :ruby,
81
+ config_file: 'spec/fixtures/sample_ruby_configuration.yml'
82
+ # config_file: 'spec/fixtures/live_ruby_configuration.yml'
83
+ )
84
+ end
85
+ let(:git_commit_double) { instance_double(Git::Object::Commit) }
86
+ describe 'when testing ruby package' do
87
+ it 'should complete successfully' do
88
+ FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test', test_directory)
89
+
90
+ VCR.use_cassette('integration_ruby',:tag => :ruby) do
91
+ #set defaults for stubbed classes
92
+ source_git_local_path = test_directory
93
+ allow(File).to receive(:exist?).and_call_original
94
+ allow(File).to receive(:open).and_call_original
95
+ allow(Open3).to receive(:popen3).and_call_original
96
+
97
+ #stub methods in source_process_pull_request_payload
98
+ allow(CapsuleCD::GitUtils).to receive(:clone).and_return(source_git_local_path)
99
+ allow(CapsuleCD::GitUtils).to receive(:fetch).and_return(true)
100
+ allow(CapsuleCD::GitUtils).to receive(:checkout).and_return(true)
101
+
102
+ #stub methods in build_step
103
+ allow(CapsuleCD::GitUtils).to receive(:create_gitignore).with(source_git_local_path, ['Ruby']).and_return(true)
104
+
105
+ #stub methods in package_step
106
+ allow(CapsuleCD::GitUtils).to receive(:commit).and_return(true)
107
+ allow(CapsuleCD::GitUtils).to receive(:tag).with(source_git_local_path,'v0.1.4').and_return(git_commit_double)
108
+ allow(git_commit_double).to receive(:sha).and_return('7d10007c0e1c6262d5a93cc2d3225c1c651fa13a')
109
+ allow(git_commit_double).to receive(:name).and_return('v0.1.4')
110
+
111
+ #stub methods in release_step
112
+ allow(Open3).to receive(:popen3).with('gem push gem_analogj_test-0.1.4.gem',{:chdir=>source_git_local_path}).and_return(true)
113
+ allow(FileUtils).to receive(:mkdir_p).with(File.expand_path('~/.gem')).and_return(true)
114
+ allow(File).to receive(:open).with(File.expand_path('~/.gem/credentials'), 'w+').and_return(true)
115
+
116
+ #stub methods in source_release
117
+ allow(CapsuleCD::GitUtils).to receive(:push).and_return(true)
118
+ allow(CapsuleCD::GitUtils).to receive(:generate_changelog).and_return('')
119
+
120
+ engine.start
121
+
122
+ end
123
+
124
+ end
125
+ end
126
+ end
127
+
128
+ end
@@ -0,0 +1,105 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ require 'rspec'
5
+ require 'vcr'
6
+ require 'webmock/rspec'
7
+ require 'capsulecd'
8
+
9
+ Dir['spec/support/*.rb'].each { |f| require File.expand_path(f) }
10
+
11
+ def configure_vcr(vcr_config, type, config_file)
12
+
13
+ if !File.exist?(config_file)
14
+ config_file = 'spec/fixtures/sample_configuration.yml'
15
+ end
16
+ capsulecd_config = CapsuleCD::Configuration.new(config_file: config_file)
17
+
18
+ vcr_config.filter_sensitive_data('<GITHUB_ACCESS_TOKEN>', type) do
19
+ capsulecd_config.source_github_access_token
20
+ end
21
+ # vcr_config.filter_sensitive_data('<SUPERMARKET_USERNAME>', type) do
22
+ # capsulecd_config.chef_supermarket_username
23
+ # end
24
+ vcr_config.filter_sensitive_data('<NPM_AUTH_TOKEN>', type) do
25
+ capsulecd_config.npm_auth_token
26
+ end
27
+ # vcr_config.filter_sensitive_data('<PYPI_USERNAME>', type) do
28
+ # capsulecd_config.pypi_username
29
+ # end
30
+ vcr_config.filter_sensitive_data('<PYPI_PASSWORD>', type) do
31
+ capsulecd_config.pypi_password
32
+ end
33
+
34
+ end
35
+
36
+ VCR.configure do |c|
37
+ c.debug_logger = File.open('spec/vcr.log', 'w+')
38
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
39
+ c.hook_into :webmock
40
+ c.configure_rspec_metadata!
41
+ c.preserve_exact_body_bytes { true }
42
+
43
+ c.default_cassette_options = {
44
+ record: :once #:new_episodes
45
+ }
46
+
47
+ configure_vcr(c, :python, 'spec/fixtures/live_python_configuration.yml')
48
+ configure_vcr(c, :ruby, 'spec/fixtures/live_ruby_configuration.yml')
49
+ configure_vcr(c, :node, 'spec/fixtures/live_node_configuration.yml')
50
+ configure_vcr(c, :chef, 'spec/fixtures/live_chef_configuration.yml')
51
+ configure_vcr(c, :javascript, 'spec/fixtures/live_javascript_configuration.yml')
52
+ end
53
+
54
+ # This file was generated by the `rspec --init` command. Conventionally, all
55
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
56
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
57
+ # this file to always be loaded, without a need to explicitly require it in any
58
+ # files.
59
+ #
60
+ # Given that it is always loaded, you are encouraged to keep this file as
61
+ # light-weight as possible. Requiring heavyweight dependencies from this file
62
+ # will add to the boot time of your test suite on EVERY test run, even for an
63
+ # individual file that may not need all of that loaded. Instead, consider making
64
+ # a separate helper file that requires the additional dependencies and performs
65
+ # the additional setup, and require it from the spec files that actually need
66
+ # it.
67
+ #
68
+ # The `.rspec` file also contains a few flags that are not defaults but that
69
+ # users commonly want.
70
+ #
71
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
72
+ RSpec.configure do |config|
73
+ config.include CapsuleCD::RSpecSupport::FileSystem
74
+
75
+ config.before(:each) {
76
+ make_test_directory
77
+ }
78
+ config.after(:each) {
79
+ remove_test_directory
80
+ }
81
+
82
+ # rspec-expectations config goes here. You can use an alternate
83
+ # assertion/expectation library such as wrong or the stdlib/minitest
84
+ # assertions if you prefer.
85
+ config.expect_with :rspec do |expectations|
86
+ # This option will default to `true` in RSpec 4. It makes the `description`
87
+ # and `failure_message` of custom matchers include text for helper methods
88
+ # defined using `chain`, e.g.:
89
+ # be_bigger_than(2).and_smaller_than(4).description
90
+ # # => "be bigger than 2 and smaller than 4"
91
+ # ...rather than:
92
+ # # => "be bigger than 2"
93
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
94
+ end
95
+
96
+ # rspec-mocks config goes here. You can use an alternate test double
97
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
98
+ config.mock_with :rspec do |mocks|
99
+ # Prevents you from mocking or stubbing a method that does not exist on
100
+ # a real object. This is generally recommended, and will default to
101
+ # `true` in RSpec 4.
102
+ mocks.verify_partial_doubles = true
103
+ end
104
+
105
+ end
@@ -0,0 +1,21 @@
1
+ module CapsuleCD
2
+ module RSpecSupport
3
+ module FileSystem
4
+ def test_directory
5
+ 'spec/tmp'
6
+ end
7
+
8
+ def test_directory_contents
9
+ Dir.glob(File.join(test_directory, '*/**'))
10
+ end
11
+
12
+ def make_test_directory
13
+ FileUtils.mkdir_p(test_directory)
14
+ end
15
+
16
+ def remove_test_directory
17
+ FileUtils.remove_dir(test_directory) if Dir.exist?(test_directory)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ module CapsuleCD
2
+ module RSpecSupport
3
+ module PackageTypes
4
+ def package_types
5
+ Dir.entries('lib/capsulecd').select {|entry|
6
+ File.directory? File.join('lib/capsulecd',entry) and !(entry =='.' || entry == '..' || entry == 'base')
7
+ }
8
+ end
9
+ end
10
+ end
11
+ end