crspec 0.1.1 → 0.1.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +86 -0
- data/README.md +1 -1
- data/lib/crspec/cli.rb +86 -5
- data/lib/crspec/configuration.rb +62 -9
- data/lib/crspec/dsl.rb +66 -2
- data/lib/crspec/example.rb +60 -6
- data/lib/crspec/example_group.rb +363 -63
- data/lib/crspec/execution_context.rb +10 -6
- data/lib/crspec/expectations.rb +62 -2
- data/lib/crspec/file_fixtures.rb +18 -0
- data/lib/crspec/formatters/progress_formatter.rb +37 -14
- data/lib/crspec/matchers.rb +642 -0
- data/lib/crspec/mock/argument_matchers.rb +157 -0
- data/lib/crspec/mock/double.rb +246 -13
- data/lib/crspec/mock/interceptor.rb +32 -9
- data/lib/crspec/mock/space.rb +14 -0
- data/lib/crspec/process_runner.rb +332 -0
- data/lib/crspec/rails/assets_shim.rb +33 -0
- data/lib/crspec/rails/database_isolation.rb +179 -8
- data/lib/crspec/rails/parallel.rb +29 -29
- data/lib/crspec/rails/request_helpers.rb +70 -14
- data/lib/crspec/rails/system_server.rb +7 -0
- data/lib/crspec/rails/warden_shim.rb +18 -0
- data/lib/crspec/runner.rb +143 -29
- data/lib/crspec/shared_examples.rb +70 -0
- data/lib/crspec/status_persistence.rb +46 -0
- data/lib/crspec/transpiler/cli.rb +106 -15
- data/lib/crspec/transpiler/rewriter.rb +179 -25
- data/lib/crspec/version.rb +1 -1
- data/lib/crspec.rb +6 -0
- data/lib/rspec/core.rb +2 -0
- data/lib/rspec/expectations.rb +2 -0
- data/lib/rspec/mocks.rb +2 -0
- data/lib/rspec/rails.rb +2 -0
- data/lib/rspec.rb +2 -0
- metadata +27 -156
- data/benchmark/README.md +0 -56
- data/benchmark/run.rb +0 -72
- data/benchmark/spec/user_service_crspec_spec.rb +0 -15
- data/benchmark/spec/user_service_rspec_spec.rb +0 -16
- data/benchmark/target_service.rb +0 -12
- data/benchmark/test/user_service_test.rb +0 -18
- data/demo.rb +0 -129
- data/samples/book_store/.dockerignore +0 -51
- data/samples/book_store/.gitattributes +0 -9
- data/samples/book_store/.github/dependabot.yml +0 -12
- data/samples/book_store/.github/workflows/ci.yml +0 -130
- data/samples/book_store/.gitignore +0 -35
- data/samples/book_store/.kamal/hooks/docker-setup.sample +0 -3
- data/samples/book_store/.kamal/hooks/post-app-boot.sample +0 -3
- data/samples/book_store/.kamal/hooks/post-deploy.sample +0 -14
- data/samples/book_store/.kamal/hooks/post-proxy-reboot.sample +0 -3
- data/samples/book_store/.kamal/hooks/pre-app-boot.sample +0 -3
- data/samples/book_store/.kamal/hooks/pre-build.sample +0 -51
- data/samples/book_store/.kamal/hooks/pre-connect.sample +0 -47
- data/samples/book_store/.kamal/hooks/pre-deploy.sample +0 -122
- data/samples/book_store/.kamal/hooks/pre-proxy-reboot.sample +0 -3
- data/samples/book_store/.kamal/secrets +0 -20
- data/samples/book_store/.rubocop.yml +0 -8
- data/samples/book_store/.ruby-version +0 -1
- data/samples/book_store/Dockerfile +0 -77
- data/samples/book_store/Gemfile +0 -67
- data/samples/book_store/Gemfile.lock +0 -572
- data/samples/book_store/README.md +0 -24
- data/samples/book_store/Rakefile +0 -6
- data/samples/book_store/app/assets/images/.keep +0 -0
- data/samples/book_store/app/assets/stylesheets/application.css +0 -10
- data/samples/book_store/app/controllers/application_controller.rb +0 -2
- data/samples/book_store/app/controllers/books_controller.rb +0 -30
- data/samples/book_store/app/controllers/comments_controller.rb +0 -21
- data/samples/book_store/app/controllers/concerns/.keep +0 -0
- data/samples/book_store/app/controllers/users_controller.rb +0 -21
- data/samples/book_store/app/helpers/application_helper.rb +0 -2
- data/samples/book_store/app/helpers/books_helper.rb +0 -2
- data/samples/book_store/app/helpers/comments_helper.rb +0 -2
- data/samples/book_store/app/helpers/users_helper.rb +0 -2
- data/samples/book_store/app/javascript/application.js +0 -3
- data/samples/book_store/app/javascript/controllers/application.js +0 -9
- data/samples/book_store/app/javascript/controllers/hello_controller.js +0 -7
- data/samples/book_store/app/javascript/controllers/index.js +0 -4
- data/samples/book_store/app/jobs/application_job.rb +0 -7
- data/samples/book_store/app/mailers/application_mailer.rb +0 -4
- data/samples/book_store/app/models/application_record.rb +0 -3
- data/samples/book_store/app/models/book.rb +0 -10
- data/samples/book_store/app/models/comment.rb +0 -6
- data/samples/book_store/app/models/concerns/.keep +0 -0
- data/samples/book_store/app/models/user.rb +0 -4
- data/samples/book_store/app/views/layouts/application.html.erb +0 -29
- data/samples/book_store/app/views/layouts/mailer.html.erb +0 -13
- data/samples/book_store/app/views/layouts/mailer.text.erb +0 -1
- data/samples/book_store/app/views/pwa/manifest.json.erb +0 -22
- data/samples/book_store/app/views/pwa/service-worker.js +0 -26
- data/samples/book_store/bin/brakeman +0 -7
- data/samples/book_store/bin/bundler-audit +0 -6
- data/samples/book_store/bin/ci +0 -6
- data/samples/book_store/bin/dev +0 -2
- data/samples/book_store/bin/docker-entrypoint +0 -8
- data/samples/book_store/bin/importmap +0 -4
- data/samples/book_store/bin/jobs +0 -6
- data/samples/book_store/bin/kamal +0 -16
- data/samples/book_store/bin/rails +0 -4
- data/samples/book_store/bin/rake +0 -4
- data/samples/book_store/bin/rubocop +0 -8
- data/samples/book_store/bin/setup +0 -35
- data/samples/book_store/bin/thrust +0 -5
- data/samples/book_store/config/application.rb +0 -27
- data/samples/book_store/config/boot.rb +0 -4
- data/samples/book_store/config/bundler-audit.yml +0 -5
- data/samples/book_store/config/cable.yml +0 -17
- data/samples/book_store/config/cache.yml +0 -16
- data/samples/book_store/config/ci.rb +0 -24
- data/samples/book_store/config/credentials.yml.enc +0 -1
- data/samples/book_store/config/database.yml +0 -45
- data/samples/book_store/config/deploy.yml +0 -119
- data/samples/book_store/config/environment.rb +0 -5
- data/samples/book_store/config/environments/development.rb +0 -78
- data/samples/book_store/config/environments/production.rb +0 -90
- data/samples/book_store/config/environments/test.rb +0 -53
- data/samples/book_store/config/importmap.rb +0 -7
- data/samples/book_store/config/initializers/assets.rb +0 -7
- data/samples/book_store/config/initializers/content_security_policy.rb +0 -29
- data/samples/book_store/config/initializers/filter_parameter_logging.rb +0 -8
- data/samples/book_store/config/initializers/inflections.rb +0 -16
- data/samples/book_store/config/locales/en.yml +0 -31
- data/samples/book_store/config/puma.rb +0 -42
- data/samples/book_store/config/queue.yml +0 -18
- data/samples/book_store/config/recurring.yml +0 -15
- data/samples/book_store/config/routes.rb +0 -17
- data/samples/book_store/config/storage.yml +0 -27
- data/samples/book_store/config.ru +0 -6
- data/samples/book_store/db/cable_schema.rb +0 -11
- data/samples/book_store/db/cache_schema.rb +0 -12
- data/samples/book_store/db/migrate/20260731035441_create_users.rb +0 -10
- data/samples/book_store/db/migrate/20260731035506_create_books.rb +0 -11
- data/samples/book_store/db/migrate/20260731035528_create_comments.rb +0 -11
- data/samples/book_store/db/queue_schema.rb +0 -129
- data/samples/book_store/db/schema.rb +0 -39
- data/samples/book_store/db/seeds.rb +0 -9
- data/samples/book_store/lib/tasks/.keep +0 -0
- data/samples/book_store/log/.keep +0 -0
- data/samples/book_store/public/400.html +0 -135
- data/samples/book_store/public/404.html +0 -135
- data/samples/book_store/public/406-unsupported-browser.html +0 -135
- data/samples/book_store/public/422.html +0 -135
- data/samples/book_store/public/500.html +0 -135
- data/samples/book_store/public/icon.png +0 -0
- data/samples/book_store/public/icon.svg +0 -3
- data/samples/book_store/public/robots.txt +0 -1
- data/samples/book_store/script/.keep +0 -0
- data/samples/book_store/spec/models/book_spec.rb +0 -42
- data/samples/book_store/spec/models/comment_spec.rb +0 -22
- data/samples/book_store/spec/models/user_advanced_spec.rb +0 -27
- data/samples/book_store/spec/models/user_spec.rb +0 -30
- data/samples/book_store/spec/rails_helper.rb +0 -36
- data/samples/book_store/spec/rails_parallel_spec.rb +0 -23
- data/samples/book_store/spec/requests/books_spec.rb +0 -21
- data/samples/book_store/spec/requests/users_spec.rb +0 -14
- data/samples/book_store/spec/services/inventory_service_spec.rb +0 -28
- data/samples/book_store/spec/services/time_dependent_service_spec.rb +0 -26
- data/samples/book_store/spec/spec_helper.rb +0 -16
- data/samples/book_store/spec/system/book_store_system_spec.rb +0 -18
- data/samples/book_store/storage/.keep +0 -0
- data/samples/book_store/test/controllers/.keep +0 -0
- data/samples/book_store/test/controllers/books_controller_test.rb +0 -7
- data/samples/book_store/test/controllers/comments_controller_test.rb +0 -7
- data/samples/book_store/test/controllers/users_controller_test.rb +0 -7
- data/samples/book_store/test/fixtures/books.yml +0 -11
- data/samples/book_store/test/fixtures/comments.yml +0 -11
- data/samples/book_store/test/fixtures/files/.keep +0 -0
- data/samples/book_store/test/fixtures/users.yml +0 -9
- data/samples/book_store/test/helpers/.keep +0 -0
- data/samples/book_store/test/integration/.keep +0 -0
- data/samples/book_store/test/mailers/.keep +0 -0
- data/samples/book_store/test/models/.keep +0 -0
- data/samples/book_store/test/models/book_test.rb +0 -7
- data/samples/book_store/test/models/comment_test.rb +0 -7
- data/samples/book_store/test/models/user_test.rb +0 -7
- data/samples/book_store/test/test_helper.rb +0 -15
- data/samples/book_store/tmp/.keep +0 -0
- data/samples/book_store/tmp/pids/.keep +0 -0
- data/samples/book_store/tmp/storage/.keep +0 -0
- data/samples/book_store/vendor/.keep +0 -0
- data/samples/book_store/vendor/javascript/.keep +0 -0
- data/samples/user_spec.rb +0 -31
- data/test/crspec/configuration_test.rb +0 -76
- data/test/crspec/execution_context_test.rb +0 -61
- data/test/crspec/mock_test.rb +0 -55
- data/test/crspec/rails_test.rb +0 -62
- data/test/crspec/runner_test.rb +0 -68
- data/test/crspec/transpiler_test.rb +0 -41
- data/test/test_helper.rb +0 -6
|
@@ -3,39 +3,62 @@
|
|
|
3
3
|
module Crspec
|
|
4
4
|
module Formatters
|
|
5
5
|
class ProgressFormatter
|
|
6
|
+
FLUSH_THRESHOLD = 64
|
|
7
|
+
FLUSH_INTERVAL = 0.2
|
|
8
|
+
|
|
6
9
|
def initialize(output = $stdout, color: output.respond_to?(:tty?) && output.tty?)
|
|
7
10
|
@output = output
|
|
8
11
|
@color = color
|
|
9
12
|
@mutex = Mutex.new
|
|
13
|
+
@buffer = +""
|
|
14
|
+
@last_flush = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
10
15
|
end
|
|
11
16
|
|
|
12
17
|
def example_passed(_example)
|
|
13
|
-
@
|
|
14
|
-
@output.print @color ? "\e[32m.\e[0m" : "."
|
|
15
|
-
@output.flush
|
|
16
|
-
end
|
|
18
|
+
record(@color ? "\e[32m.\e[0m" : ".")
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
def example_failed(_example)
|
|
20
|
-
@
|
|
21
|
-
@output.print @color ? "\e[31mF\e[0m" : "F"
|
|
22
|
-
@output.flush
|
|
23
|
-
end
|
|
22
|
+
record(@color ? "\e[31mF\e[0m" : "F")
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
def example_pending(_example)
|
|
27
|
-
@
|
|
28
|
-
@output.print @color ? "\e[33m*\e[0m" : "*"
|
|
29
|
-
@output.flush
|
|
30
|
-
end
|
|
26
|
+
record(@color ? "\e[33m*\e[0m" : "*")
|
|
31
27
|
end
|
|
32
28
|
|
|
33
|
-
def start
|
|
29
|
+
def start
|
|
30
|
+
@last_flush = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
31
|
+
end
|
|
34
32
|
|
|
35
33
|
def finish
|
|
34
|
+
chunk = @mutex.synchronize { swap_buffer }
|
|
35
|
+
@output.print(chunk) unless chunk.empty?
|
|
36
|
+
@output.puts
|
|
37
|
+
@output.flush
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def record(token)
|
|
43
|
+
chunk = nil
|
|
36
44
|
@mutex.synchronize do
|
|
37
|
-
@
|
|
45
|
+
@buffer << token
|
|
46
|
+
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
47
|
+
if @buffer.size >= FLUSH_THRESHOLD || now - @last_flush >= FLUSH_INTERVAL
|
|
48
|
+
@last_flush = now
|
|
49
|
+
chunk = swap_buffer
|
|
50
|
+
end
|
|
38
51
|
end
|
|
52
|
+
return unless chunk
|
|
53
|
+
|
|
54
|
+
@output.print(chunk)
|
|
55
|
+
@output.flush
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def swap_buffer
|
|
59
|
+
chunk = @buffer
|
|
60
|
+
@buffer = +""
|
|
61
|
+
chunk
|
|
39
62
|
end
|
|
40
63
|
end
|
|
41
64
|
|