ra10ke 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'ra10ke/validate'
5
+ RSpec::Mocks.configuration.allow_message_expectations_on_nil = true
6
+
7
+ RSpec.describe 'Ra10ke::Validate::Validation' do
8
+ let(:instance) do
9
+ Ra10ke::Validate::Validation.new(puppetfile)
10
+ end
11
+
12
+ let(:result) do
13
+ double
14
+ end
15
+
16
+ before(:each) do
17
+ allow(result).to receive(:success?).and_return(true)
18
+ # allow(instance).to receive(:`).with(anything).and_return(result)
19
+ allow($CHILD_STATUS).to receive(:success?).and_return(true)
20
+ allow(instance).to receive(:`).with(anything)
21
+ .and_return(File.read(File.join(fixtures_dir, 'reflist.txt')))
22
+ end
23
+
24
+ let(:puppetfile) do
25
+ File.join(fixtures_dir, 'Puppetfile')
26
+ end
27
+
28
+ it '#new' do
29
+ expect(instance).to be_a Ra10ke::Validate::Validation
30
+ end
31
+
32
+ it '#valid_ref?' do
33
+ expect(instance.valid_ref?('https://www.example.com', 'master')).to be true
34
+ end
35
+
36
+ it '#valid_commit?' do
37
+ expect(instance.valid_commit?('https://www.example.com', 'master')).to be true
38
+ end
39
+
40
+ it '#bad_mods?' do
41
+ allow(instance).to receive(:`).with(anything)
42
+ .and_return(File.read(File.join(fixtures_dir, 'reflist.txt')))
43
+ # because we can't test every single module we return the same result set
44
+ # which only passes for a single module, while others fail.
45
+ expect(instance.bad_mods?).to be true
46
+ end
47
+
48
+ it '#all_modules is an array' do
49
+ expect(instance.all_modules).to be_a Array
50
+ end
51
+
52
+ it '#sorted_mods is an array' do
53
+ expect(instance.sorted_mods).to be_a Array
54
+ end
55
+
56
+ it '#data is a hash' do
57
+ expect(instance.all_modules.first).to be_a Hash
58
+ end
59
+
60
+ it '#data is a hash with keys' do
61
+ keys = instance.all_modules.first.keys
62
+ expect(keys).to eq(%i[name url ref valid_ref? status])
63
+ end
64
+
65
+ it '#data is a hash with values' do
66
+ keys = instance.all_modules.first.values
67
+
68
+ expect(keys).to eq(['gitlab', 'https://github.com/vshn/puppet-gitlab',
69
+ '00397b86dfb3487d9df768cbd3698d362132b5bf', true, '👍'])
70
+ end
71
+
72
+ it '#all_refs' do
73
+ refs = instance.all_refs('https://www.example.com')
74
+ expect(refs).to be_a Hash
75
+ expect(refs.first).to eq(
76
+ ["0ec707e431367bbe2752966be8ab915b6f0da754",
77
+ {:name=>"74110ac", :ref=>"refs/heads/74110ac", :subtype=>nil, :type=>:branch}]
78
+ )
79
+
80
+ end
81
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ra10ke'
4
+ require 'spec_helper'
5
+
6
+ RSpec.describe 'Ra10ke::RakeTask' do
7
+ let(:instance) do
8
+ Ra10ke::RakeTask.new do |t|
9
+ t.puppetfile_path = puppetfile
10
+ end
11
+ end
12
+
13
+ let(:puppetfile) do
14
+ File.join(fixtures_dir, 'Puppetfile')
15
+ end
16
+
17
+ let(:args) do
18
+ []
19
+ end
20
+
21
+ describe 'validate tasks' do
22
+ it '#new' do
23
+ expect(instance).to be_a Ra10ke::RakeTask
24
+ end
25
+
26
+ it '#define_task_validate' do
27
+ expect(instance.define_task_validate(args)).to be_a Rake::Task
28
+ end
29
+
30
+ it '#define_task_solve_dependencies' do
31
+ expect(instance.define_task_solve_dependencies(args)).to be_a Rake::Task
32
+ end
33
+
34
+ it '#define_task_syntax' do
35
+ expect(instance.define_task_syntax(args)).to be_a Rake::Task
36
+ end
37
+
38
+ it '#define_task_dependencies' do
39
+ expect(instance.define_task_dependencies(args)).to be_a Rake::Task
40
+ end
41
+
42
+ it '#define_task_install' do
43
+ expect(instance.define_task_install(args)).to be_a Rake::Task
44
+ end
45
+
46
+ it '#get_puppetfile' do
47
+ expect(instance.get_puppetfile).to be_a R10K::Puppetfile
48
+ end
49
+ end
50
+
51
+ describe 'run tasks with good refs' do
52
+ it '#run_validate_task' do
53
+ task = instance.define_task_validate(args)
54
+ expect(task.invoke).to be_a Array
55
+ end
56
+ end
57
+
58
+ describe 'run tasks with bad refs' do
59
+ let(:puppetfile) do
60
+ File.join(fixtures_dir, 'Puppetfile_with_bad_refs')
61
+ end
62
+
63
+ # I suspect rake is caching something here and the puppetfile is
64
+ # not being sent correctly as it is not using the file I specify.
65
+ # The output should be different.
66
+ # Testing this by itself works
67
+ it '#run_validate_task' do
68
+ t = Ra10ke::RakeTask.new
69
+ task2 = t.define_task_validate(args)
70
+ expect(task2.invoke).to be nil
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,3 @@
1
+ def fixtures_dir
2
+ File.join(__dir__, 'fixtures')
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ra10ke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Theo Chatzimichos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-26 00:00:00.000000000 Z
11
+ date: 2019-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -94,6 +94,34 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '2.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: table_print
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.5.6
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.5.6
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.6'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.6'
97
125
  description: R10K and Puppetfile rake tasks
98
126
  email:
99
127
  - tampakrap@gmail.com
@@ -102,6 +130,7 @@ extensions: []
102
130
  extra_rdoc_files: []
103
131
  files:
104
132
  - ".gitignore"
133
+ - ".ruby-version"
105
134
  - ".travis.yml"
106
135
  - CHANGELOG.md
107
136
  - Gemfile
@@ -109,9 +138,23 @@ files:
109
138
  - README.md
110
139
  - Rakefile
111
140
  - lib/ra10ke.rb
141
+ - lib/ra10ke/dependencies.rb
142
+ - lib/ra10ke/install.rb
143
+ - lib/ra10ke/monkey_patches.rb
144
+ - lib/ra10ke/puppetfile_parser.rb
112
145
  - lib/ra10ke/solve.rb
146
+ - lib/ra10ke/syntax.rb
147
+ - lib/ra10ke/validate.rb
113
148
  - lib/ra10ke/version.rb
114
149
  - ra10ke.gemspec
150
+ - spec/fixtures/Puppetfile
151
+ - spec/fixtures/Puppetfile_test
152
+ - spec/fixtures/Puppetfile_with_bad_refs
153
+ - spec/fixtures/reflist.txt
154
+ - spec/ra10ke/puppetfile_parser_spec.rb
155
+ - spec/ra10ke/validate_spec.rb
156
+ - spec/ra10ke_spec.rb
157
+ - spec/spec_helper.rb
115
158
  homepage: https://github.com/voxpupuli/ra10ke
116
159
  licenses:
117
160
  - MIT