zeus 0.13.4.pre2 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,36 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ zeus (0.15.0)
5
+ method_source (>= 0.6.7)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.1.3)
11
+ hpricot (0.8.6)
12
+ method_source (0.8.2)
13
+ mustache (0.99.5)
14
+ rake (10.3.0)
15
+ rdiscount (2.1.7.1)
16
+ ronn (0.7.3)
17
+ hpricot (>= 0.8.2)
18
+ mustache (>= 0.7.0)
19
+ rdiscount (>= 1.5.8)
20
+ rspec (2.12.0)
21
+ rspec-core (~> 2.12.0)
22
+ rspec-expectations (~> 2.12.0)
23
+ rspec-mocks (~> 2.12.0)
24
+ rspec-core (2.12.2)
25
+ rspec-expectations (2.12.1)
26
+ diff-lcs (~> 1.1.3)
27
+ rspec-mocks (2.12.2)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ rake
34
+ ronn (>= 0.7.0)
35
+ rspec (~> 2.12.0)
36
+ zeus!
data/Rakefile CHANGED
@@ -6,39 +6,10 @@ require 'pathname'
6
6
  ROOT_PATH = Pathname.new(File.expand_path("../../", __FILE__))
7
7
  RUBYGEM_PATH = Pathname.new(File.expand_path("../", __FILE__))
8
8
 
9
- task build: [:import_externals, :version, :manifest]
9
+ task build: [:manifest]
10
10
  task default: :build
11
11
 
12
- task :import_externals do
13
- puts "building rubygem"
14
-
15
- Rake::Task[:clean].invoke
16
-
17
- FileUtils.rm_r(RUBYGEM_PATH + "man") rescue nil
18
- FileUtils.rm_r(RUBYGEM_PATH + "build") rescue nil
19
-
20
- # manpages
21
- FileUtils.mkdir(RUBYGEM_PATH + "man")
22
- FileUtils.cp_r(ROOT_PATH + "man/build", RUBYGEM_PATH + "man")
23
-
24
- # multi-arch binaries
25
- FileUtils.cp_r(ROOT_PATH + "build", RUBYGEM_PATH + "build")
26
-
27
- Rake::Task[:manifest].invoke
28
- Rake::Task[:build].invoke
29
- end
30
-
31
- task :version do
32
- version = File.read('../VERSION').chomp
33
- File.open('lib/zeus/version.rb', 'w') { |f| f.puts <<END
34
- module Zeus
35
- VERSION = "#{version}"
36
- end
37
- END
38
- }
39
- end
40
-
41
- task manifest: :version do
12
+ task :manifest do
42
13
  files = `find . -type f | sed 's|^\./||'`.lines.map(&:chomp)
43
14
  exceptions = [
44
15
  /.gitignore$/,
@@ -49,10 +20,3 @@ task manifest: :version do
49
20
  File.open('MANIFEST', 'w') {|f| f.puts files.join("\n") }
50
21
  end
51
22
 
52
- task :clean do
53
- FileUtils.rm(RUBYGEM_PATH + "lib/zeus/version.rb") rescue nil
54
- FileUtils.rm_r(RUBYGEM_PATH + "man") rescue nil
55
- FileUtils.rm_r(RUBYGEM_PATH + "build") rescue nil
56
- FileUtils.rm_r(RUBYGEM_PATH + "pkg") rescue nil
57
- end
58
-
Binary file
Binary file
Binary file
Binary file
@@ -14,7 +14,6 @@
14
14
  "dbconsole": []
15
15
  },
16
16
  "test_environment": {
17
- "cucumber_environment": {"cucumber": []},
18
17
  "test_helper": {"test": ["rspec", "testrb"]}
19
18
  }
20
19
  }
@@ -14,7 +14,6 @@
14
14
  "dbconsole": []
15
15
  },
16
16
  "test_environment": {
17
- "cucumber_environment": {"cucumber": []},
18
17
  "test_helper": {"test": ["rspec", "testrb"]}
19
18
  }
20
19
  }
@@ -1,7 +1,14 @@
1
1
  # encoding: utf-8
2
2
  require 'socket'
3
+
4
+ # load exact json version from Gemfile.lock to avoid conflicts
5
+ gemfile = "#{ENV["BUNDLE_GEMFILE"] || "Gemfile"}.lock"
6
+ if File.exist?(gemfile) && version = File.read(gemfile)[/^ json \((.*)\)/, 1]
7
+ gem 'json', version
8
+ end
3
9
  require 'json'
4
10
  require 'pty'
11
+ require 'set'
5
12
 
6
13
  require 'zeus/load_tracking'
7
14
  require 'zeus/plan'
@@ -19,7 +26,7 @@ module Zeus
19
26
  # Yup.
20
27
  def setup_dummy_tty!
21
28
  return if self.dummy_tty
22
- master, self.dummy_tty = PTY.open
29
+ master, self.dummy_tty = PTY.send(:open)
23
30
  Thread.new {
24
31
  loop { master.read(1024) }
25
32
  }
@@ -35,51 +42,72 @@ module Zeus
35
42
  end
36
43
 
37
44
  def go(identifier=:boot)
38
- $0 = "zeus slave: #{identifier}"
39
-
40
- setup_dummy_tty!
41
- master = setup_master_socket!
42
- feature_pipe_r, feature_pipe_w = IO.pipe
43
-
44
- # I need to give the master a way to talk to me exclusively
45
- local, remote = UNIXSocket.pair(Socket::SOCK_STREAM)
46
- master.send_io(remote)
47
-
48
- # Now I need to tell the master about my PID and ID
49
- local.write "P:#{Process.pid}:#{identifier}\0"
50
- local.send_io(feature_pipe_r)
51
-
52
- # Now we run the action and report its success/fail status to the master.
53
- features = Zeus::LoadTracking.features_loaded_by {
54
- run_action(local, identifier)
55
- }
56
-
57
- # the master wants to know about the files that running the action caused us to load.
58
- Thread.new { notify_features(feature_pipe_w, features) }
59
-
60
- # We are now 'connected'. From this point, we may receive requests to fork.
61
- children = Set.new
62
- loop do
63
- messages = local.recv(2**16)
64
-
65
- # Reap any child runners or slaves that might have exited in
66
- # the meantime. Note that reaping them like this can leave <=1
67
- # zombie process per slave around while the slave waits for a
68
- # new command.
69
- children.each do |pid|
70
- children.delete(pid) if Process.waitpid(pid, Process::WNOHANG)
71
- end
45
+ # Thanks to the magic of fork, this following line will return
46
+ # many times: Every time the parent step receives a request to
47
+ # run a command.
48
+ if run_command = boot_steps(identifier)
49
+ ident, local = run_command
50
+ return command(ident, local)
51
+ end
52
+ end
72
53
 
73
- messages.split("\0").each do |new_identifier|
74
- new_identifier =~ /^(.):(.*)/
75
- code, ident = $1, $2
76
- pid = nil
77
- if code == "S"
78
- children << fork { go(ident.to_sym) }
79
- else
80
- children << fork { command(ident.to_sym, local) }
54
+ def boot_steps(identifier)
55
+ while true
56
+ boot_step = catch(:boot_step) do
57
+ $0 = "zeus slave: #{identifier}"
58
+
59
+ setup_dummy_tty!
60
+ master = setup_master_socket!
61
+ feature_pipe_r, feature_pipe_w = IO.pipe
62
+
63
+ # I need to give the master a way to talk to me exclusively
64
+ local, remote = UNIXSocket.pair(Socket::SOCK_STREAM)
65
+ master.send_io(remote)
66
+
67
+ # Now I need to tell the master about my PID and ID
68
+ local.write "P:#{Process.pid}:#{identifier}\0"
69
+ local.send_io(feature_pipe_r)
70
+ feature_pipe_r.close
71
+
72
+ # Now we run the action and report its success/fail status to the master.
73
+ features = Zeus::LoadTracking.features_loaded_by {
74
+ run_action(local, identifier, feature_pipe_w)
75
+ }
76
+
77
+ # the master wants to know about the files that running the action caused us to load.
78
+ Thread.new { notify_features(feature_pipe_w, features) }
79
+
80
+ # We are now 'connected'. From this point, we may receive requests to fork.
81
+ children = Set.new
82
+ while true
83
+ messages = local.recv(2**16)
84
+
85
+ # Reap any child runners or slaves that might have exited in
86
+ # the meantime. Note that reaping them like this can leave <=1
87
+ # zombie process per slave around while the slave waits for a
88
+ # new command.
89
+ children.each do |pid|
90
+ children.delete(pid) if Process.waitpid(pid, Process::WNOHANG)
91
+ end
92
+
93
+ messages.split("\0").each do |new_identifier|
94
+ new_identifier =~ /^(.):(.*)/
95
+ code, ident = $1, $2
96
+ pid = fork
97
+ if pid
98
+ # We're in the parent. Record the child:
99
+ children << pid
100
+ elsif code == "S"
101
+ # Child, supposed to start another step:
102
+ throw(:boot_step, ident.to_sym)
103
+ else
104
+ # Child, supposed to run a command:
105
+ return [ident.to_sym, local]
106
+ end
107
+ end
81
108
  end
82
109
  end
110
+ identifier = boot_step
83
111
  end
84
112
  end
85
113
 
@@ -94,11 +122,15 @@ module Zeus
94
122
  remote.close
95
123
  sock.close
96
124
 
97
- pid_and_arguments = local.recv(2**16) # if starting client before boot slave is latched, we get stuck here. We also get stuck here in #182.
98
- pid_and_arguments.chomp!("\0")
99
- pid_and_arguments =~ /(.*?):(.*)/
100
- client_pid, arguments = $1.to_i, $2
101
- arguments.chomp!("\0")
125
+ pid_and_argument_count = local.recv(2**16)
126
+ pid_and_argument_count.chomp("\0") =~ /(.*?):(.*)/
127
+ client_pid, argument_count = $1.to_i, $2.to_i
128
+ arg_io = local.recv_io
129
+ arguments = arg_io.read.chomp("\0").split("\0")
130
+
131
+ if arguments.length != argument_count
132
+ raise "Argument count mismatch: Expected #{argument_count}, got #{arguments.length}"
133
+ end
102
134
 
103
135
  pid = fork {
104
136
  $0 = "zeus command: #{identifier}"
@@ -111,7 +143,7 @@ module Zeus
111
143
  $stdin.reopen(client_terminal)
112
144
  $stdout.reopen(client_terminal)
113
145
  $stderr.reopen(client_terminal)
114
- ARGV.replace(JSON.parse(arguments))
146
+ ARGV.replace(arguments)
115
147
 
116
148
  plan.send(identifier)
117
149
  }
@@ -161,13 +193,22 @@ module Zeus
161
193
  local.write str
162
194
  end
163
195
 
164
- def run_action(socket, identifier)
165
- plan.after_fork unless identifier == :boot
166
- plan.send(identifier)
167
- socket.write "R:OK\0"
168
- rescue Exception => e
169
- report_error_to_master(socket, e)
196
+ def run_action(socket, identifier, feature_pipe_w)
197
+ loaded = false
198
+ begin
199
+ plan.after_fork unless identifier == :boot
200
+ plan.send(identifier)
201
+ loaded = true
202
+ socket.write "R:OK\0"
203
+ rescue Exception => e
204
+ report_error_to_master(socket, e)
205
+
206
+ # Report any setup-time failures back to the Zeus master:
207
+ unless loaded
208
+ notify_features(feature_pipe_w, Zeus::LoadTracking.all_features)
209
+ end
210
+ feature_pipe_w.close
211
+ end
170
212
  end
171
-
172
213
  end
173
214
  end
@@ -18,13 +18,13 @@ module Zeus
18
18
  add_extra_feature(path) if path
19
19
  end
20
20
 
21
- private
22
-
23
21
  def all_features
24
22
  untracked = defined?($untracked_features) ? $untracked_features : []
25
23
  $LOADED_FEATURES + untracked
26
24
  end
27
25
 
26
+ private
27
+
28
28
  def add_extra_feature(path)
29
29
  $untracked_features ||= []
30
30
  $untracked_features << path
@@ -198,9 +198,7 @@ module Zeus
198
198
  case framework
199
199
  when :minitest
200
200
  nerf_test_unit_autorunner
201
- exit_code = nil
202
- at_exit { exit false if exit_code && exit_code != 0 }
203
- exit_code = MiniTest::Unit.runner.run test_arguments
201
+ exit(MiniTest::Unit.runner.run(test_arguments).to_i)
204
202
  when :testunit1, :testunit2
205
203
  exit Test::Unit::AutoRunner.run(false, nil, test_arguments)
206
204
  else
@@ -221,7 +219,7 @@ module Zeus
221
219
  abort_with_no_test_found_by_line_number if @tests_to_run.empty?
222
220
 
223
221
  # assemble the regexp to run these tests,
224
- test_names = @tests_to_run.map(&:name).join('|')
222
+ test_names = @tests_to_run.map(&:escaped_name).join('|')
225
223
 
226
224
  # set up the args needed for the runner
227
225
  ["-n", "/(#{test_names})/"]
@@ -248,7 +246,7 @@ module Zeus
248
246
  # For every test ordered by line number,
249
247
  # spit out the test name and line number where it starts,
250
248
  tests.by_line_number do |test|
251
- message << "#{sprintf("%0#{tests.column_size}s", test.name)}: zeus test #{@files[0]}:#{test.start_line}\n"
249
+ message << "#{sprintf("%0#{tests.column_size}s", test.escaped_name)}: zeus test #{@files[0]}:#{test.start_line}\n"
252
250
  end
253
251
 
254
252
  # fail like a good unix process should.
@@ -256,7 +254,7 @@ module Zeus
256
254
  end
257
255
 
258
256
  def test_name_to_s
259
- @test_name.is_a?(Regexp)? "/#{@test_name.source}/" : @test_name
257
+ @test_name.is_a?(Regexp)? "/#{Regexp.escape(@test_name.source)}/" : Regexp.escape(@test_name)
260
258
  end
261
259
 
262
260
  def user_specified_name?
@@ -30,6 +30,10 @@ module Zeus
30
30
  # Shove the given attributes into a new databag
31
31
  new(test_method, start_line, end_line)
32
32
  end
33
+
34
+ def escaped_name
35
+ Regexp.escape(name)
36
+ end
33
37
  end
34
38
  end
35
39
  end
@@ -7,13 +7,13 @@ ROOT_PATH = File.expand_path(Dir.pwd)
7
7
  RAILS_PATH = find_rails_path(ROOT_PATH)
8
8
  ENV_PATH = File.expand_path('config/environment', RAILS_PATH)
9
9
  BOOT_PATH = File.expand_path('config/boot', RAILS_PATH)
10
- APP_PATH = File.expand_path('config/application', RAILS_PATH)
10
+ APP_PATH = File.expand_path('config/application', RAILS_PATH) unless defined? APP_PATH
11
11
 
12
12
  require 'zeus'
13
13
 
14
14
  def gem_is_bundled?(gem)
15
15
  gemfile_lock_contents = File.read(ROOT_PATH + "/Gemfile.lock")
16
- gemfile_lock_contents.scan(/\b#{gem} \(([^=~><]+?)\)/).flatten.first
16
+ gemfile_lock_contents.scan(/^\s*#{gem} \(([^=~><]+?)\)/).flatten.first
17
17
  end
18
18
 
19
19
  if version = gem_is_bundled?('method_source')
@@ -24,14 +24,6 @@ require 'zeus/m'
24
24
 
25
25
  module Zeus
26
26
  class Rails < Plan
27
- def deprecated
28
- puts "Zeus 0.11.0 changed zeus.json. You'll have to rm zeus.json && zeus init."
29
- end
30
- alias_method :spec_helper, :deprecated
31
- alias_method :testrb, :deprecated
32
- alias_method :rspec, :deprecated
33
-
34
-
35
27
  def after_fork
36
28
  reconnect_activerecord
37
29
  restart_girl_friday
@@ -136,11 +128,11 @@ module Zeus
136
128
  end
137
129
 
138
130
  def console
139
- require 'rails/commands/console'
140
131
  if defined?(Pry) && IRB == Pry
141
132
  require "pry"
142
133
  Pry.start
143
134
  else
135
+ require 'rails/commands/console'
144
136
  ::Rails::Console.start(::Rails.application)
145
137
  end
146
138
  end
@@ -182,12 +174,24 @@ module Zeus
182
174
  end
183
175
 
184
176
  def test_helper
185
- if File.exists?(ROOT_PATH + "/spec/spec_helper.rb")
186
- require 'spec_helper'
187
- elsif File.exist?(ROOT_PATH + "/test/minitest_helper.rb")
188
- require 'minitest_helper'
177
+ # don't let minitest setup another exit hook
178
+ begin
179
+ require 'minitest/unit'
180
+ MiniTest::Unit.class_variable_set("@@installed_at_exit", true)
181
+ rescue LoadError
182
+ # noop
183
+ end
184
+
185
+ if ENV['RAILS_TEST_HELPER']
186
+ require ENV['RAILS_TEST_HELPER']
189
187
  else
190
- require 'test_helper'
188
+ if File.exists?(ROOT_PATH + "/spec/spec_helper.rb")
189
+ require 'spec_helper'
190
+ elsif File.exists?(ROOT_PATH + "/test/minitest_helper.rb")
191
+ require 'minitest_helper'
192
+ else
193
+ require 'test_helper'
194
+ end
191
195
  end
192
196
  end
193
197
 
@@ -201,20 +205,6 @@ module Zeus
201
205
  end
202
206
  end
203
207
 
204
- def cucumber_environment
205
- require 'cucumber/rspec/disable_option_parser'
206
- require 'cucumber/cli/main'
207
- @cucumber_runtime = Cucumber::Runtime.new
208
- end
209
-
210
- def cucumber(argv=ARGV)
211
- cucumber_main = Cucumber::Cli::Main.new(argv.dup)
212
- had_failures = cucumber_main.execute!(@cucumber_runtime)
213
- exit_code = had_failures ? 1 : 0
214
- exit exit_code
215
- end
216
-
217
-
218
208
  private
219
209
 
220
210
  SPEC_DIR_REGEXP = %r"(^|/)spec"
@@ -1,3 +1,3 @@
1
1
  module Zeus
2
- VERSION = "0.13.4.pre2"
2
+ VERSION = "0.15.0"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "ZEUS" "1" "May 2013" "" ""
4
+ .TH "ZEUS" "1" "April 2014" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBzeus\fR \- boot rails in under a second
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "ZEUS\-INIT" "1" "March 2013" "" ""
4
+ .TH "ZEUS\-INIT" "1" "April 2014" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBzeus\-init\fR \- Generate a template zeus\.json
@@ -14,4 +14,4 @@ DESCRIPTION
14
14
 
15
15
 
16
16
 
17
- March 2013 ZEUS-INIT(1)
17
+ April 2014 ZEUS-INIT(1)
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "ZEUS\-START" "1" "March 2013" "" ""
4
+ .TH "ZEUS\-START" "1" "April 2014" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBzeus\-start\fR \- Start a zeus server
@@ -15,4 +15,4 @@ DESCRIPTION
15
15
 
16
16
 
17
17
 
18
- March 2013 ZEUS-START(1)
18
+ April 2014 ZEUS-START(1)
@@ -72,4 +72,4 @@ BUILTIN COMMANDS
72
72
 
73
73
 
74
74
 
75
- May 2013 ZEUS(1)
75
+ April 2014 ZEUS(1)
@@ -20,12 +20,23 @@ def fake_suite
20
20
  :instance_method => fake_instance_method)
21
21
  end
22
22
 
23
+ def fake_suite_with_special_characters
24
+ @suite ||= stub("TestSuite",
25
+ :test_methods => [fake_special_characters_test_method],
26
+ :instance_method => fake_instance_method(fake_special_characters_test_method))
27
+ end
28
+
23
29
  def fake_test_method
24
30
  "test_method"
25
31
  end
26
32
 
27
- def fake_instance_method
33
+ def fake_special_characters_test_method
34
+ "test_my_test_method?"
35
+ end
36
+
37
+ def fake_instance_method(name=fake_test_method)
28
38
  @instance_method ||= stub("InstanceMethod",
29
39
  :source_location => ["path/to/file.rb", 2],
30
- :source => "def #{fake_test_method} \n assert true \n end")
40
+ :source => "def #{name} \n assert true \n end")
31
41
  end
42
+
@@ -1,83 +1,110 @@
1
1
  require 'spec_helper'
2
2
  require 'fake_mini_test'
3
3
 
4
- describe Zeus::M::Runner do
5
- Runner = Zeus::M::Runner
4
+ module Zeus::M
5
+ describe Runner do
6
6
 
7
- before do
8
- stub_mini_test_methods
9
- end
7
+ context "given a test with a question mark" do
8
+ before do
9
+ MiniTest::Unit::TestCase.stub!(:test_suites).and_return [fake_suite_with_special_characters]
10
+ MiniTest::Unit.stub!(:runner).and_return fake_runner
11
+ end
12
+
13
+ it "escapes the question mark when using line number" do
14
+ argv = ["path/to/file.rb:2"]
15
+
16
+ fake_runner.should_receive(:run).with(["-n", "/(test_my_test_method\\?)/"])
17
+
18
+ lambda { Runner.new(argv).run }.should exit_with_code(0)
19
+ end
10
20
 
11
- context "no option is given" do
12
- it "runs the test without giving any option" do
13
- argv = ["path/to/file.rb"]
21
+ it "escapes the question mark from explicit names" do
22
+ argv = ["path/to/file.rb", "--name", fake_special_characters_test_method]
14
23
 
15
- fake_runner.should_receive(:run).with([])
24
+ fake_runner.should_receive(:run).with(["-n", "test_my_test_method\\?"])
16
25
 
17
- lambda { Runner.new(argv).run }.should exit_with_code(0)
26
+ lambda { Runner.new(argv).run }.should exit_with_code(0)
27
+ end
18
28
  end
19
29
  end
20
30
 
21
- context "given a line number" do
22
- it "aborts if no test is found" do
23
- argv = ["path/to/file.rb:100"]
31
+ describe Runner do
32
+ before do
33
+ stub_mini_test_methods
34
+ end
35
+
36
+ context "no option is given" do
37
+ it "runs the test without giving any option" do
38
+ argv = ["path/to/file.rb"]
24
39
 
25
- STDERR.should_receive(:write).with(/No tests found on line 100/)
26
- fake_runner.should_not_receive :run
40
+ fake_runner.should_receive(:run).with([])
27
41
 
28
- lambda { Runner.new(argv).run }.should_not exit_with_code(0)
42
+ lambda { Runner.new(argv).run }.should exit_with_code(0)
43
+ end
29
44
  end
30
45
 
31
- it "runs the test if the correct line number is given" do
32
- argv = ["path/to/file.rb:2"]
46
+ context "given a line number" do
47
+ it "aborts if no test is found" do
48
+ argv = ["path/to/file.rb:100"]
33
49
 
34
- fake_runner.should_receive(:run).with(["-n", "/(#{fake_test_method})/"])
50
+ STDERR.should_receive(:write).with(/No tests found on line 100/)
51
+ fake_runner.should_not_receive :run
35
52
 
36
- lambda { Runner.new(argv).run }.should exit_with_code(0)
37
- end
38
- end
53
+ lambda { Runner.new(argv).run }.should_not exit_with_code(0)
54
+ end
39
55
 
40
- context "specifying test name" do
41
- it "runs the specified tests when using a pattern in --name option" do
42
- argv = ["path/to/file.rb", "--name", "/#{fake_test_method}/"]
56
+ it "runs the test if the correct line number is given" do
57
+ argv = ["path/to/file.rb:2"]
43
58
 
44
- fake_runner.should_receive(:run).with(["-n", "/#{fake_test_method}/"])
59
+ fake_runner.should_receive(:run).with(["-n", "/(#{fake_test_method})/"])
45
60
 
46
- lambda { Runner.new(argv).run }.should exit_with_code(0)
61
+ lambda { Runner.new(argv).run }.should exit_with_code(0)
62
+ end
47
63
  end
48
64
 
49
- it "runs the specified tests when using a pattern in -n option" do
50
- argv = ["path/to/file.rb", "-n", "/method/"]
65
+ context "specifying test name" do
66
+ it "runs the specified tests when using a pattern in --name option" do
67
+ argv = ["path/to/file.rb", "--name", "/#{fake_test_method}/"]
51
68
 
52
- fake_runner.should_receive(:run).with(["-n", "/method/"])
69
+ fake_runner.should_receive(:run).with(["-n", "/#{fake_test_method}/"])
53
70
 
54
- lambda { Runner.new(argv).run }.should exit_with_code(0)
55
- end
71
+ lambda { Runner.new(argv).run }.should exit_with_code(0)
72
+ end
56
73
 
57
- it "aborts if no test matches the given pattern" do
58
- argv = ["path/to/file.rb", "-n", "/garbage/"]
74
+ it "runs the specified tests when using a pattern in -n option" do
75
+ argv = ["path/to/file.rb", "-n", "/method/"]
59
76
 
60
- STDERR.should_receive(:write).with(%r{No test name matches \'/garbage/\'})
61
- fake_runner.should_not_receive :run
77
+ fake_runner.should_receive(:run).with(["-n", "/method/"])
62
78
 
63
- lambda { Runner.new(argv).run }.should_not exit_with_code(0)
64
- end
79
+ lambda { Runner.new(argv).run }.should exit_with_code(0)
80
+ end
65
81
 
66
- it "runs the specified tests when using a name (no pattern)" do
67
- argv = ["path/to/file.rb", "-n", "#{fake_test_method}"]
82
+ it "aborts if no test matches the given pattern" do
83
+ argv = ["path/to/file.rb", "-n", "/garbage/"]
68
84
 
69
- fake_runner.should_receive(:run).with(["-n", fake_test_method])
85
+ STDERR.should_receive(:write).with(%r{No test name matches \'/garbage/\'})
86
+ fake_runner.should_not_receive :run
70
87
 
71
- lambda { Runner.new(argv).run }.should exit_with_code(0)
72
- end
88
+ lambda { Runner.new(argv).run }.should_not exit_with_code(0)
89
+ end
90
+
91
+ it "runs the specified tests when using a name (no pattern)" do
92
+ argv = ["path/to/file.rb", "-n", "#{fake_test_method}"]
73
93
 
74
- it "aborts if no test matches the given test name" do
75
- argv = ["path/to/file.rb", "-n", "method"]
94
+ fake_runner.should_receive(:run).with(["-n", fake_test_method])
76
95
 
77
- STDERR.should_receive(:write).with(%r{No test name matches \'method\'})
78
- fake_runner.should_not_receive :run
96
+ lambda { Runner.new(argv).run }.should exit_with_code(0)
97
+ end
79
98
 
80
- lambda { Runner.new(argv).run }.should_not exit_with_code(0)
99
+ it "aborts if no test matches the given test name" do
100
+ argv = ["path/to/file.rb", "-n", "method"]
101
+
102
+ STDERR.should_receive(:write).with(%r{No test name matches \'method\'})
103
+ fake_runner.should_not_receive :run
104
+
105
+ lambda { Runner.new(argv).run }.should_not exit_with_code(0)
106
+ end
81
107
  end
82
108
  end
109
+
83
110
  end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ module Zeus
4
+ describe Rails do
5
+ subject(:rails) { Rails.new }
6
+
7
+ context "#test_helper" do
8
+ before(:each) do
9
+ rails.should_receive(:require).with("minitest/unit")
10
+ end
11
+
12
+ it "when ENV['RAILS_TEST_HELPER'] is set helper is loaded from variable" do
13
+ ENV['RAILS_TEST_HELPER'] = "a_test_helper"
14
+ rails.should_receive(:require).with("a_test_helper")
15
+
16
+ rails.test_helper
17
+ ENV.clear
18
+ end
19
+
20
+ it "when spec_helper exists spec_helper is required" do
21
+ mock_file_existence(ROOT_PATH + "/spec/spec_helper.rb", true)
22
+
23
+ rails.should_receive(:require).with("spec_helper")
24
+
25
+ rails.test_helper
26
+ end
27
+
28
+ it "when minitest_helper exists minitest_helper is required" do
29
+ mock_file_existence(ROOT_PATH + "/spec/spec_helper.rb", false)
30
+ mock_file_existence(ROOT_PATH + "/test/minitest_helper.rb", true)
31
+
32
+ rails.should_receive(:require).with("minitest_helper")
33
+
34
+ rails.test_helper
35
+ end
36
+
37
+ it "when there is no spec_helper or minitest_helper, test_helper is required" do
38
+ mock_file_existence(ROOT_PATH + "/spec/spec_helper.rb", false)
39
+ mock_file_existence(ROOT_PATH + "/test/minitest_helper.rb", false)
40
+
41
+ rails.should_receive(:require).with("test_helper")
42
+
43
+ rails.test_helper
44
+ end
45
+ end
46
+
47
+ context "#gem_is_bundled?" do
48
+ it "returns gem version from Gemfile.lock" do
49
+ File.stub(:read).and_return("
50
+ GEM
51
+ remote: https://rubygems.org/
52
+ specs:
53
+ exception_notification-rake (0.0.6)
54
+ exception_notification (~> 3.0.1)
55
+ rake (>= 0.9.0)
56
+ rake (10.0.4)
57
+ ")
58
+ gem_is_bundled?('rake').should == '10.0.4'
59
+ end
60
+ end
61
+ end
62
+ end
@@ -1,9 +1,5 @@
1
1
  require 'zeus/rails'
2
2
 
3
- module Zeus::M
4
- VERSION = "0.0.0.test"
5
- end
6
-
7
3
  RSpec::Matchers.define :exit_with_code do |exp_code|
8
4
  actual = nil
9
5
  match do |block|
@@ -31,6 +27,10 @@ def stub_system_methods
31
27
  Kernel.stub!(:load).and_return
32
28
  end
33
29
 
30
+ def mock_file_existence(file, result)
31
+ File.should_receive(:exists?).with(file).and_return(result)
32
+ end
33
+
34
34
  RSpec.configure do |config|
35
35
  config.before(:each) do
36
36
  stub_system_methods
@@ -28,6 +28,7 @@ Gem::Specification.new do |gem|
28
28
  gem.license = "MIT"
29
29
 
30
30
  gem.add_development_dependency "rspec", '~> 2.12.0'
31
+ gem.add_development_dependency "rake"
31
32
  gem.add_development_dependency "ronn", '>= 0.7.0'
32
33
 
33
34
  gem.add_runtime_dependency "method_source", ">= 0.6.7"
metadata CHANGED
@@ -1,64 +1,80 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zeus
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: 7
5
- version: 0.13.4.pre2
4
+ version: 0.15.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Burke Libbey
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-21 00:00:00.000000000 Z
12
+ date: 2014-04-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- version_requirements: !ruby/object:Gem::Requirement
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
19
21
  version: 2.12.0
20
- none: false
21
- name: rspec
22
22
  type: :development
23
23
  prerelease: false
24
- requirement: !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
25
26
  requirements:
26
27
  - - ~>
27
28
  - !ruby/object:Gem::Version
28
29
  version: 2.12.0
29
- none: false
30
30
  - !ruby/object:Gem::Dependency
31
- version_requirements: !ruby/object:Gem::Requirement
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
32
34
  requirements:
33
35
  - - ! '>='
34
36
  - !ruby/object:Gem::Version
35
- version: 0.7.0
36
- none: false
37
- name: ronn
37
+ version: '0'
38
38
  type: :development
39
39
  prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: ronn
40
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
41
50
  requirements:
42
51
  - - ! '>='
43
52
  - !ruby/object:Gem::Version
44
53
  version: 0.7.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
45
57
  none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.7.0
46
62
  - !ruby/object:Gem::Dependency
47
- version_requirements: !ruby/object:Gem::Requirement
63
+ name: method_source
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
48
66
  requirements:
49
67
  - - ! '>='
50
68
  - !ruby/object:Gem::Version
51
69
  version: 0.6.7
52
- none: false
53
- name: method_source
54
70
  type: :runtime
55
71
  prerelease: false
56
- requirement: !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
57
74
  requirements:
58
75
  - - ! '>='
59
76
  - !ruby/object:Gem::Version
60
77
  version: 0.6.7
61
- none: false
62
78
  description: Boot any rails app in under a second
63
79
  email:
64
80
  - burke@libbey.me
@@ -76,10 +92,10 @@ files:
76
92
  - examples/custom_plan/custom_plan.rb
77
93
  - examples/custom_plan/zeus.json
78
94
  - examples/zeus.json
79
- - ext/fsevents-wrapper/fsevents-wrapper
80
95
  - ext/inotify-wrapper/extconf.rb
81
96
  - ext/inotify-wrapper/inotify-wrapper.cpp
82
97
  - Gemfile
98
+ - Gemfile.lock
83
99
  - lib/zeus/load_tracking.rb
84
100
  - lib/zeus/m/test_collection.rb
85
101
  - lib/zeus/m/test_method.rb
@@ -98,6 +114,7 @@ files:
98
114
  - Rakefile
99
115
  - spec/fake_mini_test.rb
100
116
  - spec/m_spec.rb
117
+ - spec/rails_spec.rb
101
118
  - spec/spec_helper.rb
102
119
  - zeus.gemspec
103
120
  homepage: http://zeus.is
@@ -108,17 +125,23 @@ rdoc_options: []
108
125
  require_paths:
109
126
  - lib
110
127
  required_ruby_version: !ruby/object:Gem::Requirement
128
+ none: false
111
129
  requirements:
112
130
  - - ! '>='
113
131
  - !ruby/object:Gem::Version
114
132
  version: '0'
115
- none: false
133
+ segments:
134
+ - 0
135
+ hash: -829104412674281211
116
136
  required_rubygems_version: !ruby/object:Gem::Requirement
137
+ none: false
117
138
  requirements:
118
- - - ! '>'
139
+ - - ! '>='
119
140
  - !ruby/object:Gem::Version
120
- version: 1.3.1
121
- none: false
141
+ version: '0'
142
+ segments:
143
+ - 0
144
+ hash: -829104412674281211
122
145
  requirements: []
123
146
  rubyforge_project:
124
147
  rubygems_version: 1.8.23