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.
@@ -0,0 +1,3 @@
1
+ == 0.3.0 / 2010-09-14
2
+ * assume test file from product code name.
3
+
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spe_cuke (0.2.1)
4
+ spe_cuke (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/Rakefile CHANGED
@@ -3,4 +3,6 @@ require 'bundler/setup'
3
3
  require 'spec/rake/spectask'
4
4
 
5
5
  Bundler::GemHelper.install_tasks
6
- Spec::Rake::SpecTask.new
6
+ Spec::Rake::SpecTask.new do |s|
7
+ s.spec_opts = %w[--color --format=profile]
8
+ end
@@ -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
+
@@ -1,3 +1,3 @@
1
1
  module SpeCuke
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -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: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
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-09 00:00:00 +09:00
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
@@ -1,3 +0,0 @@
1
- ---
2
- BUNDLE_DISABLE_SHARED_GEMS: "1"
3
- BUNDLE_PATH: foo