snailgun 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -9,8 +9,7 @@ command-line Ruby interpreter is required.
9
9
  Installation
10
10
  ------------
11
11
 
12
- sudo gem sources -a http://gems.github.com/
13
- sudo gem install candlerb-snailgun
12
+ sudo gem install snailgun
14
13
 
15
14
  Or for the latest code, `git clone git://github.com/candlerb/snailgun.git`
16
15
  and put the bin directory into your PATH.
@@ -60,7 +59,7 @@ with `snailgun -v` if you wish to be notified when it is ready.
60
59
  $ vi config/environments/test.rb
61
60
  ... set config.cache_classes = false
62
61
  $ snailgun
63
- Use 'exit' to terminate snailgun
62
+ Now entering subshell. Use 'exit' to terminate snailgun
64
63
 
65
64
  $ time RAILS_ENV=test fruby script/runner 'puts 1+2'
66
65
  3
@@ -126,11 +125,48 @@ the correct environment. e.g.
126
125
 
127
126
  RAILS_ENV=test fruby -Ilib -Itest test/unit/some_test.rb
128
127
 
128
+ Case 4: Rails with cucumber
129
+ ---------------------------
130
+
131
+ Cucumber creates its own Rails environment called "cucumber", so you can
132
+ setup snailgun like this:
133
+
134
+ $ snailgun --rails test,cucumber
135
+
136
+ Then use `frake cucumber` to exercise the features. frake selects the
137
+ "cucumber" environment if run with "cucumber" as an argument.
138
+
139
+ NOTE: to make your model classes be loaded on each run you need to set
140
+ `config.cache_classes = false` in `config/environments/cucumber.rb`.
141
+ Cucumber will give a big warning saying that this is known to be a
142
+ problem with transactional fixtures. I don't use transactional fixtures
143
+ so this isn't a problem for me.
144
+
145
+ For a substantial performance boost, remove `:lib=>false` lines from
146
+ `config/environments/cucumber.rb` so that cucumber, webrat, nokogiri etc
147
+ are preloaded.
148
+
149
+ Smaller performance boosts can be had from further preloading. For example,
150
+ cucumber makes use of some rspec libraries for diffing even if you're not
151
+ using rspec, so you can preload those. Add something like this to the end of
152
+ `config/environments/cucumber.rb`
153
+
154
+ begin
155
+ require 'spec/expectations'
156
+ require 'spec/runner/differs/default'
157
+ rescue LoadError
158
+ end
159
+ require 'test_help'
160
+ require 'test/unit/testresult'
161
+ require 'active_support/secure_random'
162
+ require 'active_support/time_with_zone'
163
+
129
164
  autotest
130
165
  --------
131
166
 
132
167
  There is some simple support for autotest (from the ZenTest package).
133
168
  Just type `fautotest` instead of `autotest` after snailgun has been started.
169
+ This hasn't been tested for a while.
134
170
 
135
171
  Bypassing rubygems
136
172
  ------------------
@@ -139,7 +175,7 @@ You can get noticeably faster startup if you don't use rubygems to invoke
139
175
  the programs. To do this, you can add the binary directory directly into
140
176
  the front of your PATH, e.g. for Ubuntu
141
177
 
142
- PATH=/var/lib/gems/1.8/gems/snailgun-1.0.2/bin:$PATH
178
+ PATH=/var/lib/gems/1.8/gems/snailgun-1.0.3/bin:$PATH
143
179
 
144
180
  Alternatively, create a file called `fruby` somewhere early on in your PATH
145
181
  (e.g. under `$HOME/bin`), like this:
data/bin/frake CHANGED
@@ -9,10 +9,13 @@ ARGV.each do |arg|
9
9
  end
10
10
  end
11
11
 
12
- # Make a guess at the correct environment
12
+ # Rails/Merb: make a guess at the correct environment
13
13
  if File.exist?("config/boot.rb") || File.exist?("config/init.rb")
14
- # Rails: default task is 'test'
15
- $DEFAULT_ENV='test' if ARGV.find { |arg| arg =~ /\b(test|spec)\b/ } || !ARGV.find { |arg| arg !~ /^-/ }
14
+ if ARGV.find { |arg| arg =~ /\bcucumber\b/ }
15
+ $DEFAULT_ENV='cucumber'
16
+ elsif ARGV.find { |arg| arg =~ /\b(test|spec)\b/ } || !ARGV.find { |arg| arg !~ /^-/ }
17
+ $DEFAULT_ENV='test'
18
+ end
16
19
  end
17
20
 
18
21
  ARGV[0,0] = ["-rrake", "-eRake.application.run", "--"]
data/bin/snailgun CHANGED
@@ -56,7 +56,7 @@ when :ruby
56
56
  when :rails
57
57
  conf = File.expand_path('config/boot.rb')
58
58
  unless File.exist?(conf)
59
- raise '#{conf} does not exist, cannot continue'
59
+ raise "#{conf} does not exist, cannot continue"
60
60
  end
61
61
  sockdir = File.expand_path('tmp/sockets/snailgun')
62
62
  begin
@@ -73,6 +73,7 @@ when :rails
73
73
  load conf
74
74
  require File.expand_path(RAILS_ROOT + '/config/environment')
75
75
  # We can get some drastic test speedups by preloading test frameworks
76
+ # (although user could do that in config/environments/test.rb)
76
77
  if env != 'test'
77
78
  # do nothing
78
79
  elsif File.exist?('test/test_helper.rb')
@@ -91,7 +92,7 @@ EOS
91
92
  server.run
92
93
  end
93
94
  end
94
- STDERR.puts "Use 'exit' to terminate snailgun"
95
+ STDERR.puts "Now entering subshell. Use 'exit' to terminate snailgun"
95
96
  Snailgun::Server.shell
96
97
  pids.each do |env,pid|
97
98
  Process.kill('TERM',pid)
@@ -25,7 +25,7 @@ module Snailgun
25
25
 
26
26
  def run
27
27
  while client = @socket.accept
28
- fork do
28
+ pid = fork do
29
29
  begin
30
30
  STDIN.reopen(client.recv_io)
31
31
  STDOUT.reopen(client.recv_io)
@@ -56,6 +56,7 @@ module Snailgun
56
56
  exit 1
57
57
  end
58
58
  end
59
+ Process.detach(pid) if pid && pid > 0
59
60
  client.close
60
61
  end
61
62
  ensure
@@ -92,7 +93,7 @@ module Snailgun
92
93
  end
93
94
 
94
95
  def self.shell
95
- system(ENV['shell'] || 'bash')
96
+ system(ENV['SHELL'] || 'bash')
96
97
  end
97
98
 
98
99
  # Interactive mode (start a subshell with SNAILGUN_SOCK set up,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snailgun
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Candler
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-19 00:00:00 +01:00
12
+ date: 2009-11-12 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies: []
15
15