Module: Specjour::Configuration
Instance Attribute Summary collapse
-
#after_fork ⇒ Object
This block is run by each worker before they begin running tests.
-
#after_load ⇒ Object
This block is run after the manager loads the app into memory, but before forking new worker processes.
-
#before_fork ⇒ Object
This block is run by the manager before forking workers.
-
#prepare ⇒ Object
This block is run on all workers when invoking ‘specjour prepare` Defaults to dropping the worker’s database and recreating it.
- #rspec_formatter ⇒ Object
- #rsync_options ⇒ Object
Instance Method Summary collapse
- #bundle_install ⇒ Object
- #default_after_fork ⇒ Object
- #default_after_load ⇒ Object
- #default_before_fork ⇒ Object
- #default_prepare ⇒ Object
- #default_rspec_formatter ⇒ Object
- #default_rsync_options ⇒ Object
- #reset ⇒ Object
Instance Attribute Details
#after_fork ⇒ Object
This block is run by each worker before they begin running tests. The default action is to migrate the database, and clear it of any old data.
10 11 12 |
# File 'lib/specjour/configuration.rb', line 10 def after_fork @after_fork ||= default_after_fork end |
#after_load ⇒ Object
This block is run after the manager loads the app into memory, but before forking new worker processes. The default action is to disconnect from the ActiveRecord database.
17 18 19 |
# File 'lib/specjour/configuration.rb', line 17 def after_load @after_load ||= default_after_load end |
#before_fork ⇒ Object
This block is run by the manager before forking workers. The default action is to run bundle install.
23 24 25 |
# File 'lib/specjour/configuration.rb', line 23 def before_fork @before_fork ||= default_before_fork end |
#prepare ⇒ Object
This block is run on all workers when invoking ‘specjour prepare` Defaults to dropping the worker’s database and recreating it. This is especially useful when two teams are sharing workers and writing migrations at around the same time causing databases to get out of sync.
31 32 33 |
# File 'lib/specjour/configuration.rb', line 31 def prepare @prepare ||= default_prepare end |
#rspec_formatter ⇒ Object
44 45 46 |
# File 'lib/specjour/configuration.rb', line 44 def rspec_formatter @rspec_formatter ||= default_rspec_formatter end |
#rsync_options ⇒ Object
48 49 50 |
# File 'lib/specjour/configuration.rb', line 48 def @rsync_options ||= end |
Instance Method Details
#bundle_install ⇒ Object
52 53 54 55 56 |
# File 'lib/specjour/configuration.rb', line 52 def bundle_install if system('which bundle') system('bundle check') || system('bundle install') end end |
#default_after_fork ⇒ Object
64 65 66 67 68 |
# File 'lib/specjour/configuration.rb', line 64 def default_after_fork lambda do DbScrub.scrub if rails_with_ar? end end |
#default_after_load ⇒ Object
70 71 72 73 74 |
# File 'lib/specjour/configuration.rb', line 70 def default_after_load lambda do ActiveRecord::Base.remove_connection if rails_with_ar? end end |
#default_before_fork ⇒ Object
58 59 60 61 62 |
# File 'lib/specjour/configuration.rb', line 58 def default_before_fork lambda do bundle_install end end |
#default_prepare ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/specjour/configuration.rb', line 76 def default_prepare lambda do if rails_with_ar? DbScrub.drop DbScrub.scrub end end end |
#default_rspec_formatter ⇒ Object
85 86 87 88 89 |
# File 'lib/specjour/configuration.rb', line 85 def default_rspec_formatter lambda do ::RSpec::Core::Formatters::ProgressFormatter end end |
#default_rsync_options ⇒ Object
91 92 93 |
# File 'lib/specjour/configuration.rb', line 91 def "-aL --delete --ignore-errors" end |
#reset ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/specjour/configuration.rb', line 35 def reset @before_fork = nil @after_fork = nil @after_load = nil @prepare = nil @rsync_options = nil @rspec_formatter = nil end |