spork-local_process 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Jarmo Pertman
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.rdoc ADDED
@@ -0,0 +1,49 @@
1
+ = Spork Local Process
2
+
3
+ * Web: http://www.github.com/jarmo/spork-local_process
4
+ * Author: Jarmo Pertman (mailto:jarmo.p[at]gmail.com)
5
+
6
+ == DESCRIPTION
7
+
8
+ Spork Local Process is a run strategy for the Spork (https://github.com/timcharper/spork) library. It will
9
+ re-run all your tests in the same process again and again without using any fork-ing under *nix or DRb processes under Windows.
10
+ This library is useful when you are having problems with the Spork server solutions (especially on Windows).
11
+
12
+ Make your tests run fast again!
13
+
14
+ == USAGE
15
+
16
+ In your spec_helper.rb:
17
+ require "spork"
18
+ require "spork/local_process"
19
+
20
+ And in the `Spork.each_run` block load all files again.
21
+
22
+ That's all you have to do. No additional changes needed usually. Just run your tests without starting up the Spork process
23
+ itself.
24
+
25
+ == INSTALL
26
+
27
+ 1. `gem install spork-local_process`
28
+ 2. add `require "spork/local_process"` line to your `spec_helper.rb` right after `require "spork"`
29
+ 3. run tests as you normally would without starting the Spork itself
30
+ 4. run same tests again by pressing `enter` or use tab-completion-powered command line to run something else
31
+
32
+ == RELOADING FILES
33
+
34
+ Add load statements into `Spork.each_run` block to load all files again before each test run:
35
+ Dir.glob(File.join(File.dirname(__FILE__), "../lib/**/*.rb")).each {|f| load f}
36
+ Dir.glob(File.join(File.dirname(__FILE__), "**/*.rb")).delete_if {|f| File.basename(f) =~ %r{(_)?spec(_helper)?.rb$}}.each do |f|
37
+ load f
38
+ end
39
+
40
+ Use `require_all` (https://github.com/jarmo/require_all) gem's `#load_all` method to do it more easily.
41
+
42
+ Sometimes only reloading the files is not enough since deleted methods/classes won't disappear from the memory and
43
+ reassigning values to constants will show a warning. In these cases you can unload constants from the memory before loading files.
44
+ For example, to unload everything in the namespace of `MyApp` and a specific constant do something like this:
45
+ Spork::RunStrategy::LocalProcess.unload :MyApp, "YourApp::SOME_CONSTANT"
46
+
47
+ == Copyright
48
+
49
+ Copyright (c) 2011 Jarmo Pertman. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'rubygems'
2
+ require 'bundler/gem_tasks'
@@ -0,0 +1,12 @@
1
+ require "readline"
2
+
3
+ module Spork
4
+ module Ext
5
+ class TabCompletion
6
+ def self.init
7
+ Readline.completion_append_character = nil
8
+ Readline.completion_proc = proc {|s| Dir[s + "*"].map {|m| File.directory?(m) ? m + "/" : m}}
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ require File.dirname(__FILE__) + '/run_strategy/local_process'
2
+
3
+ unless Spork.using_spork?
4
+ test_framework = Spork::Runner.new([], STDERR, STDOUT).find_test_framework
5
+ Spork::RunStrategy::LocalProcess.new(test_framework).run(ARGV, STDERR, STDOUT)
6
+ end
@@ -0,0 +1,62 @@
1
+ require 'rubygems'
2
+ require 'spork'
3
+ require File.dirname(__FILE__) + '/../test_framework/rspec'
4
+ require File.dirname(__FILE__) + '/../ext/tab_completion'
5
+
6
+ class Spork::RunStrategy::LocalProcess < Spork::RunStrategy
7
+
8
+ def run(argv, stderr, stdout)
9
+ $stdout, $stderr = stdout, stderr
10
+ Spork::Ext::TabCompletion.init
11
+ filter = argv.join(" ")
12
+
13
+ # in some libedit versions first #push into history won't add the item to
14
+ # the history
15
+ 2.times {Readline::HISTORY.push filter}
16
+
17
+ while true
18
+ test_framework.preload
19
+
20
+ begin
21
+ run_proc :each
22
+ test_framework.reset
23
+ test_framework.run_tests(filter.split(" "), stderr, stdout)
24
+ run_proc :after_each
25
+ rescue Exception => e
26
+ puts "#{e.class}: #{e.message}"
27
+ puts e.backtrace
28
+ end
29
+
30
+ new_filter = Readline.readline(">> '#{filter}' or: ").strip
31
+ exit 0 if new_filter.downcase == "exit"
32
+
33
+ unless new_filter.empty?
34
+ Readline::HISTORY.push new_filter
35
+ filter = new_filter
36
+ end
37
+ end
38
+ end
39
+
40
+ def self.unload *consts
41
+ consts.each do |const|
42
+ const_str = const.to_s
43
+ super_consts, const_to_remove = const_str.scan(/(.*)::(.*)$/).flatten
44
+ if super_consts && Object.const_defined?(super_consts)
45
+ Object.const_get(super_consts).send(:remove_const, const_to_remove)
46
+ elsif Object.const_defined?(const_str)
47
+ Object.send(:remove_const, const_str)
48
+ end
49
+ end
50
+ end
51
+
52
+ private
53
+
54
+ def run_proc type
55
+ Spork.instance_eval do
56
+ run_procs = send("#{type}_run_procs").dup
57
+ send "exec_#{type}_run"
58
+ instance_variable_set "@#{type}_run_procs", run_procs
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,9 @@
1
+ class Spork::TestFramework::RSpec < Spork::TestFramework
2
+ def reset
3
+ if rspec1?
4
+ raise NotImplementedError
5
+ else
6
+ ::RSpec.instance_eval {@configuration = @world = nil}
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "spork-local_process"
6
+ s.version = "0.0.1"
7
+ s.authors = ["Jarmo Pertman"]
8
+ s.email = ["jarmo.p@gmail.com"]
9
+ s.homepage = "https://github.com/jarmo/spork-local_process"
10
+ s.summary = %q{Run your code in a local process with Spork again and again without reloading the whole environment each time.}
11
+ s.description = %q{Run your code in a local process with Spork again and again without reloading the whole environment each time.}
12
+ s.files = `git ls-files`.split("\n")
13
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
+ s.require_paths = ["lib"]
16
+
17
+ s.add_dependency "spork", "~>0.9.0.rc9"
18
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spork-local_process
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Jarmo Pertman
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-09-25 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: spork
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 15424151
29
+ segments:
30
+ - 0
31
+ - 9
32
+ - 0
33
+ - rc
34
+ - 9
35
+ version: 0.9.0.rc9
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ description: Run your code in a local process with Spork again and again without reloading the whole environment each time.
39
+ email:
40
+ - jarmo.p@gmail.com
41
+ executables: []
42
+
43
+ extensions: []
44
+
45
+ extra_rdoc_files: []
46
+
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE
51
+ - README.rdoc
52
+ - Rakefile
53
+ - lib/spork/ext/tab_completion.rb
54
+ - lib/spork/local_process.rb
55
+ - lib/spork/run_strategy/local_process.rb
56
+ - lib/spork/test_framework/rspec.rb
57
+ - spork-local_process.gemspec
58
+ homepage: https://github.com/jarmo/spork-local_process
59
+ licenses: []
60
+
61
+ post_install_message:
62
+ rdoc_options: []
63
+
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ hash: 3
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ requirements: []
85
+
86
+ rubyforge_project:
87
+ rubygems_version: 1.8.4
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Run your code in a local process with Spork again and again without reloading the whole environment each time.
91
+ test_files: []
92
+