rdm 0.4.7 → 0.4.8

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +69 -1
  4. data/bin/rdm +102 -42
  5. data/example/.rdm/templates/configs/<%=config_path%> +2 -0
  6. data/example/.rdm/templates/configs/<%=role_config_path%> +2 -0
  7. data/example/Rdm.packages +8 -3
  8. data/example/domain/core/spec/core/one_more_spec.rb +5 -0
  9. data/example/domain/core/spec/core/sample_service_spec.rb +5 -0
  10. data/example/infrastructure/repository/Package.rb +1 -1
  11. data/example/infrastructure/repository/spec/example_spec.rb +5 -0
  12. data/example/infrastructure/repository/spec/spec_helper.rb +7 -0
  13. data/example/server/spec/server_spec.rb +5 -0
  14. data/example/server/spec/spec_helper.rb +7 -0
  15. data/example/{.runignore → tests/.runignore} +0 -0
  16. data/example/tests/diff_run +1 -30
  17. data/example/tests/run +1 -39
  18. data/lib/rdm.rb +2 -1
  19. data/lib/rdm/cli/dependencies_controller.rb +2 -0
  20. data/lib/rdm/cli/diff_spec_runner.rb +42 -0
  21. data/lib/rdm/errors.rb +3 -0
  22. data/lib/rdm/gen/config.rb +1 -3
  23. data/lib/rdm/gen/init.rb +13 -7
  24. data/lib/rdm/gen/package.rb +6 -6
  25. data/lib/rdm/handlers/dependencies_handler.rb +14 -9
  26. data/lib/rdm/handlers/diff_package_handler.rb +2 -1
  27. data/lib/rdm/handlers/template_handler.rb +2 -2
  28. data/lib/rdm/settings.rb +0 -1
  29. data/lib/rdm/source_modifier.rb +69 -0
  30. data/lib/rdm/spec_runner.rb +5 -2
  31. data/lib/rdm/spec_runner/command_generator.rb +3 -2
  32. data/lib/rdm/spec_runner/runner.rb +18 -8
  33. data/lib/rdm/templates/init/bin/console +1 -1
  34. data/lib/rdm/templates/init/{.runignore → tests/.runignore} +0 -0
  35. data/lib/rdm/templates/init/tests/diff_run +1 -33
  36. data/lib/rdm/templates/init/tests/run +1 -39
  37. data/lib/rdm/version.rb +1 -1
  38. data/spec/helpers/example_project_helper.rb +0 -185
  39. data/spec/rdm/cli/diff_spec_runner_spec.rb +55 -0
  40. data/spec/rdm/cli/init_spec.rb +0 -2
  41. data/spec/rdm/gen/init_spec.rb +9 -1
  42. data/spec/rdm/handlers/dependencies_handler_spec.rb +27 -0
  43. data/spec/rdm/source_parser_spec.rb +1 -2
  44. data/spec/rdm/spec_runner/runner_spec.rb +61 -3
  45. metadata +14 -9
  46. data/lib/rdm/source_composer.rb +0 -38
  47. data/spec/rdm/cli/diff_package_spec.rb +0 -5
  48. data/spec/rdm/source_composer_spec.rb +0 -76
@@ -1,35 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- ENV['RUBY_ENV'] = 'test'
4
- require 'rdm'
5
-
6
- REVISION = ARGV.clone.first
7
- PATH = File.expand_path(__FILE__)
8
-
9
- Rdm.root(__FILE__)
10
-
11
- begin
12
- changed_packages = Rdm::Handlers::DiffPackageHandler.handle(
13
- path: PATH,
14
- revision: REVISION
15
- )
16
-
17
- puts "Tests for the following packages will run:"
18
- puts changed_packages
19
-
20
- changed_packages.each do |package|
21
- Rdm::SpecRunner.run(
22
- package: package,
23
- path: PATH,
24
- skip_ignored_packages: false,
25
- show_missing_packages: true
26
- )
27
- end
28
-
29
-
30
- rescue Rdm::Errors::GitRepositoryNotInitialized
31
- puts "Git repository is not initialized. Use `git init .`"
32
- exit(1)
33
- end
34
-
35
-
3
+ system("bundle exec rdm rspec.diff_run #{ARGV.join(' ')}", out: STDOUT, err: :out)
@@ -1,41 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- ## # run own tests:
4
- ## $ TEST_RUN=1 tests/run
5
-
6
- ## # run application tests:
7
- ## $ tests/run
8
-
9
- ## # run package tests:
10
- ## $ tests/run commands
11
-
12
- ## # run spec in a package:
13
- ## $ tests/run commands some_spec.rb
14
-
15
- ENV['RUBY_ENV'] = 'test'
16
- require 'rdm'
17
-
18
- Rdm.root(__FILE__)
19
-
20
- if ENV['TEST_RUN']
21
- require 'minitest/autorun'
22
- describe Rdm::SpecRunner::Runner do
23
- before do
24
- @runner = Rdm::SpecRunner::Runner.new({})
25
- end
26
-
27
- describe 'works ' do
28
- it 'assert true' do
29
- assert 2 == 2
30
- end
31
- end
32
- end
33
- else
34
- Rdm::SpecRunner.run(
35
- package: ARGV.clone.first,
36
- spec_matcher: ARGV.clone[1],,
37
- path: File.expand_path(__FILE__),
38
- skip_ignored_packages: true,
39
- show_missing_packages: true
40
- )
41
- end
3
+ system("bundle exec rdm rspec.run #{ARGV.join(' ')}", out: STDOUT, err: :out)
data/lib/rdm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rdm
2
- VERSION = '0.4.7'.freeze
2
+ VERSION = '0.4.8'.freeze
3
3
  end
@@ -28,190 +28,5 @@ module ExampleProjectHelper
28
28
 
29
29
  FileUtils.rm_rf(File.join(@example_project_path, '.rdm'))
30
30
  end
31
-
32
- # FileUtils.mkdir_p(File.join(path, 'configs'))
33
- # FileUtils.mkdir_p(File.join(path, 'application/web/package/web'))
34
- # FileUtils.mkdir_p(File.join(path, 'domain/core/package/core'))
35
- # FileUtils.mkdir_p(File.join(path, 'subsystems/mailing_system/package/mailing_system'))
36
- # FileUtils.mkdir_p(File.join(path, 'subsystems/api/package/api'))
37
- # FileUtils.mkdir_p(File.join(path, 'tests'))
38
-
39
- # if package_template
40
- # FileUtils.mkdir_p(File.join(path, '.rdm/templates/package'))
41
- # File.open(File.join(path, '.rdm/templates/package/Package.rb'), 'w') do |f|
42
- # f.write <<~EOF
43
- # package do
44
- # name '<%= package_name %>'
45
- # version "1.0"
46
- # end
47
-
48
- # dependency do
49
- # # import "core"
50
- # end
51
- # EOF
52
- # end
53
- # end
54
-
55
- # File.open(File.join(path, 'tests/run'), 'w') do |f|
56
- # f.write <<~EOF
57
- # # how to start tests for your project with rdm
58
- # EOF
59
- # end
60
-
61
- # File.open(File.join(path, 'Readme.md'), 'w') do |f|
62
- # f.write <<~EOF
63
- # Some content about your project
64
- # EOF
65
- # end
66
-
67
- # File.open(File.join(path, 'Gemfile'), 'w') do |f|
68
- # f.write <<~EOF
69
- # gem 'rdm'
70
- # EOF
71
- # end
72
-
73
- # File.open(File.join(path, 'Gemfile.lock'), 'w') do |f|
74
- # f.write <<~EOF
75
- # gem 'rdm'
76
- # EOF
77
- # end
78
-
79
- # File.open(File.join(path, 'Gemfile.lock'), 'w') do |f|
80
- # f.write <<~EOF
81
- # gem 'rdm'
82
- # EOF
83
- # end
84
-
85
- # File.open(File.join(path, Rdm::SOURCE_FILENAME), 'w') do |f|
86
- # f.write <<~EOF
87
- # setup do
88
- # role "production"
89
- # configs_dir "configs"
90
- # config_path ":configs_dir/:config_name/default.yml"
91
- # role_config_path ":configs_dir/:config_name/:role.yml"
92
- # package_subdir_name "package"
93
- # compile_path "/tmp/example_compile"
94
- # compile_ignore_files [
95
- # '.gitignore',
96
- # '.byebug_history',
97
- # '.irbrc',
98
- # '.rspec',
99
- # '*_spec.rb',
100
- # '*.log'
101
- # ]
102
- # compile_add_files [
103
- # 'Gemfile',
104
- # 'Gemfile.lock'
105
- # ]
106
- # end
107
-
108
- # package "application/web"
109
- # package "domain/core"
110
- # package "subsystems/api"
111
- # EOF
112
- # end
113
-
114
- # File.open(File.join(path, "application/web", Rdm::PACKAGE_FILENAME), 'w') do |f|
115
- # f.write <<~EOF
116
- # package do
117
- # name "web"
118
- # version "1.0"
119
- # end
120
-
121
- # dependency do
122
- # import "core"
123
- # end
124
- # EOF
125
- # end
126
-
127
- # File.open(File.join(path, "domain/core", Rdm::PACKAGE_FILENAME), 'w') do |f|
128
- # f.write <<~EOF
129
- # package do
130
- # name "core"
131
- # version "1.0"
132
- # end
133
-
134
- # dependency do
135
- # end
136
- # EOF
137
- # end
138
-
139
- # File.open(File.join(path, "subsystems/api", Rdm::PACKAGE_FILENAME), 'w') do |f|
140
- # f.write <<~EOF
141
- # package do
142
- # name "api"
143
- # version "1.0"
144
- # end
145
-
146
- # dependency do
147
- # import "web"
148
- # end
149
- # EOF
150
- # end
151
-
152
- # File.open(File.join(path, "application/web/package/web/", "sample_controller.rb"), 'w') do |f|
153
- # f.write <<~EOF
154
- # class Web::SampleController
155
- # def perform
156
- # sample_service.perform
157
- # end
158
-
159
- # def sample_service
160
- # Core::SampleService.new
161
- # end
162
- # end
163
- # EOF
164
- # end
165
-
166
- # File.open(File.join(path, "application/web/package/", "web.rb"), 'w') do |f|
167
- # f.write <<~EOF
168
- # require 'active_support'
169
- # require 'active_support/dependencies'
170
- # require 'active_support/core_ext'
171
-
172
- # ActiveSupport::Dependencies.autoload_paths << Pathname.new(__FILE__).parent.to_s
173
-
174
- # module Web
175
- # end
176
- # EOF
177
- # end
178
-
179
- # File.open(File.join(path, "domain/core/package/core/", "sample_service.rb"), 'w') do |f|
180
- # f.write <<~EOF
181
- # class Core::SampleService
182
- # def perform
183
- # puts "Core::SampleService called..."
184
- # end
185
- # end
186
- # EOF
187
- # end
188
-
189
- # File.open(File.join(path, "domain/core/package/", "core.rb"), 'w') do |f|
190
- # f.write <<~EOF
191
- # require 'active_support'
192
- # require 'active_support/dependencies'
193
- # require 'active_support/core_ext'
194
-
195
- # ActiveSupport::Dependencies.autoload_paths << Pathname.new(__FILE__).parent.to_s
196
-
197
- # module Core
198
- # end
199
- # EOF
200
- # end
201
-
202
- # File.open(File.join(path, "subsystems/api/package", "api.rb"), 'w') do |f|
203
- # f.write <<~EOF
204
- # require 'active_support'
205
- # require 'active_support/dependencies'
206
- # require 'active_support/core_ext'
207
-
208
- # ActiveSupport::Dependencies.autoload_paths << Pathname.new(__FILE__).parent.to_s
209
-
210
- # module Api
211
- # end
212
- # EOF
213
- # end
214
-
215
- # return path
216
31
  end
217
32
  end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rdm::CLI::DiffSpecRunner do
4
+ include ExampleProjectHelper
5
+ include GitCommandsHelper
6
+
7
+ subject { described_class }
8
+ let(:stdout) { SpecLogger.new }
9
+
10
+ before { initialize_example_project }
11
+ after do
12
+ reset_example_project
13
+ stdout.clean
14
+ end
15
+
16
+ describe '::run' do
17
+ context 'for not initialized git repository' do
18
+ it 'puts message to initialize git repository' do
19
+ subject.run(path: example_project_path, stdout: stdout)
20
+
21
+ expect(stdout.output).to include("Git repository is not initialized. Use `git init .`")
22
+ end
23
+ end
24
+
25
+ context 'for initialized git repository' do
26
+ context 'if no files were changed' do
27
+ it 'puts message about no changed packages were found' do
28
+ git_initialize_repository(example_project_path)
29
+ git_commit_changes(example_project_path)
30
+
31
+ subject.run(path: example_project_path, stdout: stdout)
32
+
33
+ expect(stdout.output).to include("No modified packages were found. Type `git add .` to index all changes...")
34
+ end
35
+ end
36
+
37
+ context 'if any files were changed' do
38
+ it 'puts the list of changed packages' do
39
+ git_initialize_repository(example_project_path)
40
+ git_commit_changes(example_project_path)
41
+
42
+ File.open(
43
+ File.join(example_project_path, 'server/package/server.rb'), 'w+'
44
+ ) {|f| f.write '# some comment message'}
45
+
46
+ git_index_changes(example_project_path)
47
+
48
+ subject.run(path: example_project_path, stdout: stdout, show_output: false)
49
+
50
+ expect(stdout.output).to include("Tests for the following packages will run:\n - server\n\n")
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -23,8 +23,6 @@ describe Rdm::CLI::Init do
23
23
  ensure_exists("Rdm.packages")
24
24
  ensure_exists("Gemfile")
25
25
  ensure_exists("Readme.md")
26
- ensure_exists("tests/run")
27
- ensure_exists("tests/diff_run")
28
26
  end
29
27
  end
30
28
 
@@ -17,7 +17,6 @@ describe Rdm::Gen::Init do
17
17
  ensure_exists("Rdm.packages")
18
18
  ensure_exists("Gemfile")
19
19
  ensure_exists("Readme.md")
20
- ensure_exists("tests/run")
21
20
  ensure_exists("bin/console")
22
21
  ensure_exists("env_files/test.env")
23
22
  ensure_exists("env_files/development.env")
@@ -37,6 +36,15 @@ describe Rdm::Gen::Init do
37
36
  ensure_exists(".rdm/templates/package/bin/console")
38
37
  end
39
38
  end
39
+
40
+ it "has generated config templates" do
41
+ subject.generate(current_path: example_project_path, stdout: stdout)
42
+
43
+ FileUtils.cd(example_project_path) do
44
+ ensure_exists(".rdm/templates/configs/<%=config_path%>")
45
+ ensure_exists(".rdm/templates/configs/<%=role_config_path%>")
46
+ end
47
+ end
40
48
  end
41
49
 
42
50
  context "prevents double execution" do
@@ -17,6 +17,15 @@ describe Rdm::Handlers::DependenciesHandler do
17
17
  )
18
18
  ).to match(["core", "repository", "web"])
19
19
  end
20
+
21
+ it "raises Rdm::Errors::PackageDoesNotExist for invalid package name" do
22
+ expect{
23
+ subject.show_names(
24
+ package_name: 'invalid_package',
25
+ project_path: example_project_path
26
+ )
27
+ }.to raise_error(Rdm::Errors::PackageDoesNotExist)
28
+ end
20
29
  end
21
30
 
22
31
  context ":show_packages" do
@@ -33,6 +42,15 @@ describe Rdm::Handlers::DependenciesHandler do
33
42
  it "returns array with proper size" do
34
43
  expect(result.first).to be_a Rdm::Package
35
44
  end
45
+
46
+ it "raises Rdm::Errors::PackageDoesNotExist for invalid package name" do
47
+ expect{
48
+ subject.show_packages(
49
+ package_name: 'invalid_package',
50
+ project_path: example_project_path
51
+ )
52
+ }.to raise_error(Rdm::Errors::PackageDoesNotExist)
53
+ end
36
54
  end
37
55
 
38
56
  context ":format_for_draw" do
@@ -82,5 +100,14 @@ describe Rdm::Handlers::DependenciesHandler do
82
100
  )
83
101
  end
84
102
  end
103
+
104
+ it "raises Rdm::Errors::PackageDoesNotExist for invalid package name" do
105
+ expect{
106
+ subject.draw(
107
+ package_name: 'invalid_package',
108
+ project_path: example_project_path
109
+ )
110
+ }.to raise_error(Rdm::Errors::PackageDoesNotExist)
111
+ end
85
112
  end
86
113
  end
@@ -98,9 +98,8 @@ describe Rdm::SourceParser do
98
98
  context "with undefined role" do
99
99
  it "puts warning message" do
100
100
  Rdm::Utils::FileUtils.change_file @rdm_source_file do |line|
101
- line.include?('env_file_name "production"') ? 'env_file_name "stading"' : line
101
+ line.include?("ENV['ENV_FILE'] || \"production\"") ? 'env_file_name "stading"' : line
102
102
  end
103
-
104
103
  subject.read_and_init_source(@rdm_source_file, stdout: stdout)
105
104
 
106
105
  expect(stdout.output).to include("WARNING! Environment file 'stading' was not found. Please, add /tmp/example/env_files/stading.env file...")
@@ -3,10 +3,68 @@ require 'spec_helper'
3
3
  describe Rdm::SpecRunner::Runner do
4
4
  include ExampleProjectHelper
5
5
 
6
- before { initialize_example_project }
7
- after { reset_example_project }
6
+ let(:stdout) { SpecLogger.new }
8
7
 
9
- it 'run some test' do
8
+ before { initialize_example_project }
9
+ after { reset_example_project }
10
10
 
11
+ describe "::run" do
12
+ it 'run all test without errors' do
13
+ expect{
14
+ described_class.new(
15
+ path: example_project_path,
16
+ package: nil,
17
+ spec_matcher: nil,
18
+ show_missing_packages: false,
19
+ skip_ignored_packages: false,
20
+ stdout: stdout,
21
+ show_output: false
22
+ ).run
23
+ }.not_to raise_error
24
+ end
25
+
26
+ it 'run tests for specified package without errors' do
27
+ expect{
28
+ described_class.new(
29
+ path: example_project_path,
30
+ package: 'repository',
31
+ spec_matcher: nil,
32
+ show_missing_packages: false,
33
+ skip_ignored_packages: false,
34
+ stdout: stdout,
35
+ show_output: false
36
+ ).run
37
+ }.not_to raise_error
38
+ end
39
+
40
+ it 'run tests for specified package and spec_matcher without errors' do
41
+ expect{
42
+ described_class.new(
43
+ path: example_project_path,
44
+ package: 'repository',
45
+ spec_matcher: 'example_spec.rb',
46
+ show_missing_packages: false,
47
+ skip_ignored_packages: false,
48
+ stdout: stdout,
49
+ show_output: false
50
+ ).run
51
+ }.not_to raise_error
52
+ end
53
+
54
+ it 'execute spec content' do
55
+ described_class.new(
56
+ path: example_project_path,
57
+ package: 'repository',
58
+ spec_matcher: 'example_spec.rb',
59
+ show_missing_packages: false,
60
+ skip_ignored_packages: false,
61
+ stdout: stdout,
62
+ show_output: false
63
+ ).run
64
+
65
+ expect(
66
+ File.read(File.join(example_project_path, 'infrastructure/repository/fixture.txt'))
67
+ ).to eq('Repository spec working here!')
68
+ end
11
69
  end
12
70
  end