single_test 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,7 +1,5 @@
1
1
  task :default do
2
- options = "--colour"
3
- files = FileList['spec/**/*_spec.rb'].map{|f| f.sub(%r{^spec/},'') }
4
- exec "cd spec && rspec #{options} #{files}"
2
+ exec "cd spec && rspec --colour single_test_spec.rb"
5
3
  end
6
4
 
7
5
  begin
data/Readme.md CHANGED
@@ -1,26 +1,35 @@
1
1
  Runs a single test/spec via rake.
2
2
 
3
- USAGE
3
+ INSTALLATION
4
4
  =====
5
- As Rails plugin:
5
+ ###As Rails plugin
6
+
6
7
  script/plugin install git://github.com/grosser/single_test.git
7
8
 
8
- As Gem:
9
- sudo gem install single_test
9
+ ###As Gem
10
+
11
+ sudo gem install single_test
12
+
13
+ Include in your Rakefile:
10
14
 
11
- # in your Rakefile
12
- require 'single_test'
13
- SingleTest.load_tasks
15
+ require 'single_test'
16
+ SingleTest.load_tasks
14
17
 
18
+ USAGE
19
+ =====
15
20
 
16
21
  ###Single test/spec
17
- Searchs for test-files matching the given name.
22
+ Searches for test-files matching the given name.
18
23
 
19
24
  rake spec:user #run spec/model/user_spec.rb
20
25
  rake test:users_c #run test/functional/users_controller_test.rb
21
26
  rake spec:admin/users_c #run spec/controllers/admin/users_controller_spec.rb
22
27
  rake test:u*hel #run test/helpers/user_helper_test.rb
23
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
+
24
33
  ###Single test-case/example
25
34
  rake spec:user:token #run the first spec in user_spec.rb that matches /token/
26
35
  rake test:user:token #run all tests in user_test.rb that match /token/
@@ -40,6 +49,7 @@ TIPS
40
49
  ====
41
50
  - if `script/spec` is missing, if will use just `spec` for specs (which solves some issues)
42
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`
43
53
 
44
54
  TODO
45
55
  ====
@@ -50,6 +60,8 @@ Authors
50
60
 
51
61
  ### [Contributors](http://github.com/grosser/single_test/contributors)
52
62
  - [Ian Young](https://github.com/iangreenleaf)
63
+ - [Lorrin Nelson](https://github.com/lorrin)
64
+ - [Jason King](https://github.com/smathy)
53
65
 
54
66
  [Michael Grosser](http://grosser.it)<br/>
55
67
  michael@grosser.it<br/>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
data/lib/single_test.rb CHANGED
@@ -49,7 +49,7 @@ module SingleTest
49
49
  # spec:user:blah --> [spec,user,blah]
50
50
  def parse_cli(call)
51
51
  raise "you should not have gotten here..." unless call =~ CMD_LINE_MATCHER
52
- arguments = call.split(":",3)
52
+ arguments = underscore(call).split(":",3)
53
53
  [
54
54
  arguments[0], #type
55
55
  arguments[1], #file name
@@ -109,6 +109,18 @@ module SingleTest
109
109
 
110
110
  private
111
111
 
112
+ # copied from Rails - so we're not dependent
113
+ def underscore(camel_cased_word)
114
+ word = camel_cased_word.to_s.dup
115
+ word.gsub!(/::/, '/')
116
+ word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
117
+ word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
118
+ word.tr!("-", "_")
119
+ word.downcase!
120
+ word
121
+ end
122
+
123
+
112
124
  def test_name_matcher(executable, file, test_name)
113
125
  if test_name and not executable.include?('rspec')
114
126
  # rspec 1 only supports full test names -> find a matching test-name
data/single_test.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{single_test}
8
- s.version = "0.4.1"
8
+ s.version = "0.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2011-07-01}
12
+ s.date = %q{2011-10-13}
13
13
  s.email = %q{grosser.michael@gmail.com}
14
14
  s.files = [
15
15
  "Gemfile",
@@ -34,6 +34,21 @@ describe SingleTest do
34
34
  it "does not split test name further" do
35
35
  SingleTest.parse_cli('test:something:else:oh:no')[2].should == 'else:oh:no'
36
36
  end
37
+
38
+ it "parses ClassNames" do
39
+ SingleTest.parse_cli('test:ClassNames')[1].should == 'class_names'
40
+ end
41
+
42
+ it "parses ClassNames::WithNamespaces" do
43
+ SingleTest.parse_cli('test:ClassNames::WithNamespaces')[1].should == 'class_names/with_namespaces'
44
+ end
45
+
46
+ it "doesn't confuse :s with ::s" do
47
+ parsed = SingleTest.parse_cli('test:ClassNames::WithNamespaces:foobar')
48
+ parsed[0].should == 'test'
49
+ parsed[1].should == 'class_names/with_namespaces'
50
+ parsed[2].should == 'foobar'
51
+ end
37
52
  end
38
53
 
39
54
  describe :find_test_file do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: single_test
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 1
10
- version: 0.4.1
9
+ - 2
10
+ version: 0.4.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-01 00:00:00 +02:00
18
+ date: 2011-10-13 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21