spe_cuke 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -2
- data/Gemfile.lock +1 -1
- data/README.rdoc +1 -1
- data/lib/spe_cuke/environment.rb +21 -0
- data/lib/spe_cuke/target/rspec.rb +9 -4
- data/lib/spe_cuke/version.rb +1 -1
- data/spec/fixtures/.bundle/config +3 -0
- data/spec/fixtures/Gemfile.lock.rspec1 +10 -0
- data/spec/fixtures/Gemfile.lock.rspec2 +18 -0
- data/spec/spe_cuke/environment_spec.rb +22 -0
- data/spec/spe_cuke/target_rspec_spec.rb +12 -0
- metadata +6 -3
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -24,7 +24,7 @@ when not bundlized but --format-executable in .gemrc
|
|
24
24
|
and has option to specify invoking via rake.
|
25
25
|
|
26
26
|
sc -r --line 32 spec/foobar/foobar_spec.rb #=>
|
27
|
-
|
27
|
+
bundle18 exec rake spec SPEC=spec/foobar/foobar_spec.rb:32
|
28
28
|
|
29
29
|
== Vim script
|
30
30
|
|
data/lib/spe_cuke/environment.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'rbconfig'
|
2
2
|
require 'pathname'
|
3
3
|
require 'yaml'
|
4
|
+
require 'drb'
|
5
|
+
require 'bundler'
|
4
6
|
|
5
7
|
module SpeCuke
|
6
8
|
class Environment
|
@@ -30,7 +32,26 @@ module SpeCuke
|
|
30
32
|
(@root + 'Rakefile').exist?
|
31
33
|
end
|
32
34
|
|
35
|
+
def bundled_version(gem_name)
|
36
|
+
return nil unless bundlized?
|
37
|
+
|
38
|
+
lp = Bundler::LockfileParser.new(gemfile_dot_lock)
|
39
|
+
lp.specs.detect{|bs| bs.name == gem_name}.version rescue nil
|
40
|
+
end
|
41
|
+
|
42
|
+
def spork_running?
|
43
|
+
begin
|
44
|
+
DRbObject.new_with_uri("druby://127.0.0.1:8989").respond_to?(:run)
|
45
|
+
rescue DRb::DRbConnError, Errno::ECONNREFUSED
|
46
|
+
return false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
33
50
|
private
|
51
|
+
def gemfile_dot_lock
|
52
|
+
(@root + 'Gemfile.lock').read
|
53
|
+
end
|
54
|
+
|
34
55
|
def bundle_exec
|
35
56
|
[executable_name('bundle'), 'exec']
|
36
57
|
end
|
@@ -12,14 +12,19 @@ module SpeCuke::Target
|
|
12
12
|
|
13
13
|
private
|
14
14
|
def raw_commands
|
15
|
-
cmds = [@env.command(
|
15
|
+
cmds = [@env.command(spec_command_base)]
|
16
16
|
cmds << self.class.default_options
|
17
|
-
if @line
|
18
|
-
|
19
|
-
end
|
17
|
+
cmds << '-fn' if @line # XXX
|
18
|
+
cmds << '--drb' if @env.spork_running?
|
20
19
|
cmds << fn_and_line
|
21
20
|
end
|
22
21
|
|
22
|
+
def spec_command_base
|
23
|
+
v = @env.bundled_version('rspec')
|
24
|
+
|
25
|
+
(v.nil? || v < Gem::Version.new("2.0.0.beta.0")) ? 'spec' : 'rspec'
|
26
|
+
end
|
27
|
+
|
23
28
|
def rake_commands
|
24
29
|
cmds = [@env.command('rake'), 'spec', "SPEC=#{fn_and_line}"]
|
25
30
|
if @line
|
data/lib/spe_cuke/version.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.2)
|
5
|
+
rspec (2.0.0.beta.20)
|
6
|
+
rspec-core (= 2.0.0.beta.20)
|
7
|
+
rspec-expectations (= 2.0.0.beta.20)
|
8
|
+
rspec-mocks (= 2.0.0.beta.20)
|
9
|
+
rspec-core (2.0.0.beta.20)
|
10
|
+
rspec-expectations (2.0.0.beta.20)
|
11
|
+
diff-lcs (>= 1.1.2)
|
12
|
+
rspec-mocks (2.0.0.beta.20)
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
rspec (>= 2.0.0.beta)
|
@@ -12,6 +12,28 @@ describe Environment do
|
|
12
12
|
end
|
13
13
|
subject { @env.command('rails') }
|
14
14
|
|
15
|
+
describe 'bundled_version' do
|
16
|
+
before do
|
17
|
+
@env.stub(:bundlized?).and_return true
|
18
|
+
end
|
19
|
+
subject { @env.bundled_version('rspec') }
|
20
|
+
|
21
|
+
context 'rspec 1.3.0' do
|
22
|
+
before do
|
23
|
+
@env.stub(:gemfile_dot_lock).and_return File.read('spec/fixtures/Gemfile.lock.rspec1')
|
24
|
+
end
|
25
|
+
it { should == Gem::Version.new("1.3.0") }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'rspec 2.0' do
|
29
|
+
before do
|
30
|
+
@env.stub(:gemfile_dot_lock).and_return File.read('spec/fixtures/Gemfile.lock.rspec2')
|
31
|
+
end
|
32
|
+
it { should == Gem::Version.new("2.0.0.beta.20") }
|
33
|
+
it { should > Gem::Version.new("2.0.0.beta.0") }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
15
37
|
describe '#command()' do
|
16
38
|
context 'bundlized & --gem_format_executable' do
|
17
39
|
before do
|
@@ -13,6 +13,7 @@ describe Target::Rspec do
|
|
13
13
|
@env = Environment.new
|
14
14
|
@env.stub!(:bundlized?).and_return false
|
15
15
|
@env.stub!(:gem_format_executable?).and_return false
|
16
|
+
@env.stub!(:spork_running?).and_return false
|
16
17
|
|
17
18
|
Target::Rspec.default_options = ['--color']
|
18
19
|
end
|
@@ -38,6 +39,17 @@ describe Target::Rspec do
|
|
38
39
|
it(%q[spec --color -l 40 spec/foo/bar_spec.rb]){ @target.execute! }
|
39
40
|
end
|
40
41
|
|
42
|
+
context 'spec/foo/bar_spec.rb on line:40/spork:true' do
|
43
|
+
before do
|
44
|
+
@env.stub!(:spork_running?).and_return true
|
45
|
+
@env.stub!(:prefer_rake?).and_return false
|
46
|
+
@target = Target::Rspec.new(@env, 'spec/foo/bar_spec.rb', 40)
|
47
|
+
SpeCuke.should_receive(:wrap_execute!).with(%w[spec --color -fn --drb spec/foo/bar_spec.rb:40])
|
48
|
+
end
|
49
|
+
|
50
|
+
it(%q[spec --color -l 40 spec/foo/bar_spec.rb]){ @target.execute! }
|
51
|
+
end
|
52
|
+
|
41
53
|
context 'spec/foo/bar_spec.rb w/Rakefile' do
|
42
54
|
before do
|
43
55
|
@env.stub!(:prefer_rake?).and_return true
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spe_cuke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- MOROHASHI Kyosuke
|
@@ -60,6 +60,9 @@ files:
|
|
60
60
|
- lib/spe_cuke/target/rspec.rb
|
61
61
|
- lib/spe_cuke/version.rb
|
62
62
|
- spe_cuke.gemspec
|
63
|
+
- spec/fixtures/.bundle/config
|
64
|
+
- spec/fixtures/Gemfile.lock.rspec1
|
65
|
+
- spec/fixtures/Gemfile.lock.rspec2
|
63
66
|
- spec/spe_cuke/environment_spec.rb
|
64
67
|
- spec/spe_cuke/target_cucumber_spec.rb
|
65
68
|
- spec/spe_cuke/target_rspec_spec.rb
|