single_test 0.5.2 → 0.6.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.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -0
- data/lib/single_test.rb +4 -2
- data/lib/{tasks/single_test.rake → single_test/tasks.rb} +0 -0
- data/lib/single_test/version.rb +3 -0
- metadata +38 -31
- metadata.gz.sig +0 -0
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -30
- data/Rakefile +0 -19
- data/Readme.md +0 -68
- data/VERSION +0 -1
- data/single_test.gemspec +0 -44
- data/spec/example_finder_test.txt +0 -7
- data/spec/single_test_spec.rb +0 -228
- data/spec/spec_helper.rb +0 -18
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 537339e81e907e5311250f9a6d0c079079b1cbef
|
4
|
+
data.tar.gz: b97a72cee31ccd029375ac5c2ba212bdd47aac77
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1ba786804d32649662109fba5de15a21176f3edda1da3345597c776537cf72d44be3697b9838b0e3c7dd1d0a4cc96c59017bdd75cf650234506966ed8b534d9e
|
7
|
+
data.tar.gz: bd3a99e06692aa384d1b78ab4c14d5d86648f242a345eaaf8a3beb6d78e3dd9d18d2690e7ac157303bb316b38eeba90af4a9bcc791a7da317cbbb43e7d5eacec
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
data/lib/single_test.rb
CHANGED
@@ -6,7 +6,7 @@ module SingleTest
|
|
6
6
|
CMD_LINE_MATCHER = /^(spec|test)\:.*(\:.*)?$/
|
7
7
|
|
8
8
|
def load_tasks
|
9
|
-
|
9
|
+
raise "replace this line with require 'single_test/tasks'"
|
10
10
|
end
|
11
11
|
|
12
12
|
def run_last(type)
|
@@ -80,7 +80,9 @@ module SingleTest
|
|
80
80
|
|
81
81
|
def run_test(type, file, test_name=nil)
|
82
82
|
case type.to_s
|
83
|
-
when 'test' then
|
83
|
+
when 'test' then
|
84
|
+
filter = test_name.to_s.length > 0 ? " -n /#{test_name}/" : ''
|
85
|
+
Rake.sh "ruby -Ilib:test #{file}#{filter}"
|
84
86
|
when 'spec' then
|
85
87
|
executable = spec_executable
|
86
88
|
options_file = "spec/spec.opts"
|
File without changes
|
metadata
CHANGED
@@ -1,74 +1,81 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: single_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.6.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Michael Grosser
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
|
-
cert_chain:
|
12
|
-
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDMjCCAhqgAwIBAgIBADANBgkqhkiG9w0BAQUFADA/MRAwDgYDVQQDDAdtaWNo
|
14
|
+
YWVsMRcwFQYKCZImiZPyLGQBGRYHZ3Jvc3NlcjESMBAGCgmSJomT8ixkARkWAml0
|
15
|
+
MB4XDTEzMDIwMzE4MTMxMVoXDTE0MDIwMzE4MTMxMVowPzEQMA4GA1UEAwwHbWlj
|
16
|
+
aGFlbDEXMBUGCgmSJomT8ixkARkWB2dyb3NzZXIxEjAQBgoJkiaJk/IsZAEZFgJp
|
17
|
+
dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMorXo/hgbUq97+kII9H
|
18
|
+
MsQcLdC/7wQ1ZP2OshVHPkeP0qH8MBHGg6eYisOX2ubNagF9YTCZWnhrdKrwpLOO
|
19
|
+
cPLaZbjUjljJ3cQR3B8Yn1veV5IhG86QseTBjymzJWsLpqJ1UZGpfB9tXcsFtuxO
|
20
|
+
6vHvcIHdzvc/OUkICttLbH+1qb6rsHUceqh+JrH4GrsJ5H4hAfIdyS2XMK7YRKbh
|
21
|
+
h+IBu6dFWJJByzFsYmV1PDXln3UBmgAt65cmCu4qPfThioCGDzbSJrGDGLmw/pFX
|
22
|
+
FPpVCm1zgYSb1v6Qnf3cgXa2f2wYGm17+zAVyIDpwryFru9yF/jJxE38z/DRsd9R
|
23
|
+
/88CAwEAAaM5MDcwCQYDVR0TBAIwADAdBgNVHQ4EFgQUsiNnXHtKeMYYcr4yJVmQ
|
24
|
+
WONL+IwwCwYDVR0PBAQDAgSwMA0GCSqGSIb3DQEBBQUAA4IBAQAlyN7kKo/NQCQ0
|
25
|
+
AOzZLZ3WAePvStkCFIJ53tsv5Kyo4pMAllv+BgPzzBt7qi605mFSL6zBd9uLou+W
|
26
|
+
Co3s48p1dy7CjjAfVQdmVNHF3MwXtfC2OEyvSQPi4xKR8iba8wa3xp9LVo1PuLpw
|
27
|
+
/6DsrChWw74HfsJN6qJOK684hJeT8lBYAUfiC3wD0owoPSg+XtyAAddisR+KV5Y1
|
28
|
+
NmVHuLtQcNTZy+gRht3ahJRMuC6QyLmkTsf+6MaenwAMkAgHdswGsJztOnNnBa3F
|
29
|
+
y0kCSWmK6D+x/SbfS6r7Ke07MRqziJdB9GuE1+0cIRuFh8EQ+LN6HXCKM5pon/GU
|
30
|
+
ycwMXfl0
|
31
|
+
-----END CERTIFICATE-----
|
32
|
+
date: 2013-08-17 00:00:00.000000000 Z
|
13
33
|
dependencies:
|
14
34
|
- !ruby/object:Gem::Dependency
|
15
35
|
name: rake
|
16
36
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
37
|
requirements:
|
19
|
-
- -
|
38
|
+
- - '>='
|
20
39
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0
|
40
|
+
version: '0'
|
22
41
|
type: :runtime
|
23
42
|
prerelease: false
|
24
43
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
44
|
requirements:
|
27
|
-
- -
|
45
|
+
- - '>='
|
28
46
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0
|
47
|
+
version: '0'
|
30
48
|
description:
|
31
|
-
email:
|
49
|
+
email: michael@grosser.it
|
32
50
|
executables: []
|
33
51
|
extensions: []
|
34
52
|
extra_rdoc_files: []
|
35
53
|
files:
|
36
|
-
- Gemfile
|
37
|
-
- Gemfile.lock
|
38
|
-
- Rakefile
|
39
|
-
- Readme.md
|
40
|
-
- VERSION
|
41
54
|
- lib/single_test.rb
|
42
|
-
- lib/tasks
|
43
|
-
- single_test.
|
44
|
-
- spec/example_finder_test.txt
|
45
|
-
- spec/single_test_spec.rb
|
46
|
-
- spec/spec_helper.rb
|
55
|
+
- lib/single_test/tasks.rb
|
56
|
+
- lib/single_test/version.rb
|
47
57
|
homepage: http://github.com/grosser/single_test
|
48
|
-
licenses:
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
49
61
|
post_install_message:
|
50
62
|
rdoc_options: []
|
51
63
|
require_paths:
|
52
64
|
- lib
|
53
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
66
|
requirements:
|
56
|
-
- -
|
67
|
+
- - '>='
|
57
68
|
- !ruby/object:Gem::Version
|
58
69
|
version: '0'
|
59
|
-
segments:
|
60
|
-
- 0
|
61
|
-
hash: -339983977063863514
|
62
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
71
|
requirements:
|
65
|
-
- -
|
72
|
+
- - '>='
|
66
73
|
- !ruby/object:Gem::Version
|
67
74
|
version: '0'
|
68
75
|
requirements: []
|
69
76
|
rubyforge_project:
|
70
|
-
rubygems_version:
|
77
|
+
rubygems_version: 2.0.6
|
71
78
|
signing_key:
|
72
|
-
specification_version:
|
79
|
+
specification_version: 4
|
73
80
|
summary: Rake tasks to invoke single tests/specs with rakish syntax
|
74
81
|
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
diff-lcs (1.1.3)
|
5
|
-
git (1.2.5)
|
6
|
-
jeweler (1.8.4)
|
7
|
-
bundler (~> 1.0)
|
8
|
-
git (>= 1.2.5)
|
9
|
-
rake
|
10
|
-
rdoc
|
11
|
-
json (1.7.6)
|
12
|
-
rake (10.0.3)
|
13
|
-
rdoc (3.12.1)
|
14
|
-
json (~> 1.4)
|
15
|
-
rspec (2.12.0)
|
16
|
-
rspec-core (~> 2.12.0)
|
17
|
-
rspec-expectations (~> 2.12.0)
|
18
|
-
rspec-mocks (~> 2.12.0)
|
19
|
-
rspec-core (2.12.2)
|
20
|
-
rspec-expectations (2.12.1)
|
21
|
-
diff-lcs (~> 1.1.3)
|
22
|
-
rspec-mocks (2.12.2)
|
23
|
-
|
24
|
-
PLATFORMS
|
25
|
-
ruby
|
26
|
-
|
27
|
-
DEPENDENCIES
|
28
|
-
jeweler
|
29
|
-
rake (> 0.9)
|
30
|
-
rspec (~> 2)
|
data/Rakefile
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
task :default do
|
2
|
-
sh "rspec spec"
|
3
|
-
end
|
4
|
-
|
5
|
-
begin
|
6
|
-
require 'jeweler'
|
7
|
-
project_name = 'single_test'
|
8
|
-
Jeweler::Tasks.new do |gem|
|
9
|
-
gem.name = project_name
|
10
|
-
gem.summary = "Rake tasks to invoke single tests/specs with rakish syntax"
|
11
|
-
gem.email = "grosser.michael@gmail.com"
|
12
|
-
gem.homepage = "http://github.com/grosser/#{project_name}"
|
13
|
-
gem.authors = ["Michael Grosser"]
|
14
|
-
end
|
15
|
-
|
16
|
-
Jeweler::GemcutterTasks.new
|
17
|
-
rescue LoadError
|
18
|
-
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler"
|
19
|
-
end
|
data/Readme.md
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
Runs a single test/spec via rake.
|
2
|
-
|
3
|
-
INSTALLATION
|
4
|
-
=====
|
5
|
-
###As Rails plugin
|
6
|
-
|
7
|
-
script/plugin install git://github.com/grosser/single_test.git
|
8
|
-
|
9
|
-
###As Gem
|
10
|
-
|
11
|
-
sudo gem install single_test
|
12
|
-
|
13
|
-
Include in your Rakefile:
|
14
|
-
|
15
|
-
require 'single_test'
|
16
|
-
SingleTest.load_tasks
|
17
|
-
|
18
|
-
USAGE
|
19
|
-
=====
|
20
|
-
|
21
|
-
###Single test/spec
|
22
|
-
Searches for test-files matching the given name.
|
23
|
-
|
24
|
-
rake spec:user #run spec/model/user_spec.rb
|
25
|
-
rake test:users_c #run test/functional/users_controller_test.rb
|
26
|
-
rake spec:admin/users_c #run spec/controllers/admin/users_controller_spec.rb
|
27
|
-
rake test:u*hel #run test/helpers/user_helper_test.rb
|
28
|
-
|
29
|
-
Searches for test-files by class (Foo::Bar -> foo/bar)
|
30
|
-
|
31
|
-
rake spec:Foo::Bar #run spec/foo/bar_spec.rb
|
32
|
-
|
33
|
-
###Single test-case/example
|
34
|
-
rake spec:user:token #run the first spec in user_spec.rb that matches /token/
|
35
|
-
rake test:user:token #run all tests in user_test.rb that match /token/
|
36
|
-
|
37
|
-
###Spec-server
|
38
|
-
rake spec:user X= #run test on spec_sever (if one is running...), very fast for quick failure pin-pointing
|
39
|
-
|
40
|
-
###All one by one
|
41
|
-
rake spec:one_by_one #run each spec/test one by one, to find tests that fail when ran
|
42
|
-
rake test:one_by_one #on their own or produce strange output
|
43
|
-
|
44
|
-
###For last mofified file
|
45
|
-
rake test:last
|
46
|
-
rake spec:last
|
47
|
-
|
48
|
-
TIPS
|
49
|
-
====
|
50
|
-
- if `script/spec` is missing, it will use just `spec` for specs (which solves some issues)
|
51
|
-
- run whole describe blocks: `describe 'xxx' do describe 'yyy'` --> `rake spec:file:'xxx yyy'`
|
52
|
-
- run single examples or describe blocks via line-numbers `rspec spec/foo_spec:123`
|
53
|
-
|
54
|
-
TODO
|
55
|
-
====
|
56
|
-
- make test:last more clever e.g. lib -> try spec + spec/lib
|
57
|
-
|
58
|
-
Authors
|
59
|
-
=======
|
60
|
-
|
61
|
-
### [Contributors](http://github.com/grosser/single_test/contributors)
|
62
|
-
- [Ian Young](https://github.com/iangreenleaf)
|
63
|
-
- [Lorrin Nelson](https://github.com/lorrin)
|
64
|
-
- [Jason King](https://github.com/smathy)
|
65
|
-
|
66
|
-
[Michael Grosser](http://grosser.it)<br/>
|
67
|
-
michael@grosser.it<br/>
|
68
|
-
Hereby placed under public domain, do what you want, just do not hold me accountable...
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.5.2
|
data/single_test.gemspec
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = "single_test"
|
8
|
-
s.version = "0.5.2"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Michael Grosser"]
|
12
|
-
s.date = "2013-02-08"
|
13
|
-
s.email = "grosser.michael@gmail.com"
|
14
|
-
s.files = [
|
15
|
-
"Gemfile",
|
16
|
-
"Gemfile.lock",
|
17
|
-
"Rakefile",
|
18
|
-
"Readme.md",
|
19
|
-
"VERSION",
|
20
|
-
"lib/single_test.rb",
|
21
|
-
"lib/tasks/single_test.rake",
|
22
|
-
"single_test.gemspec",
|
23
|
-
"spec/example_finder_test.txt",
|
24
|
-
"spec/single_test_spec.rb",
|
25
|
-
"spec/spec_helper.rb"
|
26
|
-
]
|
27
|
-
s.homepage = "http://github.com/grosser/single_test"
|
28
|
-
s.require_paths = ["lib"]
|
29
|
-
s.rubygems_version = "1.8.24"
|
30
|
-
s.summary = "Rake tasks to invoke single tests/specs with rakish syntax"
|
31
|
-
|
32
|
-
if s.respond_to? :specification_version then
|
33
|
-
s.specification_version = 3
|
34
|
-
|
35
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
36
|
-
s.add_runtime_dependency(%q<rake>, ["> 0.9"])
|
37
|
-
else
|
38
|
-
s.add_dependency(%q<rake>, ["> 0.9"])
|
39
|
-
end
|
40
|
-
else
|
41
|
-
s.add_dependency(%q<rake>, ["> 0.9"])
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
data/spec/single_test_spec.rb
DELETED
@@ -1,228 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe SingleTest do
|
4
|
-
describe :parse_cli do
|
5
|
-
def parse_cli(string)
|
6
|
-
SingleTest.parse_cli(string.freeze)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "finds the type spec" do
|
10
|
-
parse_cli('spec:something')[0].should == 'spec'
|
11
|
-
end
|
12
|
-
|
13
|
-
it "finds the type test" do
|
14
|
-
parse_cli('test:something:else')[0].should == 'test'
|
15
|
-
end
|
16
|
-
|
17
|
-
it "does not find another type" do
|
18
|
-
lambda{ parse_cli('oops:something:else') }.should raise_error
|
19
|
-
end
|
20
|
-
|
21
|
-
it "parses the file name" do
|
22
|
-
parse_cli('test:something:else')[1].should == 'something'
|
23
|
-
end
|
24
|
-
|
25
|
-
it "parses the test name" do
|
26
|
-
parse_cli('test:something:else')[2].should == 'else'
|
27
|
-
end
|
28
|
-
|
29
|
-
it "parses missing test name as nil" do
|
30
|
-
parse_cli('test:something')[2].should be_nil
|
31
|
-
end
|
32
|
-
|
33
|
-
it "parses empty test name as nil" do
|
34
|
-
parse_cli('test:something: ')[2].should be_nil
|
35
|
-
end
|
36
|
-
|
37
|
-
it "does not split test name further" do
|
38
|
-
parse_cli('test:something:else:oh:no')[2].should == 'else:oh:no'
|
39
|
-
end
|
40
|
-
|
41
|
-
it "parses ClassNames" do
|
42
|
-
parse_cli('test:ClassNames')[1].should == 'class_names'
|
43
|
-
end
|
44
|
-
|
45
|
-
it "parses ClassNames::WithNamespaces" do
|
46
|
-
parse_cli('test:ClassNames::WithNamespaces')[1].should == 'class_names/with_namespaces'
|
47
|
-
end
|
48
|
-
|
49
|
-
it "doesn't confuse :s with ::s" do
|
50
|
-
parsed = parse_cli('test:ClassNames::WithNamespaces:foobar')
|
51
|
-
parsed[0].should == 'test'
|
52
|
-
parsed[1].should == 'class_names/with_namespaces'
|
53
|
-
parsed[2].should == 'foobar'
|
54
|
-
end
|
55
|
-
|
56
|
-
it "doesn't mess with non-class names" do
|
57
|
-
parsed = parse_cli('test:ClassNames::WithNamespaces:FOOBAR')
|
58
|
-
parsed[2].should == 'FOOBAR'
|
59
|
-
end
|
60
|
-
|
61
|
-
it "doesn't mess with mixed case filenames" do
|
62
|
-
parsed = parse_cli('test:a/fileName/withMixedCase')
|
63
|
-
parsed[1].should == 'a/fileName/withMixedCase'
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe :find_test_file do
|
68
|
-
def make_file(path)
|
69
|
-
folder = File.dirname(path)
|
70
|
-
`mkdir -p #{folder}` unless File.exist?(folder)
|
71
|
-
`touch #{path}`
|
72
|
-
raise unless File.exist?(path)
|
73
|
-
end
|
74
|
-
|
75
|
-
before do
|
76
|
-
`rm -rf spec`
|
77
|
-
end
|
78
|
-
|
79
|
-
it "finds exact matches first" do
|
80
|
-
make_file 'spec/mixins/xxx_spec.rb'
|
81
|
-
make_file 'spec/controllers/xxx_controller_spec.rb'
|
82
|
-
SingleTest.find_test_file('spec','xxx').should == 'spec/mixins/xxx_spec.rb'
|
83
|
-
end
|
84
|
-
|
85
|
-
it "finds lower files first" do
|
86
|
-
make_file 'spec/mixins/xxx_spec.rb'
|
87
|
-
make_file 'spec/mixins/xxx/xxx_spec.rb'
|
88
|
-
SingleTest.find_test_file('spec','xxx').should == 'spec/mixins/xxx_spec.rb'
|
89
|
-
end
|
90
|
-
|
91
|
-
it "finds short matches first" do
|
92
|
-
make_file 'spec/models/xxx_spec.rb'
|
93
|
-
make_file 'spec/controllers/xxx_controller_spec.rb'
|
94
|
-
SingleTest.find_test_file('spec','xx').should == 'spec/models/xxx_spec.rb'
|
95
|
-
end
|
96
|
-
|
97
|
-
it "finds with wildcards" do
|
98
|
-
make_file 'spec/controllers/admin/xxx_controller_spec.rb'
|
99
|
-
SingleTest.find_test_file('spec','ad*/x?x').should == 'spec/controllers/admin/xxx_controller_spec.rb'
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe :find_example_in_spec do
|
104
|
-
examples_file = File.join(File.dirname(__FILE__),'example_finder_test.txt')
|
105
|
-
|
106
|
-
it "finds a complete statement" do
|
107
|
-
SingleTest.find_example_in_spec(examples_file,'example 1').should == 'example 1'
|
108
|
-
end
|
109
|
-
|
110
|
-
it "finds a partial statement" do
|
111
|
-
SingleTest.find_example_in_spec(examples_file,'mple 1').should == 'example 1'
|
112
|
-
end
|
113
|
-
|
114
|
-
it "finds in strangely formatted files" do
|
115
|
-
SingleTest.find_example_in_spec(examples_file,'2').should == 'example "2"'
|
116
|
-
end
|
117
|
-
|
118
|
-
it "returns nil for unfound examples" do
|
119
|
-
SingleTest.find_example_in_spec(examples_file,'not here').should == nil
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
describe :run_last do
|
124
|
-
before do
|
125
|
-
`mkdir app` unless File.exist?('app')
|
126
|
-
`touch -t 01010000 app/yyy.rb`
|
127
|
-
`touch -t 01020000 app/xxx.rb`
|
128
|
-
`mkdir spec` unless File.exist?('spec')
|
129
|
-
`touch -t 01030000 spec/yyy_spec.rb`
|
130
|
-
`touch -t 01040000 spec/xxx_spec.rb`
|
131
|
-
end
|
132
|
-
|
133
|
-
it "runs the last test" do
|
134
|
-
SingleTest.should_receive(:run_test).with(:spec, "spec/xxx_spec.rb")
|
135
|
-
SingleTest.run_last(:spec)
|
136
|
-
end
|
137
|
-
|
138
|
-
it "runs another file when timestamps change" do
|
139
|
-
`touch -t 12312359 app/yyy.rb` # last minute in current year, spec will fail on new years eve :D
|
140
|
-
SingleTest.should_receive(:run_test).with(:spec, "spec/yyy_spec.rb")
|
141
|
-
SingleTest.run_last(:spec)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
describe :run_test do
|
146
|
-
before do
|
147
|
-
ENV['X']=nil
|
148
|
-
end
|
149
|
-
|
150
|
-
after do
|
151
|
-
ENV['X']=nil
|
152
|
-
end
|
153
|
-
|
154
|
-
it "fails when type is not spec/test" do
|
155
|
-
lambda{SingleTest.run_test('x','y')}.should raise_error
|
156
|
-
end
|
157
|
-
|
158
|
-
it "runs whole tests" do
|
159
|
-
Rake.should_receive(:sh).with('ruby -Ilib:test xxx -n //')
|
160
|
-
SingleTest.run_test('test','xxx')
|
161
|
-
end
|
162
|
-
|
163
|
-
it "runs single tests on their own" do
|
164
|
-
Rake.should_receive(:sh).with('ruby -Ilib:test xxx -n /yyy/')
|
165
|
-
SingleTest.run_test('test', 'xxx', 'yyy')
|
166
|
-
end
|
167
|
-
|
168
|
-
it "runs whole specs without -e" do
|
169
|
-
Rake.should_receive(:sh).with('export RAILS_ENV=test ; script/spec xxx')
|
170
|
-
SingleTest.run_test('spec','xxx')
|
171
|
-
end
|
172
|
-
|
173
|
-
it "runs all matching specs through -e for rspec 2" do
|
174
|
-
File.should_receive(:file?).with('script/spec').and_return false
|
175
|
-
File.stub!(:readlines).and_return ['it "bla yyy" do']
|
176
|
-
Rake.should_receive(:sh).with('export RAILS_ENV=test ; bundle exec rspec xxx -e "yyy"')
|
177
|
-
SingleTest.run_test('spec','xxx', 'yyy')
|
178
|
-
end
|
179
|
-
|
180
|
-
it "runs full single specs through -e for rspec 1" do
|
181
|
-
File.stub!(:readlines).and_return ['it "bla yyy" do']
|
182
|
-
Rake.should_receive(:sh).with('export RAILS_ENV=test ; script/spec xxx -e "bla yyy"')
|
183
|
-
SingleTest.run_test('spec','xxx', 'yyy')
|
184
|
-
end
|
185
|
-
|
186
|
-
it "runs single specs through -e with -X" do
|
187
|
-
File.stub!(:readlines).and_return []
|
188
|
-
ENV['X']=''
|
189
|
-
Rake.should_receive(:sh).with('export RAILS_ENV=test ; script/spec xxx -e "yyy" -X')
|
190
|
-
SingleTest.run_test('spec','xxx', 'yyy')
|
191
|
-
end
|
192
|
-
|
193
|
-
it "runs quoted specs though -e" do
|
194
|
-
File.stub!(:readlines).and_return []
|
195
|
-
Rake.should_receive(:sh).with(%Q(export RAILS_ENV=test ; script/spec xxx -e "y\\\"yy"))
|
196
|
-
SingleTest.run_test('spec','xxx', 'y"yy')
|
197
|
-
end
|
198
|
-
|
199
|
-
it "adds --options if spec.opts file exists" do
|
200
|
-
File.stub!(:exist?).and_return true
|
201
|
-
Rake.should_receive(:sh).with('export RAILS_ENV=test ; script/spec --options spec/spec.opts xxx')
|
202
|
-
SingleTest.run_test('spec','xxx')
|
203
|
-
end
|
204
|
-
|
205
|
-
it "runs with bundled spec if script/spec is not found" do
|
206
|
-
File.stub!(:file?).and_return false
|
207
|
-
File.should_receive(:file?).with('script/spec').and_return false
|
208
|
-
Rake.should_receive(:sh).with('export RAILS_ENV=test ; bundle exec rspec xxx')
|
209
|
-
SingleTest.run_test('spec','xxx')
|
210
|
-
end
|
211
|
-
|
212
|
-
it "uses bundler if Gemfile is present" do
|
213
|
-
File.stub!(:file?).and_return false
|
214
|
-
SingleTest.should_receive(:bundler_enabled?).and_return true
|
215
|
-
Rake.should_receive(:sh).with('export RAILS_ENV=test ; bundle exec rspec xxx')
|
216
|
-
SingleTest.run_test('spec','xxx')
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
describe :load_tasks do
|
221
|
-
it "can load em" do
|
222
|
-
result = Rake::Task['spec:one_by_one'] rescue nil
|
223
|
-
result.should == nil
|
224
|
-
SingleTest.load_tasks
|
225
|
-
Rake::Task['spec:one_by_one'].should_not == nil
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
SPEC_ROOT = File.dirname(__FILE__)
|
2
|
-
$LOAD_PATH << File.expand_path("../lib", SPEC_ROOT)
|
3
|
-
require "single_test"
|
4
|
-
|
5
|
-
Dir.chdir(SPEC_ROOT)
|
6
|
-
|
7
|
-
RSpec.configure do |config|
|
8
|
-
config.before do
|
9
|
-
`mkdir -p script`
|
10
|
-
`touch script/spec`
|
11
|
-
end
|
12
|
-
|
13
|
-
config.after do
|
14
|
-
`rm -rf script`
|
15
|
-
`rm -rf app`
|
16
|
-
`rm -rf spec`
|
17
|
-
end
|
18
|
-
end
|