rspec-daemon 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89e342dbe33448b2a4321d6425f22924ef2e2ffca0da9c62b9b9dfe85b30df24
4
- data.tar.gz: c73ef7dc9be41b613ab443f9c3bde415afe4689bf4114bbb98fc137429b7128c
3
+ metadata.gz: 34268638889a4b7657ec87ecf13fe579c32c79753c5299fdd8f62dab0a31703f
4
+ data.tar.gz: 19cccfc47d8a9e0f03f04d80fa6f355d62ebf39dcaadc2d15113cfa68ffc8e38
5
5
  SHA512:
6
- metadata.gz: b40f70439941100811fbcf34906e077be7d8172399ecd5a046b0815dbc3ec786a87b280a6332a97dced543d4a65e13ad924b93f902ed524f9eb700ff5bea2c1a
7
- data.tar.gz: 5951972b8a86979b652a757a0ca36f41daee408728e512125230c02ee90a73088f1dd2fb064f89540fe8724ff3754ef04ce416e47b8cc7a1b3730c3525e22f6b
6
+ metadata.gz: 4b770f2cfb61e332e9e2e672dd97fac2a33bf1386d28d5300a02daffb8e332d65adadacfa25016cf1b743a6ab6eeed46f66a6d752e524eb763abedf49348d635
7
+ data.tar.gz: '01877ce39e845297adc62697f00894b2b7de0dfd8e685cae1b17bbd31b4783549e45694e4e52bb944310c48cf5deb23eca9e22b6534bfcef26dfa7af94164a99'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.1.0] - 2023-12-16
2
+
3
+ - Rails: Invoke autoreloading on every run #11 @osyoyu
4
+
1
5
  ## [1.0.1] - 2023-12-16
2
6
 
3
7
  - Fix the method to start the test #9 @ta1kt0me
data/README.md CHANGED
@@ -43,6 +43,21 @@ $ echo 'spec/models/user_spec.rb' | nc -v 0.0.0.0 3002
43
43
 
44
44
  By default, `rspec-daemon` will run on port `3002`. You can adjust the port by passing `--port` to `rspec-daemon` or setting the `RSPEC_DAEMON_PORT` environment variable.
45
45
 
46
+ ### Auto-reloading application code in Rails
47
+
48
+ If properly configured, rspec-daemon will automatically reload your application code (you probably want this behavior).
49
+ Add the following code to `config/initializers/rspec_daemon.rb`:
50
+
51
+ ```ruby
52
+ # rspec-daemon exposes RSPEC_DAEMON=1
53
+ if Rails.env.test? && ENV['RSPEC_DAEMON']
54
+ Rails.configuration.enable_reloading = true
55
+ end
56
+ ```
57
+
58
+ If autoreloading is not configured, you'd need to restart `rspec-daemon` every time you change code under `app/`.
59
+ Spec code (under `spec/`) will be always reloaded regardless of this setting.
60
+
46
61
  ## Editor integration
47
62
 
48
63
  ### Vim/Neovim
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  class Daemon
5
- VERSION = "1.0.1"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
data/lib/rspec/daemon.rb CHANGED
@@ -64,14 +64,22 @@ module RSpec
64
64
  RSpec.reset
65
65
 
66
66
  if cached_config.has_recorded_config?
67
+ # Reload configuration from the first time
67
68
  cached_config.replay_configuration
69
+ # Invoke auto reload
70
+ if defined?(::Rails) && ::Rails.configuration.reloading_enabled?
71
+ puts "Reloading..."
72
+ ::Rails.autoloaders.main.reload
73
+ end
68
74
  else
75
+ # This is the first spec run
69
76
  cached_config.record_configuration(&rspec_configuration)
70
77
  end
71
78
  end
72
79
 
73
80
  def rspec_configuration
74
81
  proc do
82
+ ENV['RSPEC_DAEMON'] = "1"
75
83
  if File.exist? "spec/rails_helper.rb"
76
84
  require "rails_helper"
77
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-daemon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuya Fujiwara