spe_cuke 0.2.1 → 0.3.0
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/ChangeLog +3 -0
- data/Gemfile.lock +1 -1
- data/Rakefile +3 -1
- data/lib/spe_cuke/target/product_code.rb +45 -0
- data/lib/spe_cuke/version.rb +1 -1
- data/spec/spe_cuke/target_product_code_spec.rb +44 -0
- metadata +8 -6
- data/spec/fixtures/.bundle/config +0 -3
data/ChangeLog
ADDED
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
require 'spe_cuke/target/base'
|
3
|
+
require 'spe_cuke/target/rspec'
|
4
|
+
|
5
|
+
module SpeCuke::Target
|
6
|
+
class ProductCode < Base
|
7
|
+
extend Forwardable
|
8
|
+
class << self
|
9
|
+
attr_accessor :default_options
|
10
|
+
def suitable?(file)
|
11
|
+
!!paired_test(file)
|
12
|
+
end
|
13
|
+
|
14
|
+
def paired_test(file)
|
15
|
+
top, *rests = file.split('/')
|
16
|
+
return nil unless %w[lib app].include?(top)
|
17
|
+
spec = File.basename(rests.pop, '.rb') + '_spec.rb'
|
18
|
+
exactlly_paired(rests, spec) || fuzzy_paired(rests, spec)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def exactlly_paired(dirs, spec)
|
23
|
+
spec = ['spec', dirs, spec].flatten.join('/')
|
24
|
+
File.exist?(spec) && spec
|
25
|
+
end
|
26
|
+
|
27
|
+
def fuzzy_paired(dirs, spec)
|
28
|
+
dirs = dirs.dup
|
29
|
+
while merged = dirs.pop
|
30
|
+
spec = [merged, spec].join('_')
|
31
|
+
fullpath = ['spec', dirs, spec].flatten.join('/')
|
32
|
+
return fullpath if File.exist?(fullpath)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def_delegator :rspec_target, :execute!
|
38
|
+
|
39
|
+
private
|
40
|
+
def rspec_target
|
41
|
+
@rspec_target ||= Rspec.new(@env, self.class.paired_test(@fname))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
data/lib/spe_cuke/version.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'spe_cuke/environment'
|
4
|
+
require 'spe_cuke/target/product_code'
|
5
|
+
|
6
|
+
module SpeCuke::Target
|
7
|
+
describe ProductCode do
|
8
|
+
describe '.execute!' do
|
9
|
+
before do
|
10
|
+
@env = ::SpeCuke::Environment.new
|
11
|
+
@env.stub!(:bundlized?).and_return false
|
12
|
+
@env.stub!(:gem_format_executable?).and_return false
|
13
|
+
@env.stub!(:spork_running?).and_return false
|
14
|
+
|
15
|
+
@target = ProductCode.new(@env, 'lib/spe_cuke/target/product_code.rb')
|
16
|
+
|
17
|
+
spec = 'spec/spe_cuke/target/product_code_spec.rb'
|
18
|
+
File.should_receive(:exist?).with(spec).and_return true
|
19
|
+
SpeCuke.should_receive(:wrap_execute!).with(%w[spec --color] << spec)
|
20
|
+
end
|
21
|
+
it("should call wrap_execute with valid args"){ @target.execute! }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.paired_test' do
|
25
|
+
subject do
|
26
|
+
SpeCuke::Target::ProductCode.paired_test('lib/spe_cuke/target/product_code.rb')
|
27
|
+
end
|
28
|
+
|
29
|
+
it do
|
30
|
+
spec = 'spec/spe_cuke/target/product_code_spec.rb'
|
31
|
+
File.should_receive(:exist?).with(spec).and_return true
|
32
|
+
should == spec
|
33
|
+
end
|
34
|
+
|
35
|
+
it do
|
36
|
+
spec = 'spec/spe_cuke/target_product_code_spec.rb'
|
37
|
+
File.should_receive(:exist?).with('spec/spe_cuke/target/product_code_spec.rb').and_return false
|
38
|
+
File.should_receive(:exist?).with(spec).and_return true
|
39
|
+
should == spec
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
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: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- MOROHASHI Kyosuke
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-14 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -47,6 +47,7 @@ extra_rdoc_files: []
|
|
47
47
|
|
48
48
|
files:
|
49
49
|
- .gitignore
|
50
|
+
- ChangeLog
|
50
51
|
- Gemfile
|
51
52
|
- Gemfile.lock
|
52
53
|
- README.rdoc
|
@@ -57,14 +58,15 @@ files:
|
|
57
58
|
- lib/spe_cuke/target.rb
|
58
59
|
- lib/spe_cuke/target/base.rb
|
59
60
|
- lib/spe_cuke/target/cucumber.rb
|
61
|
+
- lib/spe_cuke/target/product_code.rb
|
60
62
|
- lib/spe_cuke/target/rspec.rb
|
61
63
|
- lib/spe_cuke/version.rb
|
62
64
|
- spe_cuke.gemspec
|
63
|
-
- spec/fixtures/.bundle/config
|
64
65
|
- spec/fixtures/Gemfile.lock.rspec1
|
65
66
|
- spec/fixtures/Gemfile.lock.rspec2
|
66
67
|
- spec/spe_cuke/environment_spec.rb
|
67
68
|
- spec/spe_cuke/target_cucumber_spec.rb
|
69
|
+
- spec/spe_cuke/target_product_code_spec.rb
|
68
70
|
- spec/spe_cuke/target_rspec_spec.rb
|
69
71
|
- spec/spec_helper.rb
|
70
72
|
has_rdoc: true
|