spork-local_process 0.0.1 → 0.0.2

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/CHANGES ADDED
@@ -0,0 +1,7 @@
1
+ == 0.0.2 - 2011/09/25
2
+ * allow to specify example name like with -e from command line by entering something like this:
3
+ - spec/ "part of example name"
4
+ * reset RSpec differently to not lose global configuration
5
+
6
+ == 0.0.1 - 2011/09/25
7
+ * first version
data/README.rdoc CHANGED
@@ -13,37 +13,45 @@ Make your tests run fast again!
13
13
 
14
14
  == USAGE
15
15
 
16
- In your spec_helper.rb:
16
+ 1. Install the gem:
17
+ gem install spork-local_process
18
+
19
+ 2. Edit your spec_helper.rb file:
17
20
  require "spork"
18
21
  require "spork/local_process"
19
22
 
20
- And in the `Spork.each_run` block load all files again.
23
+ 3. Add load statements into Spork.each_run block to load all files again before each test run:
24
+ Dir.glob(File.join(File.dirname(__FILE__), "../lib/**/*.rb")).each {|f| load f}
25
+ Dir.glob(File.join(File.dirname(__FILE__), "**/*.rb")).delete_if {|f| File.basename(f) =~ %r{(_)?spec(_helper)?.rb$}}.each do |f|
26
+ load f
27
+ end
21
28
 
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.
29
+ 4. Run specs from command line:
30
+ rspec spec
24
31
 
25
- == INSTALL
32
+ 5. Press ENTER to run the same specs again or specify some new spec file with the help of tab-completion-powered command line:
33
+ spec/some_other_spec.rb # to run all the specs from that file
34
+ spec/some_other_spec.rb:33 # to run spec within range of line 33
35
+ spec/some_other_spec.rb "part of example name" # like -e option for RSpec when running from command line
26
36
 
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
37
+ 6. Type 'exit' to exit
31
38
 
32
- == RELOADING FILES
39
+ That's all you have to do. No additional changes needed usually. If Spork itself is started, then it is used normally instead
40
+ making Spork Local Process totally backwards compatible.
33
41
 
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
42
+ == RELOADING FILES
39
43
 
40
- Use `require_all` (https://github.com/jarmo/require_all) gem's `#load_all` method to do it more easily.
44
+ Make sure that you're loading all interesting files in your Spork.each_run block.
45
+ Use require_all (https://github.com/jarmo/require_all) gem's #load_all method to do it more easily.
41
46
 
42
47
  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:
48
+ reassigning values to constants will show warnings. In these cases you can unload constants from the memory before loading files.
49
+
50
+ For example, to unload everything in the module/class of MyApp and a specific constant do something like this:
45
51
  Spork::RunStrategy::LocalProcess.unload :MyApp, "YourApp::SOME_CONSTANT"
46
52
 
53
+ Everything nested in these constants (e.g. submodules/subclasses) will be unloaded.
54
+
47
55
  == Copyright
48
56
 
49
57
  Copyright (c) 2011 Jarmo Pertman. See LICENSE for details.
@@ -8,11 +8,13 @@ class Spork::RunStrategy::LocalProcess < Spork::RunStrategy
8
8
  def run(argv, stderr, stdout)
9
9
  $stdout, $stderr = stdout, stderr
10
10
  Spork::Ext::TabCompletion.init
11
- filter = argv.join(" ")
12
-
11
+
12
+ filter = argv
13
+ additional_options = nil
14
+
13
15
  # in some libedit versions first #push into history won't add the item to
14
16
  # the history
15
- 2.times {Readline::HISTORY.push filter}
17
+ 2.times {Readline::HISTORY.push argv.join(" ")}
16
18
 
17
19
  while true
18
20
  test_framework.preload
@@ -20,19 +22,21 @@ class Spork::RunStrategy::LocalProcess < Spork::RunStrategy
20
22
  begin
21
23
  run_proc :each
22
24
  test_framework.reset
23
- test_framework.run_tests(filter.split(" "), stderr, stdout)
25
+ test_framework.additional_options = additional_options if additional_options
26
+ test_framework.run_tests([filter].flatten, stderr, stdout)
24
27
  run_proc :after_each
25
28
  rescue Exception => e
26
29
  puts "#{e.class}: #{e.message}"
27
30
  puts e.backtrace
28
31
  end
29
32
 
30
- new_filter = Readline.readline(">> '#{filter}' or: ").strip
33
+ new_filter = Readline.readline("> '#{test_framework.options_str(filter, additional_options)}' or: ").strip
31
34
  exit 0 if new_filter.downcase == "exit"
32
35
 
33
36
  unless new_filter.empty?
34
37
  Readline::HISTORY.push new_filter
35
- filter = new_filter
38
+ filter, additional_options = new_filter.scan(/(.*[^"])(?:\s+"(.*)")/).flatten
39
+ filter = new_filter unless filter
36
40
  end
37
41
  end
38
42
  end
@@ -3,7 +3,19 @@ class Spork::TestFramework::RSpec < Spork::TestFramework
3
3
  if rspec1?
4
4
  raise NotImplementedError
5
5
  else
6
- ::RSpec.instance_eval {@configuration = @world = nil}
6
+ ::RSpec.reset
7
+ ::RSpec.configuration.formatters.clear if ::RSpec.configuration.formatters
8
+ ::RSpec::configuration.clear_inclusion_filter
7
9
  end
8
10
  end
11
+
12
+ def additional_options= options
13
+ ::RSpec::configuration.full_description = options
14
+ end
15
+
16
+ def options_str options, additional_options=nil
17
+ str = options.to_s.gsub("\\", "/")
18
+ str << " \"#{additional_options}\"" if additional_options
19
+ str
20
+ end
9
21
  end
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "spork-local_process"
6
- s.version = "0.0.1"
6
+ s.version = "0.0.2"
7
7
  s.authors = ["Jarmo Pertman"]
8
8
  s.email = ["jarmo.p@gmail.com"]
9
9
  s.homepage = "https://github.com/jarmo/spork-local_process"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spork-local_process
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jarmo Pertman
@@ -46,6 +46,7 @@ extra_rdoc_files: []
46
46
 
47
47
  files:
48
48
  - .gitignore
49
+ - CHANGES
49
50
  - Gemfile
50
51
  - LICENSE
51
52
  - README.rdoc