Skip to content

Commit 0db5c3e

Browse files
committed
test: Setup Bullet gem
1 parent 1a5879c commit 0db5c3e

5 files changed

Lines changed: 30 additions & 10 deletions

File tree

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ end
4444
gem 'concurrent-ruby', '1.3.4'
4545

4646
gem 'bigdecimal'
47+
gem 'bullet'
4748
gem 'image_processing', '>= 1.2'
4849
gem 'mutex_m'
4950
gem 'puma'

extra/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ ENV DEBIAN_FRONTEND=noninteractive
55
ENV DEVEL=1
66
ENV LANG=C.UTF-8
77

8-
RUN apt-get update -qq
9-
RUN apt-get install -yqq --no-install-recommends build-essential less nano netcat-traditional pkg-config
10-
RUN apt-get install -yqq --no-install-recommends freetds-dev libmariadb-dev libpq-dev libvips42 libyaml-dev sqlite3
8+
RUN apt-get update -qq && \
9+
apt-get install -yqq --no-install-recommends build-essential less nano netcat-traditional pkg-config && \
10+
apt-get install -yqq --no-install-recommends freetds-dev libmariadb-dev libpq-dev libvips42 libyaml-dev sqlite3
1111

1212
ARG BUNDLER_VERSION
1313
RUN gem install bundler -v ${BUNDLER_VERSION}

spec/dummy/config/environments/development.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
require "active_support/core_ext/integer/time"
44

55
Rails.application.configure do
6+
config.after_initialize do
7+
Bullet.enable = true
8+
Bullet.alert = true
9+
Bullet.bullet_logger = true
10+
Bullet.console = true
11+
Bullet.rails_logger = true
12+
Bullet.add_footer = true
13+
end
14+
615
# Settings specified here will take precedence over those in config/application.rb.
716

817
# In the development environment your application's code is reloaded any time

spec/dummy/config/environments/test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
# and recreated between test runs. Don't rely on the data there!
99

1010
Rails.application.configure do
11+
config.after_initialize do
12+
Bullet.enable = true
13+
Bullet.bullet_logger = true
14+
Bullet.raise = true # raise an error if n+1 query occurs
15+
end
16+
1117
# Settings specified here will take precedence over those in config/application.rb.
1218

1319
# Turn false under Spring and add config.action_view.cache_template_loading = true.

spec/rails_helper.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@
3737
support_files = File.expand_path('support/**/*.rb', __dir__)
3838
Dir[support_files].sort.each { |f| require f }
3939

40-
# begin
41-
# ActiveRecord::Migration.maintain_test_schema!
42-
# rescue ActiveRecord::PendingMigrationError => e
43-
# puts e.to_s.strip
44-
# exit 1
45-
# end
46-
4740
RSpec.configure do |config|
4841
config.filter_rails_from_backtrace!
4942
config.infer_spec_type_from_file_location!
@@ -68,4 +61,15 @@
6861

6962
RSpec.configuration.reporter.message(intro)
7063
end
64+
65+
config.before do |example|
66+
Bullet.start_request unless example.metadata[:skip_bullet]
67+
end
68+
69+
config.after do |example|
70+
unless example.metadata[:skip_bullet]
71+
Bullet.perform_out_of_channel_notifications if Bullet.notification?
72+
Bullet.end_request
73+
end
74+
end
7175
end

0 commit comments

Comments
 (0)