crspec 0.1.0 → 0.1.1

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 (164) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +67 -17
  3. data/benchmark/README.md +56 -0
  4. data/benchmark/run.rb +72 -0
  5. data/benchmark/spec/user_service_crspec_spec.rb +15 -0
  6. data/benchmark/spec/user_service_rspec_spec.rb +16 -0
  7. data/benchmark/target_service.rb +12 -0
  8. data/benchmark/test/user_service_test.rb +18 -0
  9. data/demo.rb +6 -3
  10. data/lib/crspec/cli.rb +34 -3
  11. data/lib/crspec/configuration.rb +59 -0
  12. data/lib/crspec/example_group.rb +31 -0
  13. data/lib/crspec/execution_context.rb +1 -1
  14. data/lib/crspec/generators/init.rb +94 -0
  15. data/lib/crspec/matchers.rb +55 -0
  16. data/lib/crspec/mock/double.rb +8 -1
  17. data/lib/crspec/rails/database_isolation.rb +6 -15
  18. data/lib/crspec/rails/parallel.rb +1 -1
  19. data/lib/crspec/rails/request_helpers.rb +96 -0
  20. data/lib/crspec/transpiler/cli.rb +6 -6
  21. data/lib/crspec/version.rb +1 -1
  22. data/lib/crspec.rb +3 -0
  23. data/samples/book_store/.dockerignore +51 -0
  24. data/samples/book_store/.gitattributes +9 -0
  25. data/samples/book_store/.github/dependabot.yml +12 -0
  26. data/samples/book_store/.github/workflows/ci.yml +130 -0
  27. data/samples/book_store/.gitignore +35 -0
  28. data/samples/book_store/.kamal/hooks/docker-setup.sample +3 -0
  29. data/samples/book_store/.kamal/hooks/post-app-boot.sample +3 -0
  30. data/samples/book_store/.kamal/hooks/post-deploy.sample +14 -0
  31. data/samples/book_store/.kamal/hooks/post-proxy-reboot.sample +3 -0
  32. data/samples/book_store/.kamal/hooks/pre-app-boot.sample +3 -0
  33. data/samples/book_store/.kamal/hooks/pre-build.sample +51 -0
  34. data/samples/book_store/.kamal/hooks/pre-connect.sample +47 -0
  35. data/samples/book_store/.kamal/hooks/pre-deploy.sample +122 -0
  36. data/samples/book_store/.kamal/hooks/pre-proxy-reboot.sample +3 -0
  37. data/samples/book_store/.kamal/secrets +20 -0
  38. data/samples/book_store/.rubocop.yml +8 -0
  39. data/samples/book_store/.ruby-version +1 -0
  40. data/samples/book_store/Dockerfile +77 -0
  41. data/samples/book_store/Gemfile +67 -0
  42. data/samples/book_store/Gemfile.lock +572 -0
  43. data/samples/book_store/README.md +24 -0
  44. data/samples/book_store/Rakefile +6 -0
  45. data/samples/book_store/app/assets/images/.keep +0 -0
  46. data/samples/book_store/app/assets/stylesheets/application.css +10 -0
  47. data/samples/book_store/app/controllers/application_controller.rb +2 -0
  48. data/samples/book_store/app/controllers/books_controller.rb +30 -0
  49. data/samples/book_store/app/controllers/comments_controller.rb +21 -0
  50. data/samples/book_store/app/controllers/concerns/.keep +0 -0
  51. data/samples/book_store/app/controllers/users_controller.rb +21 -0
  52. data/samples/book_store/app/helpers/application_helper.rb +2 -0
  53. data/samples/book_store/app/helpers/books_helper.rb +2 -0
  54. data/samples/book_store/app/helpers/comments_helper.rb +2 -0
  55. data/samples/book_store/app/helpers/users_helper.rb +2 -0
  56. data/samples/book_store/app/javascript/application.js +3 -0
  57. data/samples/book_store/app/javascript/controllers/application.js +9 -0
  58. data/samples/book_store/app/javascript/controllers/hello_controller.js +7 -0
  59. data/samples/book_store/app/javascript/controllers/index.js +4 -0
  60. data/samples/book_store/app/jobs/application_job.rb +7 -0
  61. data/samples/book_store/app/mailers/application_mailer.rb +4 -0
  62. data/samples/book_store/app/models/application_record.rb +3 -0
  63. data/samples/book_store/app/models/book.rb +10 -0
  64. data/samples/book_store/app/models/comment.rb +6 -0
  65. data/samples/book_store/app/models/concerns/.keep +0 -0
  66. data/samples/book_store/app/models/user.rb +4 -0
  67. data/samples/book_store/app/views/layouts/application.html.erb +29 -0
  68. data/samples/book_store/app/views/layouts/mailer.html.erb +13 -0
  69. data/samples/book_store/app/views/layouts/mailer.text.erb +1 -0
  70. data/samples/book_store/app/views/pwa/manifest.json.erb +22 -0
  71. data/samples/book_store/app/views/pwa/service-worker.js +26 -0
  72. data/samples/book_store/bin/brakeman +7 -0
  73. data/samples/book_store/bin/bundler-audit +6 -0
  74. data/samples/book_store/bin/ci +6 -0
  75. data/samples/book_store/bin/dev +2 -0
  76. data/samples/book_store/bin/docker-entrypoint +8 -0
  77. data/samples/book_store/bin/importmap +4 -0
  78. data/samples/book_store/bin/jobs +6 -0
  79. data/samples/book_store/bin/kamal +16 -0
  80. data/samples/book_store/bin/rails +4 -0
  81. data/samples/book_store/bin/rake +4 -0
  82. data/samples/book_store/bin/rubocop +8 -0
  83. data/samples/book_store/bin/setup +35 -0
  84. data/samples/book_store/bin/thrust +5 -0
  85. data/samples/book_store/config/application.rb +27 -0
  86. data/samples/book_store/config/boot.rb +4 -0
  87. data/samples/book_store/config/bundler-audit.yml +5 -0
  88. data/samples/book_store/config/cable.yml +17 -0
  89. data/samples/book_store/config/cache.yml +16 -0
  90. data/samples/book_store/config/ci.rb +24 -0
  91. data/samples/book_store/config/credentials.yml.enc +1 -0
  92. data/samples/book_store/config/database.yml +45 -0
  93. data/samples/book_store/config/deploy.yml +119 -0
  94. data/samples/book_store/config/environment.rb +5 -0
  95. data/samples/book_store/config/environments/development.rb +78 -0
  96. data/samples/book_store/config/environments/production.rb +90 -0
  97. data/samples/book_store/config/environments/test.rb +53 -0
  98. data/samples/book_store/config/importmap.rb +7 -0
  99. data/samples/book_store/config/initializers/assets.rb +7 -0
  100. data/samples/book_store/config/initializers/content_security_policy.rb +29 -0
  101. data/samples/book_store/config/initializers/filter_parameter_logging.rb +8 -0
  102. data/samples/book_store/config/initializers/inflections.rb +16 -0
  103. data/samples/book_store/config/locales/en.yml +31 -0
  104. data/samples/book_store/config/puma.rb +42 -0
  105. data/samples/book_store/config/queue.yml +18 -0
  106. data/samples/book_store/config/recurring.yml +15 -0
  107. data/samples/book_store/config/routes.rb +17 -0
  108. data/samples/book_store/config/storage.yml +27 -0
  109. data/samples/book_store/config.ru +6 -0
  110. data/samples/book_store/db/cable_schema.rb +11 -0
  111. data/samples/book_store/db/cache_schema.rb +12 -0
  112. data/samples/book_store/db/migrate/20260731035441_create_users.rb +10 -0
  113. data/samples/book_store/db/migrate/20260731035506_create_books.rb +11 -0
  114. data/samples/book_store/db/migrate/20260731035528_create_comments.rb +11 -0
  115. data/samples/book_store/db/queue_schema.rb +129 -0
  116. data/samples/book_store/db/schema.rb +39 -0
  117. data/samples/book_store/db/seeds.rb +9 -0
  118. data/samples/book_store/lib/tasks/.keep +0 -0
  119. data/samples/book_store/log/.keep +0 -0
  120. data/samples/book_store/public/400.html +135 -0
  121. data/samples/book_store/public/404.html +135 -0
  122. data/samples/book_store/public/406-unsupported-browser.html +135 -0
  123. data/samples/book_store/public/422.html +135 -0
  124. data/samples/book_store/public/500.html +135 -0
  125. data/samples/book_store/public/icon.png +0 -0
  126. data/samples/book_store/public/icon.svg +3 -0
  127. data/samples/book_store/public/robots.txt +1 -0
  128. data/samples/book_store/script/.keep +0 -0
  129. data/samples/book_store/spec/models/book_spec.rb +42 -0
  130. data/samples/book_store/spec/models/comment_spec.rb +22 -0
  131. data/samples/book_store/spec/models/user_advanced_spec.rb +27 -0
  132. data/samples/book_store/spec/models/user_spec.rb +30 -0
  133. data/samples/book_store/spec/rails_helper.rb +36 -0
  134. data/samples/book_store/spec/rails_parallel_spec.rb +23 -0
  135. data/samples/book_store/spec/requests/books_spec.rb +21 -0
  136. data/samples/book_store/spec/requests/users_spec.rb +14 -0
  137. data/samples/book_store/spec/services/inventory_service_spec.rb +28 -0
  138. data/samples/book_store/spec/services/time_dependent_service_spec.rb +26 -0
  139. data/samples/book_store/spec/spec_helper.rb +16 -0
  140. data/samples/book_store/spec/system/book_store_system_spec.rb +18 -0
  141. data/samples/book_store/storage/.keep +0 -0
  142. data/samples/book_store/test/controllers/.keep +0 -0
  143. data/samples/book_store/test/controllers/books_controller_test.rb +7 -0
  144. data/samples/book_store/test/controllers/comments_controller_test.rb +7 -0
  145. data/samples/book_store/test/controllers/users_controller_test.rb +7 -0
  146. data/samples/book_store/test/fixtures/books.yml +11 -0
  147. data/samples/book_store/test/fixtures/comments.yml +11 -0
  148. data/samples/book_store/test/fixtures/files/.keep +0 -0
  149. data/samples/book_store/test/fixtures/users.yml +9 -0
  150. data/samples/book_store/test/helpers/.keep +0 -0
  151. data/samples/book_store/test/integration/.keep +0 -0
  152. data/samples/book_store/test/mailers/.keep +0 -0
  153. data/samples/book_store/test/models/.keep +0 -0
  154. data/samples/book_store/test/models/book_test.rb +7 -0
  155. data/samples/book_store/test/models/comment_test.rb +7 -0
  156. data/samples/book_store/test/models/user_test.rb +7 -0
  157. data/samples/book_store/test/test_helper.rb +15 -0
  158. data/samples/book_store/tmp/.keep +0 -0
  159. data/samples/book_store/tmp/pids/.keep +0 -0
  160. data/samples/book_store/tmp/storage/.keep +0 -0
  161. data/samples/book_store/vendor/.keep +0 -0
  162. data/samples/book_store/vendor/javascript/.keep +0 -0
  163. data/test/crspec/configuration_test.rb +76 -0
  164. metadata +152 -2
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+ require "tmpdir"
5
+
6
+ class ConfigurationTest < Minitest::Test
7
+ def setup
8
+ Crspec.reset_configuration!
9
+ end
10
+
11
+ def teardown
12
+ Crspec.reset_configuration!
13
+ end
14
+
15
+ def test_configuration_hooks_and_module_inclusion
16
+ helper_module = Module.new do
17
+ def custom_helper_method
18
+ "helper_ok"
19
+ end
20
+ end
21
+
22
+ before_called = false
23
+ after_called = false
24
+
25
+ Crspec.configure do |config|
26
+ config.include(helper_module)
27
+ config.before(:each) { before_called = true }
28
+ config.after(:each) { after_called = true }
29
+ end
30
+
31
+ group = Crspec.describe "Configured Group" do
32
+ it "uses included module and runs global hooks" do
33
+ expect(custom_helper_method).to eq("helper_ok")
34
+ end
35
+ end
36
+
37
+ runner = Crspec::Runner.new(concurrency: 1, formatter: Crspec::Formatters::NullFormatter.new)
38
+ runner.run([group])
39
+
40
+ assert runner.success?
41
+ assert before_called
42
+ assert after_called
43
+ end
44
+
45
+ def test_init_generator_in_non_rails_project_creates_only_spec_helper
46
+ Dir.mktmpdir do |dir|
47
+ spec_dir = File.join(dir, "spec")
48
+ created = Crspec::Generators::Init.generate(spec_dir, dir)
49
+
50
+ assert_equal 1, created.size
51
+ assert File.exist?(File.join(spec_dir, "spec_helper.rb"))
52
+ refute File.exist?(File.join(spec_dir, "rails_helper.rb"))
53
+
54
+ spec_helper_content = File.read(File.join(spec_dir, "spec_helper.rb"))
55
+ assert_includes spec_helper_content, "Crspec.configure"
56
+ end
57
+ end
58
+
59
+ def test_init_generator_in_rails_project_creates_both_helpers
60
+ Dir.mktmpdir do |dir|
61
+ FileUtils.mkdir_p(File.join(dir, "config"))
62
+ File.write(File.join(dir, "config", "application.rb"), "# Rails app")
63
+
64
+ spec_dir = File.join(dir, "spec")
65
+ created = Crspec::Generators::Init.generate(spec_dir, dir)
66
+
67
+ assert_equal 2, created.size
68
+ assert File.exist?(File.join(spec_dir, "spec_helper.rb"))
69
+ assert File.exist?(File.join(spec_dir, "rails_helper.rb"))
70
+
71
+ rails_helper_content = File.read(File.join(spec_dir, "rails_helper.rb"))
72
+ assert_includes rails_helper_content, "require_relative \"spec_helper\""
73
+ assert_includes rails_helper_content, "DatabaseIsolation.wrap_example"
74
+ end
75
+ end
76
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aboobacker MK
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-07-29 00:00:00.000000000 Z
11
+ date: 2026-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prism
@@ -38,30 +38,180 @@ files:
38
38
  - LICENSE.txt
39
39
  - README.md
40
40
  - Rakefile
41
+ - benchmark/README.md
42
+ - benchmark/run.rb
43
+ - benchmark/spec/user_service_crspec_spec.rb
44
+ - benchmark/spec/user_service_rspec_spec.rb
45
+ - benchmark/target_service.rb
46
+ - benchmark/test/user_service_test.rb
41
47
  - demo.rb
42
48
  - exe/crspec
43
49
  - exe/crspec-transpile
44
50
  - lib/crspec.rb
45
51
  - lib/crspec/cli.rb
52
+ - lib/crspec/configuration.rb
46
53
  - lib/crspec/dsl.rb
47
54
  - lib/crspec/example.rb
48
55
  - lib/crspec/example_group.rb
49
56
  - lib/crspec/execution_context.rb
50
57
  - lib/crspec/expectations.rb
51
58
  - lib/crspec/formatters/progress_formatter.rb
59
+ - lib/crspec/generators/init.rb
52
60
  - lib/crspec/matchers.rb
53
61
  - lib/crspec/mock/double.rb
54
62
  - lib/crspec/mock/interceptor.rb
55
63
  - lib/crspec/mock/space.rb
56
64
  - lib/crspec/rails/database_isolation.rb
57
65
  - lib/crspec/rails/parallel.rb
66
+ - lib/crspec/rails/request_helpers.rb
58
67
  - lib/crspec/rails/system_server.rb
59
68
  - lib/crspec/runner.rb
60
69
  - lib/crspec/transpiler/cli.rb
61
70
  - lib/crspec/transpiler/rewriter.rb
62
71
  - lib/crspec/version.rb
72
+ - samples/book_store/.dockerignore
73
+ - samples/book_store/.gitattributes
74
+ - samples/book_store/.github/dependabot.yml
75
+ - samples/book_store/.github/workflows/ci.yml
76
+ - samples/book_store/.gitignore
77
+ - samples/book_store/.kamal/hooks/docker-setup.sample
78
+ - samples/book_store/.kamal/hooks/post-app-boot.sample
79
+ - samples/book_store/.kamal/hooks/post-deploy.sample
80
+ - samples/book_store/.kamal/hooks/post-proxy-reboot.sample
81
+ - samples/book_store/.kamal/hooks/pre-app-boot.sample
82
+ - samples/book_store/.kamal/hooks/pre-build.sample
83
+ - samples/book_store/.kamal/hooks/pre-connect.sample
84
+ - samples/book_store/.kamal/hooks/pre-deploy.sample
85
+ - samples/book_store/.kamal/hooks/pre-proxy-reboot.sample
86
+ - samples/book_store/.kamal/secrets
87
+ - samples/book_store/.rubocop.yml
88
+ - samples/book_store/.ruby-version
89
+ - samples/book_store/Dockerfile
90
+ - samples/book_store/Gemfile
91
+ - samples/book_store/Gemfile.lock
92
+ - samples/book_store/README.md
93
+ - samples/book_store/Rakefile
94
+ - samples/book_store/app/assets/images/.keep
95
+ - samples/book_store/app/assets/stylesheets/application.css
96
+ - samples/book_store/app/controllers/application_controller.rb
97
+ - samples/book_store/app/controllers/books_controller.rb
98
+ - samples/book_store/app/controllers/comments_controller.rb
99
+ - samples/book_store/app/controllers/concerns/.keep
100
+ - samples/book_store/app/controllers/users_controller.rb
101
+ - samples/book_store/app/helpers/application_helper.rb
102
+ - samples/book_store/app/helpers/books_helper.rb
103
+ - samples/book_store/app/helpers/comments_helper.rb
104
+ - samples/book_store/app/helpers/users_helper.rb
105
+ - samples/book_store/app/javascript/application.js
106
+ - samples/book_store/app/javascript/controllers/application.js
107
+ - samples/book_store/app/javascript/controllers/hello_controller.js
108
+ - samples/book_store/app/javascript/controllers/index.js
109
+ - samples/book_store/app/jobs/application_job.rb
110
+ - samples/book_store/app/mailers/application_mailer.rb
111
+ - samples/book_store/app/models/application_record.rb
112
+ - samples/book_store/app/models/book.rb
113
+ - samples/book_store/app/models/comment.rb
114
+ - samples/book_store/app/models/concerns/.keep
115
+ - samples/book_store/app/models/user.rb
116
+ - samples/book_store/app/views/layouts/application.html.erb
117
+ - samples/book_store/app/views/layouts/mailer.html.erb
118
+ - samples/book_store/app/views/layouts/mailer.text.erb
119
+ - samples/book_store/app/views/pwa/manifest.json.erb
120
+ - samples/book_store/app/views/pwa/service-worker.js
121
+ - samples/book_store/bin/brakeman
122
+ - samples/book_store/bin/bundler-audit
123
+ - samples/book_store/bin/ci
124
+ - samples/book_store/bin/dev
125
+ - samples/book_store/bin/docker-entrypoint
126
+ - samples/book_store/bin/importmap
127
+ - samples/book_store/bin/jobs
128
+ - samples/book_store/bin/kamal
129
+ - samples/book_store/bin/rails
130
+ - samples/book_store/bin/rake
131
+ - samples/book_store/bin/rubocop
132
+ - samples/book_store/bin/setup
133
+ - samples/book_store/bin/thrust
134
+ - samples/book_store/config.ru
135
+ - samples/book_store/config/application.rb
136
+ - samples/book_store/config/boot.rb
137
+ - samples/book_store/config/bundler-audit.yml
138
+ - samples/book_store/config/cable.yml
139
+ - samples/book_store/config/cache.yml
140
+ - samples/book_store/config/ci.rb
141
+ - samples/book_store/config/credentials.yml.enc
142
+ - samples/book_store/config/database.yml
143
+ - samples/book_store/config/deploy.yml
144
+ - samples/book_store/config/environment.rb
145
+ - samples/book_store/config/environments/development.rb
146
+ - samples/book_store/config/environments/production.rb
147
+ - samples/book_store/config/environments/test.rb
148
+ - samples/book_store/config/importmap.rb
149
+ - samples/book_store/config/initializers/assets.rb
150
+ - samples/book_store/config/initializers/content_security_policy.rb
151
+ - samples/book_store/config/initializers/filter_parameter_logging.rb
152
+ - samples/book_store/config/initializers/inflections.rb
153
+ - samples/book_store/config/locales/en.yml
154
+ - samples/book_store/config/puma.rb
155
+ - samples/book_store/config/queue.yml
156
+ - samples/book_store/config/recurring.yml
157
+ - samples/book_store/config/routes.rb
158
+ - samples/book_store/config/storage.yml
159
+ - samples/book_store/db/cable_schema.rb
160
+ - samples/book_store/db/cache_schema.rb
161
+ - samples/book_store/db/migrate/20260731035441_create_users.rb
162
+ - samples/book_store/db/migrate/20260731035506_create_books.rb
163
+ - samples/book_store/db/migrate/20260731035528_create_comments.rb
164
+ - samples/book_store/db/queue_schema.rb
165
+ - samples/book_store/db/schema.rb
166
+ - samples/book_store/db/seeds.rb
167
+ - samples/book_store/lib/tasks/.keep
168
+ - samples/book_store/log/.keep
169
+ - samples/book_store/public/400.html
170
+ - samples/book_store/public/404.html
171
+ - samples/book_store/public/406-unsupported-browser.html
172
+ - samples/book_store/public/422.html
173
+ - samples/book_store/public/500.html
174
+ - samples/book_store/public/icon.png
175
+ - samples/book_store/public/icon.svg
176
+ - samples/book_store/public/robots.txt
177
+ - samples/book_store/script/.keep
178
+ - samples/book_store/spec/models/book_spec.rb
179
+ - samples/book_store/spec/models/comment_spec.rb
180
+ - samples/book_store/spec/models/user_advanced_spec.rb
181
+ - samples/book_store/spec/models/user_spec.rb
182
+ - samples/book_store/spec/rails_helper.rb
183
+ - samples/book_store/spec/rails_parallel_spec.rb
184
+ - samples/book_store/spec/requests/books_spec.rb
185
+ - samples/book_store/spec/requests/users_spec.rb
186
+ - samples/book_store/spec/services/inventory_service_spec.rb
187
+ - samples/book_store/spec/services/time_dependent_service_spec.rb
188
+ - samples/book_store/spec/spec_helper.rb
189
+ - samples/book_store/spec/system/book_store_system_spec.rb
190
+ - samples/book_store/storage/.keep
191
+ - samples/book_store/test/controllers/.keep
192
+ - samples/book_store/test/controllers/books_controller_test.rb
193
+ - samples/book_store/test/controllers/comments_controller_test.rb
194
+ - samples/book_store/test/controllers/users_controller_test.rb
195
+ - samples/book_store/test/fixtures/books.yml
196
+ - samples/book_store/test/fixtures/comments.yml
197
+ - samples/book_store/test/fixtures/files/.keep
198
+ - samples/book_store/test/fixtures/users.yml
199
+ - samples/book_store/test/helpers/.keep
200
+ - samples/book_store/test/integration/.keep
201
+ - samples/book_store/test/mailers/.keep
202
+ - samples/book_store/test/models/.keep
203
+ - samples/book_store/test/models/book_test.rb
204
+ - samples/book_store/test/models/comment_test.rb
205
+ - samples/book_store/test/models/user_test.rb
206
+ - samples/book_store/test/test_helper.rb
207
+ - samples/book_store/tmp/.keep
208
+ - samples/book_store/tmp/pids/.keep
209
+ - samples/book_store/tmp/storage/.keep
210
+ - samples/book_store/vendor/.keep
211
+ - samples/book_store/vendor/javascript/.keep
63
212
  - samples/user_spec.rb
64
213
  - sig/crspec.rbs
214
+ - test/crspec/configuration_test.rb
65
215
  - test/crspec/execution_context_test.rb
66
216
  - test/crspec/mock_test.rb
67
217
  - test/crspec/rails_test.rb