guard-rails 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/Gemfile +13 -12
- data/Gemfile.lock +38 -25
- data/README.md +1 -0
- data/VERSION +1 -1
- data/guard-rails.gemspec +5 -4
- data/lib/guard/rails/runner.rb +5 -1
- data/spec/lib/guard/rails/runner_spec.rb +145 -81
- data/spec/lib/guard/rails_spec.rb +38 -40
- data/spec/spec_helper.rb +3 -2
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67204488cf9dc70a5f92d1f1cca1ff87b0936a2c
|
4
|
+
data.tar.gz: d3375c351092f169bc3a3a57e67f670ef91367e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 965491b5a14754d3ca52255568edd514970979a3c08c5309a3c748c0c2fcd067c733a29396ef231b19159709e95f61878bb2be54b2cb81ccec4282cc3575b8af
|
7
|
+
data.tar.gz: 09845a32d24d05b0aa25905453489888d6bdab523bd90b0d76b6afc430004e7f1f411767a66d9de373a17c5d477cc5e7dec77e4da6b2567a5d1e75b8a5b35450
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
-
# source 'http://ruby.taobao.org'
|
3
2
|
|
4
|
-
# Specify your gem's dependencies in guard-rails.gemspec
|
5
3
|
gemspec
|
6
|
-
gem 'rake'
|
7
|
-
gem 'fakefs', :require => nil
|
8
|
-
gem 'guard'
|
9
|
-
gem 'guard-bundler'
|
10
|
-
gem 'guard-rspec'
|
11
4
|
|
12
|
-
|
13
|
-
|
5
|
+
# Development tools
|
6
|
+
group :development do
|
7
|
+
gem 'rake'
|
8
|
+
gem 'guard'
|
9
|
+
gem 'guard-bundler'
|
10
|
+
gem 'guard-rspec'
|
14
11
|
|
15
|
-
# Notification System
|
16
|
-
gem 'terminal-notifier-guard', :
|
17
|
-
gem 'libnotify', :
|
12
|
+
# Notification System
|
13
|
+
gem 'terminal-notifier-guard', require: RUBY_PLATFORM.downcase.include?("darwin") ? 'terminal-notifier-guard' : nil
|
14
|
+
gem 'libnotify', require: RUBY_PLATFORM.downcase.include?("linux") ? 'libnotify' : nil
|
15
|
+
end
|
16
|
+
|
17
|
+
# Test Coverage
|
18
|
+
gem "codeclimate-test-reporter", group: :test, require: nil
|
data/Gemfile.lock
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
guard-rails (0.
|
4
|
+
guard-rails (0.6.0)
|
5
5
|
guard (~> 2.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
celluloid (0.
|
11
|
-
timers (~>
|
10
|
+
celluloid (0.16.0)
|
11
|
+
timers (~> 4.0.0)
|
12
|
+
codeclimate-test-reporter (0.4.0)
|
13
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
12
14
|
coderay (1.1.0)
|
13
15
|
diff-lcs (1.2.5)
|
14
|
-
|
16
|
+
docile (1.1.5)
|
17
|
+
fakefs (0.5.3)
|
15
18
|
ffi (1.9.3)
|
16
19
|
ffi (1.9.3-java)
|
17
20
|
formatador (0.2.5)
|
@@ -24,9 +27,11 @@ GEM
|
|
24
27
|
guard-bundler (2.0.0)
|
25
28
|
bundler (~> 1.0)
|
26
29
|
guard (~> 2.2)
|
27
|
-
guard-rspec (4.
|
30
|
+
guard-rspec (4.3.1)
|
28
31
|
guard (~> 2.1)
|
29
32
|
rspec (>= 2.14, < 4.0)
|
33
|
+
hitimes (1.2.2)
|
34
|
+
hitimes (1.2.2-java)
|
30
35
|
libnotify (0.8.3)
|
31
36
|
ffi (>= 1.0.11)
|
32
37
|
listen (2.7.9)
|
@@ -34,15 +39,13 @@ GEM
|
|
34
39
|
rb-fsevent (>= 0.9.3)
|
35
40
|
rb-inotify (>= 0.9)
|
36
41
|
lumberjack (1.0.9)
|
37
|
-
metaclass (0.0.4)
|
38
42
|
method_source (0.8.2)
|
39
|
-
|
40
|
-
|
41
|
-
pry (0.10.0)
|
43
|
+
multi_json (1.10.1)
|
44
|
+
pry (0.10.1)
|
42
45
|
coderay (~> 1.1.0)
|
43
46
|
method_source (~> 0.8.1)
|
44
47
|
slop (~> 3.4)
|
45
|
-
pry (0.10.
|
48
|
+
pry (0.10.1-java)
|
46
49
|
coderay (~> 1.1.0)
|
47
50
|
method_source (~> 0.8.1)
|
48
51
|
slop (~> 3.4)
|
@@ -51,20 +54,31 @@ GEM
|
|
51
54
|
rb-fsevent (0.9.4)
|
52
55
|
rb-inotify (0.9.5)
|
53
56
|
ffi (>= 0.5.0)
|
54
|
-
|
55
|
-
|
56
|
-
rspec-
|
57
|
-
rspec-
|
58
|
-
|
59
|
-
rspec-
|
60
|
-
|
61
|
-
rspec-
|
62
|
-
|
57
|
+
rr (1.1.2)
|
58
|
+
rspec (3.1.0)
|
59
|
+
rspec-core (~> 3.1.0)
|
60
|
+
rspec-expectations (~> 3.1.0)
|
61
|
+
rspec-mocks (~> 3.1.0)
|
62
|
+
rspec-core (3.1.2)
|
63
|
+
rspec-support (~> 3.1.0)
|
64
|
+
rspec-expectations (3.1.0)
|
65
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
+
rspec-support (~> 3.1.0)
|
67
|
+
rspec-mocks (3.1.0)
|
68
|
+
rspec-support (~> 3.1.0)
|
69
|
+
rspec-support (3.1.0)
|
70
|
+
simplecov (0.9.0)
|
71
|
+
docile (~> 1.1.0)
|
72
|
+
multi_json
|
73
|
+
simplecov-html (~> 0.8.0)
|
74
|
+
simplecov-html (0.8.0)
|
75
|
+
slop (3.6.0)
|
63
76
|
spoon (0.0.4)
|
64
77
|
ffi
|
65
78
|
terminal-notifier-guard (1.5.3)
|
66
79
|
thor (0.19.1)
|
67
|
-
timers (
|
80
|
+
timers (4.0.1)
|
81
|
+
hitimes
|
68
82
|
version (1.0.0)
|
69
83
|
|
70
84
|
PLATFORMS
|
@@ -72,16 +86,15 @@ PLATFORMS
|
|
72
86
|
ruby
|
73
87
|
|
74
88
|
DEPENDENCIES
|
75
|
-
|
89
|
+
codeclimate-test-reporter
|
90
|
+
fakefs (~> 0.5)
|
76
91
|
guard
|
77
92
|
guard-bundler
|
78
93
|
guard-rails!
|
79
94
|
guard-rspec
|
80
95
|
libnotify
|
81
|
-
mocha (~> 1.0)
|
82
96
|
rake
|
83
|
-
|
84
|
-
|
85
|
-
rspec (~> 2.6)
|
97
|
+
rr (~> 1.0)
|
98
|
+
rspec (~> 3.0)
|
86
99
|
terminal-notifier-guard
|
87
100
|
version (>= 1.0.0)
|
data/README.md
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
[![Build Status](https://travis-ci.org/ranmocy/guard-rails.png)](https://travis-ci.org/ranmocy/guard-rails)
|
5
5
|
[![Dependency Status](https://gemnasium.com/ranmocy/guard-rails.png)](https://gemnasium.com/ranmocy/guard-rails)
|
6
6
|
[![Code Climate](https://codeclimate.com/github/ranmocy/guard-rails.png)](https://codeclimate.com/github/ranmocy/guard-rails)
|
7
|
+
[![Test Coverage](https://codeclimate.com/github/ranmocy/guard-rails/badges/coverage.svg)](https://codeclimate.com/github/ranmocy/guard-rails)
|
7
8
|
|
8
9
|
## Main repository
|
9
10
|
Currently, the official fork repository is at [ranmocy/guard-rails][ranmocy-guard-rails].
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/guard-rails.gemspec
CHANGED
@@ -11,16 +11,17 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.description = %q{Restart Rails when things change in your app}
|
12
12
|
s.license = 'MIT'
|
13
13
|
|
14
|
-
s.rubyforge_project = "guard-rails"
|
15
|
-
|
16
14
|
s.files = `git ls-files`.split("\n")
|
17
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
17
|
s.require_paths = ["lib"]
|
20
18
|
|
19
|
+
s.required_ruby_version = '>= 1.9'
|
20
|
+
|
21
21
|
s.add_dependency 'guard', '~> 2.0'
|
22
22
|
|
23
|
-
s.add_development_dependency 'rspec', '~>
|
24
|
-
s.add_development_dependency '
|
23
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
24
|
+
s.add_development_dependency 'rr', '~> 1.0'
|
25
|
+
s.add_development_dependency 'fakefs', '~> 0.5'
|
25
26
|
s.add_development_dependency 'version', '>= 1.0.0'
|
26
27
|
end
|
data/lib/guard/rails/runner.rb
CHANGED
@@ -103,7 +103,11 @@ module Guard
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def run_rails_command!
|
106
|
-
|
106
|
+
if options[:CLI] || options[:zeus]
|
107
|
+
without_bundler_env { system(environment, build_command) }
|
108
|
+
else
|
109
|
+
system(environment, build_command)
|
110
|
+
end
|
107
111
|
end
|
108
112
|
|
109
113
|
def has_pid?
|
@@ -13,7 +13,7 @@ describe Guard::RailsRunner do
|
|
13
13
|
describe '#pid' do
|
14
14
|
include FakeFS::SpecHelpers
|
15
15
|
|
16
|
-
context 'pid file exists' do
|
16
|
+
context 'when pid file exists' do
|
17
17
|
let(:pid) { 12345 }
|
18
18
|
|
19
19
|
before do
|
@@ -21,18 +21,18 @@ describe Guard::RailsRunner do
|
|
21
21
|
File.open(runner.pid_file, 'w') { |fh| fh.print pid }
|
22
22
|
end
|
23
23
|
|
24
|
-
it "
|
25
|
-
runner.pid.
|
24
|
+
it "reads the pid" do
|
25
|
+
expect(runner.pid).to eq(pid)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
context 'pid file does not exist' do
|
30
|
-
it "
|
31
|
-
runner.pid.
|
29
|
+
context 'when pid file does not exist' do
|
30
|
+
it "returns nil" do
|
31
|
+
expect(runner.pid).to be nil
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
context 'custom rails root given' do
|
35
|
+
context 'when custom rails root given' do
|
36
36
|
let(:options) { default_options.merge(:root => 'spec/dummy') }
|
37
37
|
let(:pid) { 12345 }
|
38
38
|
|
@@ -41,194 +41,258 @@ describe Guard::RailsRunner do
|
|
41
41
|
File.open(runner.pid_file, 'w') { |fh| fh.print pid }
|
42
42
|
end
|
43
43
|
|
44
|
-
it "
|
45
|
-
runner.pid_file.
|
44
|
+
it "points to the right pid file" do
|
45
|
+
expect(runner.pid_file).to match %r{spec/dummy/tmp/pids/development.pid}
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
end
|
50
50
|
|
51
51
|
describe '#build_command' do
|
52
|
-
context "CLI" do
|
52
|
+
context "with options[:CLI]" do
|
53
53
|
let(:custom_cli) { 'custom_CLI_command' }
|
54
54
|
let(:options) { default_options.merge(:CLI => custom_cli) }
|
55
|
-
it "
|
56
|
-
runner.build_command.
|
55
|
+
it "has customized CLI" do
|
56
|
+
expect(runner.build_command).to match(%r{#{custom_cli} --pid })
|
57
57
|
end
|
58
58
|
|
59
59
|
let(:custom_pid_file) { "tmp/pids/rails_dev.pid" }
|
60
60
|
let(:options) { default_options.merge(:CLI => custom_cli, :pid_file => custom_pid_file) }
|
61
|
-
it "
|
61
|
+
it "uses customized pid_file" do
|
62
62
|
pid_file_path = File.expand_path custom_pid_file
|
63
|
-
runner.build_command.
|
63
|
+
expect(runner.build_command).to match(%r{#{custom_cli} --pid \"#{pid_file_path}\"})
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
context "daemon" do
|
68
|
-
it "
|
69
|
-
runner.build_command.
|
67
|
+
context "without options[:daemon]" do
|
68
|
+
it "doesn't have daemon switch" do
|
69
|
+
expect(runner.build_command).not_to match(%r{ -d})
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
context "
|
73
|
+
context "with options[:daemon]" do
|
74
74
|
let(:options) { default_options.merge(:daemon => true) }
|
75
|
-
it "
|
76
|
-
runner.build_command.
|
75
|
+
it "has a daemon switch" do
|
76
|
+
expect(runner.build_command).to match(%r{ -d})
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
context "
|
81
|
-
it "
|
82
|
-
runner.build_command.
|
80
|
+
context "without options[:env]" do
|
81
|
+
it "has environment switch to development" do
|
82
|
+
expect(runner.build_command).to match(%r{ -e development})
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
context "test" do
|
86
|
+
context "with options[:environment] as test" do
|
87
87
|
let(:options) { default_options.merge(:environment => 'test') }
|
88
|
-
it "
|
89
|
-
runner.build_command.
|
88
|
+
it "has environment switch to test" do
|
89
|
+
expect(runner.build_command).to match(%r{ -e test})
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
context 'debugger' do
|
93
|
+
context 'with options[:debugger]' do
|
94
94
|
let(:options) { default_options.merge(:debugger => true) }
|
95
95
|
|
96
|
-
it "
|
97
|
-
runner.build_command.
|
96
|
+
it "has a debugger switch" do
|
97
|
+
expect(runner.build_command).to match(%r{ -u})
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
-
context '
|
101
|
+
context 'with options[:server] as thin' do
|
102
102
|
let(:options) { default_options.merge(:server => 'thin') }
|
103
103
|
|
104
|
-
it "
|
105
|
-
runner.build_command.
|
104
|
+
it "has the server name thin" do
|
105
|
+
expect(runner.build_command).to match(%r{thin})
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
context "
|
110
|
-
it "
|
109
|
+
context "without options[:pid_file]" do
|
110
|
+
it "uses default pid_file" do
|
111
111
|
pid_file_path = File.expand_path "tmp/pids/development.pid"
|
112
|
-
runner.build_command.
|
112
|
+
expect(runner.build_command).to match(%r{ --pid \"#{pid_file_path}\"})
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
|
-
context "
|
116
|
+
context "with options[:pid_file]" do
|
117
117
|
let(:custom_pid_file) { "tmp/pids/rails_dev.pid" }
|
118
118
|
let(:options) { default_options.merge(:pid_file => custom_pid_file) }
|
119
119
|
|
120
|
-
it "
|
120
|
+
it "uses customized pid_file" do
|
121
121
|
pid_file_path = File.expand_path custom_pid_file
|
122
|
-
runner.build_command.
|
122
|
+
expect(runner.build_command).to match(%r{ --pid \"#{pid_file_path}\"})
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
-
context "zeus
|
126
|
+
context "with options[:zeus]" do
|
127
127
|
let(:options) { default_options.merge(:zeus => true) }
|
128
|
-
it "
|
129
|
-
runner.build_command.
|
128
|
+
it "has zeus" do
|
129
|
+
expect(runner.build_command).to match(%r{zeus server })
|
130
130
|
end
|
131
131
|
|
132
|
-
context "
|
132
|
+
context "with options[:zeus_plan]" do
|
133
133
|
let(:options) { default_options.merge(:zeus => true, :zeus_plan => 'test_server') }
|
134
|
-
it "
|
135
|
-
runner.build_command.
|
134
|
+
it "uses customized zeus plan" do
|
135
|
+
expect(runner.build_command).to match(%r{zeus test_server})
|
136
136
|
end
|
137
137
|
|
138
|
-
context "
|
138
|
+
context "with options[:server]" do
|
139
139
|
let(:options) { default_options.merge(:zeus => true, :zeus_plan => 'test_server', :server => 'thin') }
|
140
|
-
it "
|
141
|
-
runner.build_command.
|
140
|
+
it "uses customized server" do
|
141
|
+
expect(runner.build_command).to match(%r{zeus test_server .* thin})
|
142
142
|
end
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
-
context "zeus
|
148
|
-
it "
|
149
|
-
runner.build_command.
|
147
|
+
context "without options[:zeus]" do
|
148
|
+
it "doesn't have zeus" do
|
149
|
+
expect(runner.build_command).to_not match(%r{zeus server })
|
150
150
|
end
|
151
151
|
|
152
152
|
let(:options) { default_options.merge(:zeus_plan => 'test_server') }
|
153
|
-
it "
|
154
|
-
runner.build_command.
|
153
|
+
it "doesnt' have test_server" do
|
154
|
+
expect(runner.build_command).to_not match(%r{test_server})
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
|
-
context '
|
158
|
+
context 'with options[:root]' do
|
159
159
|
let(:options) { default_options.merge(:root => 'spec/dummy') }
|
160
160
|
|
161
|
-
it "
|
162
|
-
runner.build_command.
|
161
|
+
it "has `cd` command with customized rails root" do
|
162
|
+
expect(runner.build_command).to match(%r{cd .*/spec/dummy\" &&})
|
163
163
|
end
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
167
|
describe '#environment' do
|
168
|
-
it "
|
169
|
-
runner.environment["RAILS_ENV"].
|
168
|
+
it "sets RAILS_ENV to development" do
|
169
|
+
expect(runner.environment["RAILS_ENV"]).to eq "development"
|
170
170
|
end
|
171
171
|
|
172
|
-
context "with options[:environment]" do
|
173
|
-
let(:options) { default_options.merge(:environment => '
|
172
|
+
context "with options[:environment] as test" do
|
173
|
+
let(:options) { default_options.merge(:environment => 'test') }
|
174
174
|
|
175
|
-
it "
|
176
|
-
runner.environment["RAILS_ENV"].
|
175
|
+
it "sets RAILS_ENV to test" do
|
176
|
+
expect(runner.environment["RAILS_ENV"]).to eq "test"
|
177
177
|
end
|
178
178
|
|
179
|
-
context "zeus
|
179
|
+
context "with options[:zeus]" do
|
180
180
|
let(:options) { default_options.merge(:zeus => true) }
|
181
181
|
|
182
|
-
it "
|
183
|
-
runner.environment["RAILS_ENV"].
|
182
|
+
it "sets RAILS_ENV to nil" do
|
183
|
+
expect(runner.environment["RAILS_ENV"]).to be nil
|
184
184
|
end
|
185
185
|
end
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
189
|
+
describe '#run_rails_command' do
|
190
|
+
before do
|
191
|
+
@bundler_env = ENV['BUNDLE_GEMFILE']
|
192
|
+
stub(runner).build_command.returns("printenv BUNDLE_GEMFILE > /dev/null")
|
193
|
+
end
|
194
|
+
after do
|
195
|
+
ENV['BUNDLE_GEMFILE'] = @bundler_env
|
196
|
+
end
|
197
|
+
|
198
|
+
shared_examples "inside of bundler" do
|
199
|
+
it 'runs rails inside of bundler' do
|
200
|
+
expect(runner.send(:run_rails_command!)).to be true
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
shared_examples "outside of bundler" do
|
205
|
+
it 'runs rails outside of bundler' do
|
206
|
+
expect(runner.send(:run_rails_command!)).to be false
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
context 'when guard-rails is outside of bundler' do
|
211
|
+
before do
|
212
|
+
ENV['BUNDLE_GEMFILE'] = 'Gemfile'
|
213
|
+
end
|
214
|
+
|
215
|
+
context 'with default env' do
|
216
|
+
it_behaves_like "inside of bundler"
|
217
|
+
end
|
218
|
+
|
219
|
+
context 'with zeus' do
|
220
|
+
let(:options) { default_options.merge(:zeus => true) }
|
221
|
+
it_behaves_like "outside of bundler"
|
222
|
+
end
|
223
|
+
|
224
|
+
context 'with CLI' do
|
225
|
+
let(:custom_cli) { 'custom_CLI_command' }
|
226
|
+
let(:options) { default_options.merge(:CLI => custom_cli) }
|
227
|
+
it_behaves_like "outside of bundler"
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
context 'when guard-rails is outside of bundler' do
|
232
|
+
before do
|
233
|
+
ENV['BUNDLE_GEMFILE'] = nil
|
234
|
+
end
|
235
|
+
|
236
|
+
context 'with default env' do
|
237
|
+
it_behaves_like "outside of bundler"
|
238
|
+
end
|
239
|
+
|
240
|
+
context 'with zeus' do
|
241
|
+
let(:options) { default_options.merge(:zeus => true) }
|
242
|
+
it_behaves_like "outside of bundler"
|
243
|
+
end
|
244
|
+
|
245
|
+
context 'with CLI' do
|
246
|
+
let(:custom_cli) { 'custom_CLI_command' }
|
247
|
+
let(:options) { default_options.merge(:CLI => custom_cli) }
|
248
|
+
it_behaves_like "outside of bundler"
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
189
253
|
describe '#start' do
|
190
|
-
let(:kill_expectation) { runner.
|
191
|
-
let(:pid_stub) { runner.
|
254
|
+
let(:kill_expectation) { mock(runner).kill_unmanaged_pid! }
|
255
|
+
let(:pid_stub) { stub(runner).has_pid? }
|
192
256
|
|
193
257
|
before do
|
194
|
-
runner.
|
258
|
+
mock(runner).run_rails_command!.once
|
195
259
|
end
|
196
260
|
|
197
|
-
context '
|
261
|
+
context 'without options[:force_run]' do
|
198
262
|
before do
|
199
263
|
pid_stub.returns(true)
|
200
264
|
kill_expectation.never
|
201
|
-
runner.
|
265
|
+
mock(runner).wait_for_pid_action.never
|
202
266
|
end
|
203
267
|
|
204
|
-
it "
|
205
|
-
runner.start.
|
268
|
+
it "starts as normal" do
|
269
|
+
expect(runner.start).to be true
|
206
270
|
end
|
207
271
|
end
|
208
272
|
|
209
|
-
context '
|
273
|
+
context 'with options[:force_run]' do
|
210
274
|
let(:options) { default_options.merge(:force_run => true) }
|
211
275
|
|
212
276
|
before do
|
213
277
|
pid_stub.returns(true)
|
214
278
|
kill_expectation.once
|
215
|
-
runner.
|
279
|
+
mock(runner).wait_for_pid_action.never
|
216
280
|
end
|
217
281
|
|
218
|
-
it "
|
219
|
-
runner.start.
|
282
|
+
it "starts as normal" do
|
283
|
+
expect(runner.start).to be true
|
220
284
|
end
|
221
285
|
end
|
222
286
|
|
223
|
-
context "
|
287
|
+
context "doesn't write the pid" do
|
224
288
|
before do
|
225
289
|
pid_stub.returns(false)
|
226
290
|
kill_expectation.never
|
227
|
-
runner.
|
291
|
+
mock(runner).wait_for_pid_action.times(Guard::RailsRunner::MAX_WAIT_COUNT)
|
228
292
|
end
|
229
293
|
|
230
|
-
it "
|
231
|
-
runner.start.
|
294
|
+
it "doesn't start" do
|
295
|
+
expect(runner.start).to be false
|
232
296
|
end
|
233
297
|
end
|
234
298
|
end
|
@@ -237,8 +301,8 @@ describe Guard::RailsRunner do
|
|
237
301
|
let(:timeout) { 30 }
|
238
302
|
let(:options) { default_options.merge(:timeout => timeout) }
|
239
303
|
|
240
|
-
it "
|
241
|
-
runner.sleep_time.
|
304
|
+
it "adjusts the sleep time as necessary" do
|
305
|
+
expect(runner.sleep_time).to eq (timeout.to_f / Guard::RailsRunner::MAX_WAIT_COUNT.to_f)
|
242
306
|
end
|
243
307
|
end
|
244
308
|
end
|
@@ -5,30 +5,30 @@ describe Guard::Rails do
|
|
5
5
|
let(:guard) { Guard::Rails.new(options) }
|
6
6
|
let(:options) { {} }
|
7
7
|
|
8
|
-
describe
|
9
|
-
it "
|
8
|
+
describe "#initialize" do
|
9
|
+
it "initializes with options" do
|
10
10
|
guard
|
11
11
|
|
12
|
-
guard.runner.options[:port].
|
12
|
+
expect(guard.runner.options[:port]).to eq 3000
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
describe
|
17
|
-
let(:ui_expectation) { Guard::UI.
|
16
|
+
describe "#start" do
|
17
|
+
let(:ui_expectation) { mock(Guard::UI).info.with(/#{Guard::Rails::DEFAULT_OPTIONS[:port]}/) }
|
18
18
|
|
19
|
-
context
|
20
|
-
it "
|
21
|
-
guard.
|
19
|
+
context "starts when Guard starts" do
|
20
|
+
it "shows the right message and runs startup" do
|
21
|
+
mock(guard).reload.with("start").once
|
22
22
|
ui_expectation
|
23
23
|
guard.start
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
context '
|
27
|
+
context "doesn't start when Guard starts" do
|
28
28
|
let(:options) { { :start_on_start => false } }
|
29
29
|
|
30
|
-
it "
|
31
|
-
guard.
|
30
|
+
it "shows the right message and doesn't run startup" do
|
31
|
+
mock(guard).reload.never
|
32
32
|
ui_expectation
|
33
33
|
guard.start
|
34
34
|
end
|
@@ -39,55 +39,53 @@ describe Guard::Rails do
|
|
39
39
|
let(:pid) { '12345' }
|
40
40
|
|
41
41
|
before do
|
42
|
-
Guard::RailsRunner
|
42
|
+
any_instance_of(Guard::RailsRunner, pid: pid)
|
43
43
|
end
|
44
44
|
|
45
|
-
let(:runner_stub) { Guard::RailsRunner.any_instance.stubs(:restart) }
|
46
|
-
|
47
45
|
context 'at start' do
|
48
46
|
before do
|
49
|
-
Guard::UI.
|
50
|
-
Guard::Notifier.
|
51
|
-
|
47
|
+
mock(Guard::UI).info.with('Starting Rails...')
|
48
|
+
mock(Guard::Notifier).notify.with(/Rails starting/, hash_including(:image => :pending))
|
49
|
+
any_instance_of(Guard::RailsRunner, restart: true)
|
52
50
|
end
|
53
51
|
|
54
|
-
it "
|
55
|
-
Guard::UI.
|
56
|
-
Guard::Notifier.
|
52
|
+
it "starts and shows the pid file" do
|
53
|
+
mock(Guard::UI).info.with(/#{pid}/)
|
54
|
+
mock(Guard::Notifier).notify.with(/Rails started/, hash_including(:image => :success))
|
57
55
|
|
58
56
|
guard.reload("start")
|
59
57
|
end
|
60
58
|
end
|
61
59
|
|
62
|
-
context
|
60
|
+
context "after start" do
|
63
61
|
before do
|
64
|
-
Guard::RailsRunner
|
65
|
-
Guard::UI.
|
66
|
-
Guard::Notifier.
|
62
|
+
any_instance_of(Guard::RailsRunner, pid: pid)
|
63
|
+
mock(Guard::UI).info.with('Restarting Rails...')
|
64
|
+
mock(Guard::Notifier).notify.with(/Rails restarting/, hash_including(:image => :pending))
|
67
65
|
end
|
68
66
|
|
69
|
-
context
|
67
|
+
context "with pid file" do
|
70
68
|
before do
|
71
|
-
|
69
|
+
any_instance_of(Guard::RailsRunner, restart: true)
|
72
70
|
end
|
73
71
|
|
74
|
-
it "
|
75
|
-
Guard::UI.
|
76
|
-
Guard::Notifier.
|
72
|
+
it "restarts and shows the pid file" do
|
73
|
+
mock(Guard::UI).info.with(/#{pid}/)
|
74
|
+
mock(Guard::Notifier).notify.with(/Rails restarted/, hash_including(:image => :success))
|
77
75
|
|
78
76
|
guard.reload
|
79
77
|
end
|
80
78
|
end
|
81
79
|
|
82
|
-
context
|
80
|
+
context "without pid file" do
|
83
81
|
before do
|
84
|
-
|
82
|
+
any_instance_of(Guard::RailsRunner, restart: false)
|
85
83
|
end
|
86
84
|
|
87
|
-
it "
|
88
|
-
Guard::UI.
|
89
|
-
Guard::UI.
|
90
|
-
Guard::Notifier.
|
85
|
+
it "restarts and shows the pid file" do
|
86
|
+
mock(Guard::UI).info.with(/#{pid}/).never
|
87
|
+
mock(Guard::UI).info.with(/Rails NOT restarted/)
|
88
|
+
mock(Guard::Notifier).notify.with(/Rails NOT restarted/, hash_including(:image => :failed))
|
91
89
|
|
92
90
|
guard.reload
|
93
91
|
end
|
@@ -95,16 +93,16 @@ describe Guard::Rails do
|
|
95
93
|
end
|
96
94
|
end
|
97
95
|
|
98
|
-
describe
|
99
|
-
it "
|
100
|
-
Guard::Notifier.
|
96
|
+
describe "#stop" do
|
97
|
+
it "stops with correct message" do
|
98
|
+
mock(Guard::Notifier).notify.with('Until next time...', anything)
|
101
99
|
guard.stop
|
102
100
|
end
|
103
101
|
end
|
104
102
|
|
105
103
|
describe '#run_on_change' do
|
106
|
-
it "
|
107
|
-
guard.
|
104
|
+
it "reloads on change" do
|
105
|
+
mock(guard).reload.once
|
108
106
|
guard.run_on_change([])
|
109
107
|
end
|
110
108
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Bintz
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
@@ -31,16 +31,16 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '3.0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '3.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: rr
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
@@ -53,6 +53,20 @@ dependencies:
|
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '1.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: fakefs
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.5'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.5'
|
56
70
|
- !ruby/object:Gem::Dependency
|
57
71
|
name: version
|
58
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,14 +118,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
118
|
requirements:
|
105
119
|
- - ">="
|
106
120
|
- !ruby/object:Gem::Version
|
107
|
-
version: '
|
121
|
+
version: '1.9'
|
108
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
123
|
requirements:
|
110
124
|
- - ">="
|
111
125
|
- !ruby/object:Gem::Version
|
112
126
|
version: '0'
|
113
127
|
requirements: []
|
114
|
-
rubyforge_project:
|
128
|
+
rubyforge_project:
|
115
129
|
rubygems_version: 2.2.2
|
116
130
|
signing_key:
|
117
131
|
specification_version: 4
|