guard-jruby-rspec 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Joe Kutner
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # guard-jruby-rspec
2
+
3
+ This guard extention allows you to run all of your specs on JRuby without the initial start up cost. *It does not run a subset of your specs like guard-rspec* and it does not trigger a run when a file changes.
4
+
5
+ Instead, this extension loads all of your application files in advance, and reloads any that change. That way, when you run RSpec, the JVM is already running, and your file have already been required.
6
+
7
+ ## How to Use
8
+
9
+ Just add this to your guard file:
10
+
11
+ guard 'jruby-rspec', :spec_paths => ["spec"]
12
+
13
+ Then run `guard` like this (probably with Bundler):
14
+
15
+ $ bundle exec guard
16
+ Using polling (Please help us to support your system better than that).
17
+ The signal USR1 is in use by the JVM and will not work correctly on this platform
18
+ Guard could not detect any of the supported notification libraries.
19
+ Guard is now watching at '~/myapp'
20
+ Guard::JRuby::RSpec is running, with RSpec!
21
+ .......
22
+
23
+ Finished in 0.735 seconds
24
+ 7 examples, 0 failures
25
+ >
26
+
27
+ The first time guard starts up, it will run all of your specs in order to bootstrap the runtime. This first run will be as slow as any other run on JRuby.
28
+
29
+ Once you change some files, and press return at the guard prompt to rerun your specs. You'll notice it's a lot faster than running `rspec` from the command line.
30
+
31
+ NOTE: sometime you have to hit return twice because stdin is flaky on JRuby. You probably see this message a lot, but it's okay:
32
+
33
+ stty: stdin isn't a terminal
34
+
35
+ This will be improved.
36
+
37
+ ## TODO
38
+
39
+ + Autorun specs like guard-rspec (want to integrate with guard-rspec so as to not duplicate all of it's logic).
40
+
41
+ + Allow for extra rspec options
42
+
43
+ + Fix the way guard uses stdin so its not flaky on JRuby
44
+
45
+ + Work out the kinks in gj-rspec script so that specs can be run in main terminal.
46
+
47
+ ## Author
48
+
49
+ [@codefinger](http://twitter.com/#!/codefinger)
@@ -0,0 +1 @@
1
+ require 'guard/jruby-rspec'
@@ -0,0 +1,69 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+ # require 'guard/jruby-rspec/runner'
4
+
5
+ module Guard
6
+ class JRubyRSpec < Guard
7
+ autoload :Runner, 'guard/jruby-rspec/runner'
8
+
9
+ def initialize(watchers = [], options = {})
10
+ @monitor = options[:monitor_file]
11
+ @monitor ||= ".guard-jruby-rspec"
12
+
13
+ @spec_paths = options[:spec_dir]
14
+ @spec_paths ||= ["spec"]
15
+
16
+ all_watchers = watchers + [
17
+ Watcher.new(@monitor),
18
+ Watcher.new(%r{^(.+)\.rb$}),
19
+ Watcher.new(%r{^(.+)\.(erb|haml)$})
20
+ ]
21
+
22
+ # touch the monitor file (lets the gjrspec know we're here)
23
+ #File.open(@monitor, "w") {}
24
+
25
+ super(all_watchers, options)
26
+
27
+ @runner = Runner.new(options)
28
+
29
+ end
30
+
31
+ # Call once when guard starts
32
+ def start
33
+ UI.info "Guard::JRuby::RSpec is running, with RSpec!"
34
+ run_all #if @options[:all_on_start]
35
+ end
36
+
37
+ def run_all
38
+ @runner.run(@spec_paths) # options should be configurable
39
+ end
40
+
41
+ def reload
42
+ #UI.info "reload!"
43
+ end
44
+
45
+ def run_on_change(paths)
46
+ paths.each do |p|
47
+ if File.exists?(p)
48
+ if p == @monitor
49
+ begin
50
+ pidfile = open(@monitor, "r+")
51
+ pid = pidfile.read
52
+
53
+ run_all
54
+
55
+ system("kill #{pid}") if (pid and !pid.empty?)
56
+ ensure
57
+ @runner.cleanup
58
+ end
59
+ else
60
+ # reload the file
61
+ load p
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ end
68
+ end
69
+
@@ -0,0 +1,42 @@
1
+ require 'rspec'
2
+
3
+ module Guard
4
+ class JRubyRSpec
5
+ class Runner
6
+
7
+ def initialize(options = {})
8
+ @pipefile = options[:pipefile]
9
+ @pipefile ||= ".guard-jruby-rspec-pipe"
10
+ cleanup
11
+ end
12
+
13
+ def cleanup
14
+ File.delete(@pipefile) if File.exists?(@pipefile)
15
+ end
16
+
17
+ def run(paths, options = {})
18
+ # it might be a problem to run Rspec within this runtime. Might have to create an
19
+ # auxillary java process and run it over there. That would just make this one a
20
+ # controller for the other one.
21
+ if File.exists?(@pipefile)
22
+
23
+ # instead of writing to the pipefile, we should probably use a
24
+ # formatter and write to /dev/null
25
+ orig_stdout = $stdout.clone
26
+ orig_stderr = $stderr.clone
27
+ begin
28
+ $stdout.reopen(@pipefile, "w")
29
+ $stderr.reopen(@pipefile, "w")
30
+ RSpec::Core::Runner.run(paths)
31
+ ensure
32
+ $stdout.reopen(orig_stdout)
33
+ $stderr.reopen(orig_stderr)
34
+ end
35
+ else
36
+ RSpec::Core::Runner.run(paths)
37
+ end
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,2 @@
1
+ guard 'jruby-rspec', :spec_paths => ["spec"]
2
+
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ module JRubyRSpecVersion
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-jruby-rspec
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Joe Kutner
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-05-29 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: guard
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.10.0
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: "2.7"
35
+ type: :development
36
+ version_requirements: *id002
37
+ description: Guard::JRuby::RSpec keeps a warmed up JVM ready to run your specs.
38
+ email:
39
+ - jpkutner@gmail.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files: []
45
+
46
+ files:
47
+ - lib/guard-jruby-rspec.rb
48
+ - lib/guard/jruby-rspec.rb
49
+ - lib/guard/jruby-rspec/runner.rb
50
+ - lib/guard/jruby-rspec/version.rb
51
+ - lib/guard/jruby-rspec/templates/Guardfile
52
+ - LICENSE
53
+ - README.md
54
+ homepage: http://rubygems.org/gems/guard-jruby-rspec
55
+ licenses: []
56
+
57
+ post_install_message:
58
+ rdoc_options: []
59
+
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 1.3.6
74
+ requirements: []
75
+
76
+ rubyforge_project: guard-jruby-rspec
77
+ rubygems_version: 1.8.15
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: Guard gem for JRuby RSpec
81
+ test_files: []
82
+