spork-local_process 0.0.6 → 0.0.7

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,4 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
data/Gemfile CHANGED
@@ -1,2 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
  gemspec
3
+
4
+ group :development, :test do
5
+ gem "rake"
6
+ gem "rspec"
7
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  * Web: http://www.github.com/jarmo/spork-local_process
4
4
  * Author: Jarmo Pertman (mailto:jarmo.p[at]gmail.com)
5
+ {<img src="http://travis-ci.org/jarmo/spork-local_process.png" />}[http://travis-ci.org/jarmo/spork-local_process]
5
6
 
6
7
  == DESCRIPTION
7
8
 
data/Rakefile CHANGED
@@ -1,2 +1,9 @@
1
1
  require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
2
4
  require 'bundler/gem_tasks'
5
+
6
+ require 'rspec/core/rake_task'
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task :default => :spec
@@ -22,7 +22,7 @@ class Spork::RunStrategy::LocalProcess < Spork::RunStrategy
22
22
  begin
23
23
  run_proc :each
24
24
  test_framework.additional_options = additional_options if additional_options
25
- test_framework.run_tests([filter].flatten, stderr, stdout)
25
+ test_framework.run_tests(filter, stderr, stdout)
26
26
  run_proc :after_each
27
27
  rescue Exception => e
28
28
  puts "#{e.class}: #{e.message}"
@@ -31,13 +31,25 @@ class Spork::RunStrategy::LocalProcess < Spork::RunStrategy
31
31
  test_framework.reset
32
32
  end
33
33
 
34
- new_filter = Readline.readline("> '#{test_framework.options_str(filter, additional_options)}' or: ").strip
34
+ new_filter = Readline.readline("> '#{(filter + (additional_options || [])).join(" ")}' or: ").strip
35
35
  exit 0 if new_filter.downcase == "exit"
36
36
 
37
37
  unless new_filter.empty?
38
38
  Readline::HISTORY.push new_filter
39
- filter, additional_options = new_filter.scan(/(.*[^"])(?:\s+"(.*)")/).flatten
40
- filter = new_filter unless filter
39
+ new_filter, *additional_options = new_filter.split(/\s+/)
40
+ additional_options = nil if additional_options.empty?
41
+ current_filter_without_lineno = filter_without_line_no filter[0]
42
+
43
+ if new_filter == "*"
44
+ filter = [current_filter_without_lineno]
45
+ elsif new_filter =~ /^:\d+$/
46
+ filter = [current_filter_without_lineno + new_filter]
47
+ elsif File.exist? filter_without_line_no new_filter
48
+ filter = [new_filter]
49
+ else
50
+ filter = [current_filter_without_lineno]
51
+ additional_options = [new_filter]
52
+ end
41
53
  end
42
54
  end
43
55
  end
@@ -56,6 +68,10 @@ class Spork::RunStrategy::LocalProcess < Spork::RunStrategy
56
68
 
57
69
  private
58
70
 
71
+ def filter_without_line_no filter
72
+ filter.gsub(/:\d+$/, "")
73
+ end
74
+
59
75
  def run_proc type
60
76
  Spork.instance_eval do
61
77
  run_procs = send("#{type}_run_procs").dup
@@ -4,20 +4,12 @@ class Spork::TestFramework::RSpec < Spork::TestFramework
4
4
  raise NotImplementedError
5
5
  else
6
6
  ::RSpec.reset
7
- ::RSpec.configuration.formatters.clear if ::RSpec.configuration.formatters
8
- ::RSpec.configuration.clear_inclusion_filter
9
- ::RSpec.world.shared_example_groups.clear
7
+ ::RSpec.configuration.inclusion_filter.clear
10
8
  end
11
9
  end
12
10
 
13
11
  def additional_options= options
14
- ::RSpec::configuration.full_description = options
12
+ ::RSpec::configuration.full_description = options.join(" ")
15
13
  end
16
14
 
17
- def options_str options, additional_options=nil
18
- str = options.is_a?(Array) ? options.join(" ") : options
19
- str = str.gsub("\\", "/")
20
- str << " \"#{additional_options}\"" if additional_options
21
- str
22
- end
23
15
  end
@@ -23,35 +23,80 @@ describe Spork::RunStrategy::LocalProcess do
23
23
  end
24
24
 
25
25
  it "allows to specify new filter" do
26
- test_framework = mock_test_framework "other_specs", 2
26
+ test_framework = mock_test_framework 2
27
27
  test_framework.should_receive(:run_tests).with(["other_specs"], STDERR, STDOUT)
28
28
  test_framework.should_not_receive(:additional_options=)
29
- test_framework.should_receive(:options_str).with("other_specs", nil).and_return("other_specs")
30
29
 
31
30
  Readline.should_receive(:readline).with("> 'some_specs' or: ").and_return("other_specs\n")
31
+ File.should_receive(:exist?).with("other_specs").and_return(true)
32
32
  Readline.should_receive(:readline).with("> 'other_specs' or: ").and_return("\n")
33
33
  Spork::RunStrategy::LocalProcess.new(test_framework).run(["some_specs"], STDERR, STDOUT)
34
34
  end
35
35
 
36
- it "allows to specify additional options" do
37
- test_framework = mock_test_framework "other_specs", 2
36
+ it "allows to specify additional options as a string" do
37
+ test_framework = mock_test_framework 2
38
38
  test_framework.should_receive(:run_tests).with(["other_specs"], STDERR, STDOUT)
39
- test_framework.should_receive(:additional_options=).with(%q[some additional opts])
40
- test_framework.should_receive(:options_str).with("other_specs", "some additional opts").and_return(%q[other_specs "some additional opts"])
39
+ test_framework.should_receive(:additional_options=).with(%w[some additional opts])
41
40
 
42
- Readline.should_receive(:readline).with("> 'some_specs' or: ").and_return(%Q[other_specs "some additional opts"\n])
43
- Readline.should_receive(:readline).with(%Q[> 'other_specs "some additional opts"' or: ]).and_return("\n")
41
+ Readline.should_receive(:readline).with("> 'some_specs' or: ").and_return(%Q[other_specs some additional opts\n])
42
+ File.should_receive(:exist?).with("other_specs").and_return(true)
43
+ Readline.should_receive(:readline).with(%Q[> 'other_specs some additional opts' or: ]).and_return("\n")
44
44
  Spork::RunStrategy::LocalProcess.new(test_framework).run(["some_specs"], STDERR, STDOUT)
45
45
  end
46
46
 
47
- it "allows to rerun specs with the same additional options" do
48
- test_framework = mock_test_framework "other_specs", 3
47
+ it "allows to rerun specs with the same additional options without entering new filter" do
48
+ test_framework = mock_test_framework 3
49
49
  test_framework.should_receive(:run_tests).with(["other_specs"], STDERR, STDOUT).exactly(2).times
50
- test_framework.should_receive(:additional_options=).with(%q[some additional opts]).exactly(2).times
51
- test_framework.should_receive(:options_str).with("other_specs", "some additional opts").exactly(2).times.and_return(%q[other_specs "some additional opts"])
50
+ test_framework.should_receive(:additional_options=).with(%w[some additional opts]).exactly(2).times
52
51
 
53
- Readline.should_receive(:readline).with("> 'some_specs' or: ").and_return(%Q[other_specs "some additional opts"\n])
54
- Readline.should_receive(:readline).exactly(2).times.with(%Q[> 'other_specs "some additional opts"' or: ]).and_return("\n")
52
+ Readline.should_receive(:readline).with("> 'some_specs' or: ").and_return(%Q[other_specs some additional opts\n])
53
+ File.should_receive(:exist?).with("other_specs").and_return(true)
54
+ Readline.should_receive(:readline).exactly(2).times.with(%Q[> 'other_specs some additional opts' or: ]).and_return("\n")
55
+ Spork::RunStrategy::LocalProcess.new(test_framework).run(["some_specs"], STDERR, STDOUT)
56
+ end
57
+
58
+ it "allows to specify '*' as a filter resetting additional options" do
59
+ test_framework = mock_test_framework 3
60
+ test_framework.should_receive(:run_tests).with(["other_specs"], STDERR, STDOUT).exactly(2).times
61
+ test_framework.should_receive(:additional_options=).with(%w[some additional opts])
62
+
63
+ Readline.should_receive(:readline).with("> 'some_specs' or: ").and_return(%Q[other_specs some additional opts\n])
64
+ File.should_receive(:exist?).with("other_specs").and_return(true)
65
+ Readline.should_receive(:readline).with(%Q[> 'other_specs some additional opts' or: ]).and_return("*\n")
66
+ Readline.should_receive(:readline).with(%Q[> 'other_specs' or: ]).and_return("\n")
67
+ Spork::RunStrategy::LocalProcess.new(test_framework).run(["some_specs"], STDERR, STDOUT)
68
+ end
69
+
70
+ it "allows to specify '*' as a filter resetting line number" do
71
+ test_framework = mock_test_framework 3
72
+ test_framework.should_receive(:run_tests).with(["other_specs"], STDERR, STDOUT)
73
+ test_framework.should_receive(:run_tests).with(["other_specs:42"], STDERR, STDOUT)
74
+ test_framework.should_not_receive(:additional_options=)
75
+
76
+ Readline.should_receive(:readline).with("> 'some_specs' or: ").and_return(%Q[other_specs:42\n])
77
+ File.should_receive(:exist?).with("other_specs").and_return(true)
78
+ Readline.should_receive(:readline).with(%Q[> 'other_specs:42' or: ]).and_return("*\n")
79
+ Readline.should_receive(:readline).with(%Q[> 'other_specs' or: ]).and_return("\n")
80
+ Spork::RunStrategy::LocalProcess.new(test_framework).run(["some_specs"], STDERR, STDOUT)
81
+ end
82
+
83
+ it "allows to specify ':\d+' as a filter for line number" do
84
+ test_framework = mock_test_framework 2
85
+ test_framework.should_receive(:run_tests).with(["some_specs:42"], STDERR, STDOUT)
86
+ test_framework.should_not_receive(:additional_options=)
87
+
88
+ Readline.should_receive(:readline).with("> 'some_specs' or: ").and_return(%Q[:42\n])
89
+ Readline.should_receive(:readline).with(%Q[> 'some_specs:42' or: ]).and_return("\n")
90
+ Spork::RunStrategy::LocalProcess.new(test_framework).run(["some_specs"], STDERR, STDOUT)
91
+ end
92
+
93
+ it "allows to specify ':\d+' as a filter for line number" do
94
+ test_framework = mock_test_framework 2
95
+ test_framework.should_receive(:run_tests).with(["some_specs:42"], STDERR, STDOUT)
96
+ test_framework.should_not_receive(:additional_options=)
97
+
98
+ Readline.should_receive(:readline).with("> 'some_specs' or: ").and_return(%Q[:42\n])
99
+ Readline.should_receive(:readline).with(%Q[> 'some_specs:42' or: ]).and_return("\n")
55
100
  Spork::RunStrategy::LocalProcess.new(test_framework).run(["some_specs"], STDERR, STDOUT)
56
101
  end
57
102
 
@@ -64,10 +109,9 @@ describe Spork::RunStrategy::LocalProcess do
64
109
  }.to raise_exception(SystemExit)
65
110
  end
66
111
 
67
- def mock_test_framework new_filter=nil, loop_count=1
112
+ def mock_test_framework loop_count=1
68
113
  test_framework = double('TestFramework')
69
114
  test_framework.should_receive(:run_tests).with(["some_specs"], STDERR, STDOUT)
70
- test_framework.should_receive(:options_str).with(["some_specs"], nil).and_return("some_specs")
71
115
 
72
116
  test_framework.should_receive(:preload).exactly(loop_count).times
73
117
  test_framework.should_receive(:reset).exactly(loop_count).times
@@ -1,18 +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.6"
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
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.7"
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"
18
+ end
metadata CHANGED
@@ -1,52 +1,43 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: spork-local_process
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 6
10
- version: 0.0.6
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Jarmo Pertman
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-09-30 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-04-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: spork
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
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
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.0
36
22
  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:
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.0
30
+ description: Run your code in a local process with Spork again and again without reloading
31
+ the whole environment each time.
32
+ email:
40
33
  - jarmo.p@gmail.com
41
34
  executables: []
42
-
43
35
  extensions: []
44
-
45
36
  extra_rdoc_files: []
46
-
47
- files:
37
+ files:
48
38
  - .gitignore
49
39
  - .rspec
40
+ - .travis.yml
50
41
  - CHANGES
51
42
  - Gemfile
52
43
  - LICENSE
@@ -60,36 +51,33 @@ files:
60
51
  - spork-local_process.gemspec
61
52
  homepage: https://github.com/jarmo/spork-local_process
62
53
  licenses: []
63
-
64
54
  post_install_message:
65
55
  rdoc_options: []
66
-
67
- require_paths:
56
+ require_paths:
68
57
  - lib
69
- required_ruby_version: !ruby/object:Gem::Requirement
58
+ required_ruby_version: !ruby/object:Gem::Requirement
70
59
  none: false
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- hash: 3
75
- segments:
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ segments:
76
65
  - 0
77
- version: "0"
78
- required_rubygems_version: !ruby/object:Gem::Requirement
66
+ hash: -694173807
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
68
  none: false
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- hash: 3
84
- segments:
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ segments:
85
74
  - 0
86
- version: "0"
75
+ hash: -694173807
87
76
  requirements: []
88
-
89
77
  rubyforge_project:
90
- rubygems_version: 1.8.4
78
+ rubygems_version: 1.8.21
91
79
  signing_key:
92
80
  specification_version: 3
93
- summary: Run your code in a local process with Spork again and again without reloading the whole environment each time.
81
+ summary: Run your code in a local process with Spork again and again without reloading
82
+ the whole environment each time.
94
83
  test_files: []
95
-