Skip to content

Commit

Permalink
Present the bug
Browse files Browse the repository at this point in the history
  • Loading branch information
morgoth committed Mar 21, 2022
1 parent 3b205b0 commit ed3a76c
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 18 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ gem "puma", "~> 5.0"
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]

gem "async"

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]
Expand All @@ -27,4 +29,3 @@ group :development do
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"
end

10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,27 @@ GEM
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
async (2.0.1)
console (~> 1.10)
io-event (~> 1.0.0)
timers (~> 4.1)
builder (3.2.4)
concurrent-ruby (1.1.9)
console (1.14.0)
fiber-local
crass (1.0.6)
debug (1.4.0)
irb (>= 1.3.6)
reline (>= 0.2.7)
digest (3.1.0)
erubi (1.10.0)
fiber-local (1.0.0)
globalid (1.0.0)
activesupport (>= 5.0)
i18n (1.10.0)
concurrent-ruby (~> 1.0)
io-console (0.5.11)
io-event (1.0.5)
io-wait (0.2.1)
irb (1.4.1)
reline (>= 0.3.0)
Expand Down Expand Up @@ -155,6 +163,7 @@ GEM
strscan (3.0.1)
thor (1.2.1)
timeout (0.2.0)
timers (4.3.3)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
websocket-driver (0.7.5)
Expand All @@ -166,6 +175,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
async
debug
puma (~> 5.0)
rails (~> 7.0.2, >= 7.0.2.3)
Expand Down
31 changes: 15 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# README

This README would normally document whatever steps are necessary to get the
application up and running.
Run `rails t test/models/my_model_test.rb`

Things you may want to cover:
The output is:

* Ruby version
```
r t test/models/my_model_test.rb
Running 1 tests in a single process (parallelization threshold is 50)
Run options: --seed 2478
* System dependencies
# Running:
* Configuration
uninitialized constant MyModelTest::MyModel
* Database creation
MyModel.run_something
^^^^^^^
uninitialized constant MyModelTest::MyModel
* Database initialization

* How to run the test suite

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...
MyModel.run_something
^^^^^^^
something
```
5 changes: 5 additions & 0 deletions app/models/my_model.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class MyModel
def self.run_something
puts "something"
end
end
2 changes: 1 addition & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# Eager loading loads your whole application. When running a single test locally,
# this probably isn't necessary. It's a good idea to do in a continuous integration
# system, or in some way before deploying your code.
config.eager_load = ENV["CI"].present?
config.eager_load = false # Setting to true fixes the test failure

# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
Expand Down
15 changes: 15 additions & 0 deletions test/models/my_model_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require "test_helper"

class MyModelTest < ActiveSupport::TestCase
test "async run" do
Async do |task|
3.times do |i|
task.async do
MyModel.run_something
rescue => e
puts e
end
end
end.wait
end
end

0 comments on commit ed3a76c

Please sign in to comment.