autotest-rails-pure 4.1.1 → 4.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,11 @@
1
1
  Autotest for Test::Unit on Rails, including plugins for migrations and fixtures.
2
2
 
3
+ - independent of ZenTest
4
+ - added tests
5
+ - fixed namespace issues
6
+ - support application_controller.rb
7
+ - lib/foo/bar -> test/unit/foo/bar_test
8
+
3
9
  Install
4
10
  =======
5
11
 
@@ -7,10 +13,15 @@ Install
7
13
 
8
14
  TODO
9
15
  ====
10
- - add specs, e.g. which file is loaded when x changes
16
+ - add more tests: e.g. which file is loaded when x changes
17
+
18
+ Fork-contributors
19
+ =====
20
+ - [Nick Sutterer](http://nicksda.apotomo.de/)
21
+ - [Michael Grosser](http://grosser.it)
11
22
 
12
23
 
13
- LICENSE
24
+ Original LICENSE
14
25
  =======
15
26
 
16
27
  (The MIT License)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.1.1
1
+ 4.1.2
@@ -5,19 +5,16 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{autotest-rails-pure}
8
- s.version = "4.1.1"
8
+ s.version = "4.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ryan Davis"]
12
12
  s.date = %q{2010-11-07}
13
- s.extra_rdoc_files = [
14
- "README.markdown"
15
- ]
16
13
  s.files = [
17
14
  ".autotest",
18
15
  "History.txt",
19
- "README.markdown",
20
16
  "Rakefile",
17
+ "Readme.md",
21
18
  "VERSION",
22
19
  "autotest-rails-pure.gemspec",
23
20
  "lib/autotest/discover.rb",
@@ -10,77 +10,91 @@ class Autotest::Rails < Autotest
10
10
 
11
11
  clear_mappings
12
12
 
13
- self.add_mapping(/^lib\/.*\.rb$/) do |filename, _|
14
- impl = File.basename(filename, '.rb')
15
- files_matching %r%^test/unit/#{impl}_test.rb$%
16
- # TODO: (unit|functional|integration) maybe?
13
+ # lib/foo/bar.rb -> unit/foo/bar_test.rb
14
+ add_mapping %r%^lib/(.*)\.rb$% do |_, m|
15
+ "test/unit/#{m[1]}_test.rb"
17
16
  end
18
17
 
19
18
  add_mapping %r%^test/fixtures/(.*)s.yml% do |_, m|
20
- ["test/unit/#{m[1]}_test.rb",
21
- "test/controllers/#{m[1]}_controller_test.rb",
22
- "test/views/#{m[1]}_view_test.rb",
23
- "test/functional/#{m[1]}_controller_test.rb"]
19
+ [
20
+ "test/unit/#{m[1]}_test.rb",
21
+ "test/views/#{m[1]}_view_test.rb",
22
+ "test/controllers/#{m[1]}_controller_test.rb",
23
+ "test/functional/#{m[1]}_controller_test.rb"
24
+ ]
24
25
  end
25
26
 
26
- add_mapping %r%^test/(unit|integration|controllers|views|functional)/.*rb$% do |filename, _|
27
+ # test changes -> run test
28
+ add_mapping %r%^test/(#{test_namespaces*'|'})/.*rb$% do |filename, _|
27
29
  filename
28
30
  end
29
31
 
32
+ # model -> unit
30
33
  add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
31
34
  "test/unit/#{m[1]}_test.rb"
32
35
  end
33
36
 
37
+ # application_helper -> all views/helpers/controllers
34
38
  add_mapping %r%^app/helpers/application_helper.rb% do
35
- files_matching %r%^test/(views|functional)/.*_test\.rb$%
39
+ files_matching %r%^test/(views|functional|helpers)/.*_test\.rb$%
36
40
  end
37
41
 
42
+ # helper -> helper + view + controllers
38
43
  add_mapping %r%^app/helpers/(.*)_helper.rb% do |_, m|
39
- if m[1] == "application" then
40
- files_matching %r%^test/(views|functional)/.*_test\.rb$%
41
- else
42
- ["test/views/#{m[1]}_view_test.rb",
43
- "test/functional/#{m[1]}_controller_test.rb"]
44
- end
44
+ [
45
+ "test/views/#{m[1]}_view_test.rb",
46
+ "test/helpers/#{m[1]}_helper_test.rb",
47
+ "test/functional/#{m[1]}_controller_test.rb",
48
+ "test/controllers/#{m[1]}_controller_test.rb",
49
+ ]
45
50
  end
46
51
 
52
+ # view -> view + controller
47
53
  add_mapping %r%^app/views/(.*)/% do |_, m|
48
- ["test/views/#{m[1]}_view_test.rb",
49
- "test/functional/#{m[1]}_controller_test.rb"]
54
+ [
55
+ "test/views/#{m[1]}_view_test.rb",
56
+ "test/functional/#{m[1]}_controller_test.rb",
57
+ "test/controllers/#{m[1]}_controller_test.rb"
58
+ ]
59
+ end
60
+
61
+ # application_controller.rb -> all views/controllers
62
+ add_mapping %r%^app/controllers/application_controller\.rb$% do |_, m|
63
+ files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
50
64
  end
51
65
 
52
66
  add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
53
- if m[1] == "application" then
54
- files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
55
- else
56
- ["test/controllers/#{m[1]}_test.rb",
57
- "test/functional/#{m[1]}_test.rb"]
58
- end
67
+ [
68
+ "test/controllers/#{m[1]}_test.rb",
69
+ "test/functional/#{m[1]}_test.rb"
70
+ ]
59
71
  end
60
72
 
61
73
  add_mapping %r%^app/views/layouts/% do
62
74
  "test/views/layouts_view_test.rb"
63
75
  end
64
76
 
65
- add_mapping %r%^config/routes.rb$% do # FIX:
66
- files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
77
+ # routes -> views + controllers + integration
78
+ add_mapping %r%^config/routes.rb$% do
79
+ files_matching %r%^test/(controllers|views|functional|integration)/.*_test\.rb$%
67
80
  end
68
81
 
82
+ # config -> everything
69
83
  add_mapping %r%^test/test_helper.rb|config/((boot|environment(s/test)?).rb|database.yml)% do
70
- files_matching %r%^test/(unit|controllers|views|functional)/.*_test\.rb$%
84
+ files_matching %r%^test/(#{test_namespaces*'|'})/.*_test\.rb$%
71
85
  end
72
86
  end
73
87
 
74
- def ignored_namespaces
75
- 'unit|functional|integration|views|controllers|helpers|cells'
88
+ def test_namespaces
89
+ %w[unit functional integration views controllers helpers cells]
76
90
  end
77
91
 
78
92
  # Convert the pathname s to the name of class.
79
93
  def path_to_classname(s)
80
94
  sep = File::SEPARATOR
81
- parts = s.sub(/^test#{sep}((#{ignored_namespaces})#{sep})?/, '').sub(/\.rb$/, '').split(sep)
95
+ parts = s.sub(/^test#{sep}((#{test_namespaces*'|'})#{sep})?/, '').sub(/\.rb$/, '').split(sep)
82
96
  modules = parts.map { |path| path.split(/_/).map { |seg| seg.capitalize }.join }
83
- modules = modules.map { |path| path =~ /Test$/ ? path : "#{path}Test" }
97
+ modules[-1] = "#{modules.last}Test" unless modules.last =~ /Test$/
84
98
  modules.join('::')
85
99
  end
86
- end
100
+ end
@@ -15,12 +15,16 @@ class RailsTest < MiniTest::Unit::TestCase
15
15
  end
16
16
 
17
17
  it "should convert non-default namespaces" do
18
- assert_equal "FooTest::PostControllerTest", @at.path_to_classname("test/foo/post_controller_test.rb")
18
+ assert_equal "Foo::PostControllerTest", @at.path_to_classname("test/foo/post_controller_test.rb")
19
19
  end
20
20
 
21
21
  it "should convert normal namespaces inside ignored namespaces" do
22
- assert_equal "BloggingTest::PostControllerTest", @at.path_to_classname("test/controllers/blogging/post_controller_test.rb")
22
+ assert_equal "Blogging::PostControllerTest", @at.path_to_classname("test/controllers/blogging/post_controller_test.rb")
23
+ end
24
+
25
+ it "does not remove _test namespces" do
26
+ assert_equal "BloggingTest::PostControllerTest", @at.path_to_classname("test/controllers/blogging_test/post_controller_test.rb")
23
27
  end
24
28
  end
25
29
  end
26
- end
30
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autotest-rails-pure
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 63
5
5
  prerelease: false
6
6
  segments:
7
7
  - 4
8
8
  - 1
9
- - 1
10
- version: 4.1.1
9
+ - 2
10
+ version: 4.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Davis
@@ -25,13 +25,13 @@ executables: []
25
25
 
26
26
  extensions: []
27
27
 
28
- extra_rdoc_files:
29
- - README.markdown
28
+ extra_rdoc_files: []
29
+
30
30
  files:
31
31
  - .autotest
32
32
  - History.txt
33
- - README.markdown
34
33
  - Rakefile
34
+ - Readme.md
35
35
  - VERSION
36
36
  - autotest-rails-pure.gemspec
37
37
  - lib/autotest/discover.rb