railscheck 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,6 +1,15 @@
1
- == 0.1.5 2008-yet to be releases
2
- * Adding javascript parse validation.
3
- * Adding preliminary ruby code parse validation.
1
+ == 0.2.0 2008-05-12
2
+ * Adding ruby syntax check validation.
3
+ * Adding prelimary rake and rjs syntax check validation.
4
+ * Added xml syntax check (unfortunately not fully validating - anyone knows a good & portable validating ruby parser ?)
5
+ * Added critical test that test database is not the same as development or production database.
6
+ * Added test/warning about Ruby-based MySQL driver (from original recipe by Mike Naberezny)
7
+ * Added check for rails 2.0 deprecations (adapted from original snippet by Mislav Marohnić + plugin by Geoffrey Grosenbach)
8
+ * Fix: Made internal ruby paths absolute for better compatibility with projects that override the ruby load path.
9
+ * Fix: Improved error message for db/migrations versioning inconsistency.
10
+ * Fix: Removed .svn and .cvs directories from all file searches.
11
+ * Refactoring: Renamed some test files / moved some tests around.
12
+ * Improved website and readme.
4
13
 
5
14
  == 0.1.4 2008-04-26
6
15
  * Fix: sqlite3 compatibility.
data/Manifest.txt CHANGED
@@ -11,12 +11,15 @@ config/requirements.rb
11
11
  lib/railscheck.rb
12
12
  lib/railscheck/testcase.rb
13
13
  lib/railscheck/version.rb
14
- lib/test/tc_associations.rb
15
14
  lib/test/tc_config.rb
16
- lib/test/tc_database_models.rb
15
+ lib/test/tc_database.rb
17
16
  lib/test/tc_html_and_css.rb
17
+ lib/test/tc_models.rb
18
18
  lib/test/tc_project.rb
19
+ lib/test/tc_rails_deprecations.rb
20
+ lib/test/tc_syntax_check_ruby.rb
19
21
  lib/test/tc_views.rb
22
+ lib/test/tc_xml.rb
20
23
  lib/test/test_helper.rb
21
24
  log/debug.log
22
25
  script/console
@@ -27,6 +30,4 @@ setup.rb
27
30
  tasks/deployment.rake
28
31
  tasks/environment.rake
29
32
  tasks/website.rake
30
- test/test_helper.rb
31
- test/test_railscheck.rb
32
33
  website/index.html
data/README.txt CHANGED
@@ -2,31 +2,21 @@
2
2
 
3
3
  == DESCRIPTION
4
4
 
5
- This project is (or will be) a best effort semi-static verifier for your Ruby on Rails projects. Delivered as
6
- a Ruby gem it provides a shell command task "railscheck" that you can run against your Rails projects to test
7
- for a number of typical bugs and inconsistencies.
5
+ This project is (or will be) a best effort semi-static verifier for your Ruby on Rails projects. Delivered as a Ruby gem it provides a shell command task "railscheck" that you can run against your Rails projects to test for a number of typical bugs and inconsistencies.
8
6
 
9
- It is a law of software development that the earlier you identify a problem the cheaper it is to fix. This project
10
- aims to help you quickly identify many bugs and inconsistencies as early as possible (thus avoiding unnecessary
11
- debugging work for you and your development team ; as well as avoiding unnecessary, negative "surprises" for your users).
7
+ It is a law of software development that the earlier you identify a problem the cheaper it is to fix. This project aims to help you quickly identify many bugs and inconsistencies as early as possible (thus avoiding unnecessary debugging work for you and your development team ; as well as avoiding unnecessary, negative "surprises" for your users).
12
8
 
13
- Typical ruby/rails development tools does not provide ANY kind of static verification checks since the problem
14
- appears to be just about unsolvable in the general case (because of the dynamic nature of Ruby). However for a
15
- strictly limited domain such as Rails Web Applications, there are actually many potential bugs that can be
16
- identified statically, or at least (semi-)statically, without having to start the web server and actually
17
- run the application.
9
+ Typical ruby/rails development tools does not provide ANY kind of static verification checks since the problem appears to be just about unsolvable in the general case (because of the dynamic nature of Ruby). However for a strictly limited domain such as Rails Web Applications, there are actually many potential bugs that can be identified statically, or at least (semi-)statically, without having to start the web server and actually run the application.
18
10
 
19
- Furthermore because of the opinionated nature of Rails, there are many conventions that can be broken and that we can
20
- check for. Finally rails projects depends on much more than just ruby code - i.e. migrations, database schemas, erb, html,
21
- css, yaml etc... All of which needs to work for an application to fully function and which is therefore in the scope of this
22
- this gem.
11
+ Furthermore because of the opinionated nature of Rails, there are many conventions that can be broken and that we can check for. Finally rails projects depends on much more than just ruby code - i.e. migrations, database schemas, erb, html, css, yaml etc... All of which needs to work for an application to fully function and which is therefore in the scope of this this gem.
23
12
 
24
- However, this project can not - and does not attempt to - find all logical/programming errors. As such the gem
25
- supplements and does not replace existing testing practices such as automated rails tests.
13
+ However, this project can not - and does not attempt to - find all logical/programming errors. As such the gem supplements and does not replace existing testing practices such as automated rails tests.
26
14
 
27
15
  == STATUS
28
16
 
29
- This project is a working beta. It works and is useful but has a very limited feature set. Much more to come. Use the rubyforge tracker function on the railscheck website to suggest features that you would like to be added (or bugs to fix)
17
+ This project is a working BETA. It works and is useful but has a very limited feature set. Much more to come. Currently the focus is on "low hanging fruits" (features that are easy to implement)
18
+
19
+ Use the rubyforge tracker function on the railscheck website to suggest features that you would like to be added (or bugs to fix)
30
20
 
31
21
  == INSTALLATION
32
22
 
@@ -51,24 +41,33 @@ Usage examples:
51
41
 
52
42
  == FEATURE SUMMARY
53
43
 
54
- Project (in test tc_project.rb):
55
- * Check validity of Ruby On Rails project structure and existence of key files necessary to
44
+ SYNTAX CHECKS & VALIDATION (static files)
45
+ * Syntax check of static *.rb, *.rake and *.rjs ruby files (in test tc_syntax_check_ruby.rb)
46
+ * Syntax check of *.yaml files (in test tc_config.rb)
47
+ * Syntax check of *.xml files (in test tc_xml.rb)
48
+ * Syntax check of *.erb, *.rhtml view files (in test tc_views.rb)
49
+ * Syntax check (online) of *.css files (in tc_html_and_css.rb) currently using W3C web services.
50
+ * Syntax check (online) of *.(x)html files (in tc_html_and_css.rb) currently using W3C web services.
51
+
52
+ CHECK FOR RAILS PROJECT CONSISTENCY (in test tc_project.rb):
53
+ * Validates Ruby On Rails project structure and existence of key files necessary to
56
54
  develop, test and deploy rails projects successfully.
57
-
58
- Configuration files (in test tc_config.rb):
59
- * Syntax check of all YAML configuration files in project
60
55
 
61
- Views (in test tc_views.rb):
62
- * Syntax check of all ERB configuration files in project
56
+ CHECK DATABASE (in test tc_database.rb):
57
+ * Checks that database is configured correct in project / ability to connect to database.
58
+ * Checks that database migration version corresponds to latest code migration version number in project.
59
+ * Checks that database drivers are fit for production use.
60
+ * Checks that test database does not overlap with development/production database.
63
61
 
64
- (X)HTML/CSS (in test tc_htl_and_css.rb):
65
- * Validation check of all static XHTML/HTML files in project (currently using W3C web services).
66
- * Validation check of all static CSS files in project (currently using W3C web services).
62
+ CHECK MODELS (in test tc_models.rb):
63
+ * Validates that tables with correct names exist for all ActiveRecord model classes in project.
64
+ * Validates that has_many, has_one, belongs_to and has_and_belongs_to_many associations uses the correct pluralization for names (there are subtle problems with activerecord if this is not the case).
67
65
 
68
- Database (in test tc_database_models.rb):
69
- * Validates that database is configured correct in project / ability to connect to database.
70
- * Validates that database migration version corresponds to latest code migration version number in project.
71
- * Validates that tables with correct names exist for all ActiveRecord model classes in project.
66
+ DEPRECATIONS (in test tc_rails_deprecations.rb)
67
+ * Warns if deprecated Rails constructs are used.
68
+
69
+ IN PROGRESS (NOT QUITE READY BUT DUE SOON):
70
+ * Syntax check of *.js javascript files (in test tc_javascript.rb)
72
71
 
73
72
  == PROJECT SITE AND DOCUMENTATION
74
73
 
@@ -94,15 +93,13 @@ compatibility with older Rails/ruby/gem versions). Some tests may require later
94
93
  == KNOWN BUGS
95
94
 
96
95
  - The jrailscheck.bat file generated by rubygems on windows invoke ruby instead of jruby. Users have to manually change the bat file installed in the ruby bin directory until I find out how to make rubygem behave correctly here.
96
+ - Line numbers reported by ruby syntax check is +1 too large.
97
97
 
98
98
  == CONTRIBUTING
99
99
 
100
- Any contributions to tests etc. that can be added are welcomed. Please contact undersigned for details.
101
-
102
- Any added code that you contribute will be given due credit. However make sure that you assign undersigned
103
- shared copyright so I am allowed to release and license your work together with this project.
100
+ You can easily add your test files to the "lib\test" folder. Checks are tests based on the ruby unit test framework and following the standard conventions they should be placed in Ruby files starting with "tc_" in order to be picked up by Railscheck automatically. All test classes should inherit from Railscheck::TestCase which in turns inherits from "Test::Unit::TestCase". See the existing test files for examples.
104
101
 
105
- You can easily add your test files to the "lib\test" folder. Tests are based on the ruby unit test framework and following the standard conventions they should be placed in Ruby files starting with "tc_" in order to be picked up by Railscheck automatically. All test classes should inherit from Railscheck::TestCase which in turns inherits from "Test::Unit::TestCase". See the existing test files for examples.
102
+ Any added code that you contribute will be given due credit! However make sure that you assign undersigned shared copyright so I am allowed to release and license your work together with this project.
106
103
 
107
104
  The source code is available anonymously (readonly) using subversion at the path:
108
105
  svn://rubyforge.org/var/svn/railscheck/trunk
@@ -113,7 +110,7 @@ svn+ssh://YOUR-RUBYFORGE-LOGIN-NAME@rubyforge.org/var/svn/railscheck/trunk
113
110
 
114
111
  == SUPPORT
115
112
 
116
- There is no formal support for this project. Please use railscheck.rubyforge.org to report problems/suggestions and the developer(s) will look at them in time.
113
+ There is no formal support for this project. Please use railscheck.rubyforge.org tracker/forums to report problems/suggestions and the developer(s) will look at them in time.
117
114
 
118
115
  == COPYRIGHT, ATTRIBUTIONS AND AUTHOR INFORMATION
119
116
 
@@ -127,11 +124,13 @@ information. See also my blog postings at "http://techblog.41concepts.com/" abou
127
124
  * ----> Submit your code additions and get your name added here!! <----
128
125
 
129
126
  INSPIRATION, ATTRIBUTIONS AND SPECIAL CREDITS:
130
- * Fail Early Task written by Mike Naberezny for Advanced Rail Recipes.
131
- * DZone Snippet Rails task to find code typos in rhtml templates by "dseverin"
127
+ * Dr Nic Williams for newgem tool and basic css design of website (with theme extended from Paul Battley).
128
+ * Fail Early and MySQL driver Tasks written by Mike Naberezny for Advanced Rail Recipes and on his blog on maintainable.com
129
+ * DZone Snippet Rails task to find code typos in rhtml templates by Dmitry Severin (dseverin).
130
+ * Rails 2.0 deprecations snippet by Mislav Marohnić (http://mislav.caboo.se)
131
+ * Rails deprecations plugin by Geoffrey Grosenbach (http://topfunky.net/svn/plugins/deprecated/)
132
132
 
133
- + Aaron Patterson for the Johnson javascript gem, Ryan Davis for the ruby parser,
134
- Alex Dunae for the W3C wrapper gem.
133
+ + Aaron Patterson for the Johnson javascript gem, Alex Dunae for the W3C wrapper gem.
135
134
 
136
135
  LICENSE INFORMATION:
137
136
  This software is FREE for both public and commercial use - with the possible exception of commercial
data/TODO.txt CHANGED
@@ -5,10 +5,9 @@ See below for a list of some future checks that are considered:
5
5
 
6
6
  SHORT/MID TERM:
7
7
 
8
- * Syntax check *.rjs
8
+
9
9
  * Verify other markup than erb.
10
10
  * Additional verification of migration files
11
- * Syntax check project rake files.
12
11
  * Verify *.cgi files.
13
12
  * Verify process and script files.
14
13
  * Shallow verification of known rails "declarations" such as before_filters, belongs_to etc.
data/lib/railscheck.rb CHANGED
@@ -5,10 +5,7 @@ rescue LoadError
5
5
  end
6
6
 
7
7
  require 'optparse'
8
- $:.unshift(File.dirname(__FILE__)) unless
9
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
10
-
11
- require 'railscheck/version'
8
+ require File.dirname(__FILE__) +'/railscheck/version'
12
9
 
13
10
  module Railscheck
14
11
  puts "Railscheck "+Railscheck::VERSION::STRING+" (nb. help & more information avilable with -h argument):"
@@ -54,6 +51,11 @@ BANNER
54
51
  has_project_dir_arg = (ARGV.length>0)
55
52
  railscheck_root_dir = has_project_dir_arg ? ARGV[0] : '.' # Use first non-option argument at root
56
53
 
54
+ # Require anything we need in advance before boot of our rails project can mess with it.
55
+ require 'test/unit'
56
+ require 'test/unit/testsuite'
57
+ require 'test/unit/ui/console/testrunner'
58
+
57
59
  puts "No directory provided. Using '"+railscheck_root_dir+"'" if !has_project_dir_arg
58
60
 
59
61
  begin
@@ -65,7 +67,7 @@ BANNER
65
67
  end
66
68
 
67
69
  puts "Booted RoR #{Rails::VERSION::STRING} project at \"#{RAILS_ROOT}\"."
68
- puts "Running all railscheck tests satifying /#{OPTIONS[:include_test_files]}/ " + (OPTIONS[:exclude_test_files].empty? ? ":" : "and not satifying /#{OPTIONS[:exclude_test_files]}/:" )
70
+ puts "Running all railscheck tests satisfying /#{OPTIONS[:include_test_files]}/ " + (OPTIONS[:exclude_test_files].empty? ? ":" : "and not satisfying /#{OPTIONS[:exclude_test_files]}/:" )
69
71
 
70
72
  # Get all test files from test folder and apply include/exclude filters.
71
73
  tests = []
@@ -73,8 +75,6 @@ BANNER
73
75
  tst_basename = File.basename(tstfile)
74
76
  tests << tstfile if (tst_basename =~ Regexp.new(OPTIONS[:include_test_files])) and (OPTIONS[:exclude_test_files].empty? || !(tst_basename =~ Regexp.new(OPTIONS[:exclude_test_files])))
75
77
  end
76
-
77
- require 'test/unit/testsuite'
78
78
 
79
79
  #test_suite = Test::Unit::TestSuite.new("Railscheck testsuite")
80
80
  #tests.sort.each do |tst|
@@ -90,5 +90,4 @@ BANNER
90
90
  require tst
91
91
  end
92
92
 
93
- require 'test/unit/ui/console/testrunner'
94
93
  end # module Railscheck
@@ -31,9 +31,18 @@ module Railscheck
31
31
  @@model_classes
32
32
  end
33
33
 
34
+ # Helper return list to filenames to always exclude.
35
+ def version_control_excludes
36
+ if !defined? @@model_classes
37
+ @@version_control_excludes=Dir["#{RAILS_ROOT}/**/.svn/**/*.*", "#{RAILS_ROOT}/**/.cvs/**/*.*"]
38
+ end
39
+
40
+ @@version_control_excludes
41
+ end
42
+
34
43
  # Helper: Handle warnings
35
44
  def warn(msg)
36
- puts "Warning: "+msg
45
+ puts "\nWarning: "+msg
37
46
  end
38
47
  end
39
48
  end
@@ -1,8 +1,8 @@
1
1
  module Railscheck #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 1
5
- TINY = 4
4
+ MINOR = 2
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,11 +1,11 @@
1
- require 'test/test_helper'
1
+ require File.dirname(__FILE__) +'/test_helper'
2
2
 
3
3
  module Railscheck
4
4
  module Test
5
5
  class Config < Railscheck::TestCase
6
6
  # Test that every yaml file in the project can parse (except vendor plugins/rails).
7
7
  def test_all_yaml_can_parse
8
- (Dir["#{RAILS_ROOT}/**/*.yml"]-Dir["#{RAILS_ROOT}/vendor/**/*.yml"]).each do |fname|
8
+ (Dir["#{RAILS_ROOT}/**/*.yml"]-Dir["#{RAILS_ROOT}/vendor/**/*.yml"]-version_control_excludes).each do |fname|
9
9
  assert_nothing_raised("Could not parse file \"#{fname}\".") do
10
10
  raise StandardError.new("Parse failed") if YAML.parse_file(fname)==nil
11
11
  end
@@ -0,0 +1,54 @@
1
+ require File.dirname(__FILE__) +'/test_helper'
2
+
3
+ module Railscheck
4
+ module Test
5
+ class DataBase < Railscheck::TestCase
6
+ # Test that database connection can be established.
7
+ def test_database_connection_working
8
+ assert File.file?("#{RAILS_ROOT}/config/database.yml"), "Database configuration file database.yml must be present"
9
+
10
+ assert_nothing_raised("Could not open database connection / no migration schema_info table in database") do
11
+ ActiveRecord::Base.establish_connection
12
+ ActiveRecord::Base.connection.select_all('select * from schema_info')
13
+ end
14
+ end
15
+
16
+ # Test that test database does not overlap with development/production database.
17
+ def test_database_connection_working
18
+ assert File.file?("#{RAILS_ROOT}/config/database.yml"), "Database configuration file database.yml must be present"
19
+
20
+ test_database = ActiveRecord::Base.configurations['test']['database']
21
+ development_database = ActiveRecord::Base.configurations['development']['database']
22
+ production_database = ActiveRecord::Base.configurations['production']['database']
23
+
24
+ assert_not_equal test_database, development_database, "Test database must NOT be the same as development database as this can cause your data to be erased!"
25
+ assert_not_equal test_database, production_database, "Test database must NOT be the same as production database as this can cause your data to be erased!"
26
+ end
27
+
28
+ # Test if driver used is suitable for production. Thanks to Mike Naberezny for the orginal code.
29
+ def test_driver_suitable_for_production
30
+ config = ActiveRecord::Base.configurations['production']
31
+ if config['adapter'] == 'mysql'
32
+ ActiveRecord::Base.require_mysql
33
+ ruby_based_mysql_driver = Mysql::VERSION.to_s.include?('-ruby')
34
+
35
+ if RAILS_ENV == 'production'
36
+ assert !ruby_based_mysql_driver, "Ruby-based MySQL driver is not suitable for production use"
37
+ else
38
+ warn "Ruby-based MySQL driver is not suitable for production use. Remember to change driver before switching to production use."
39
+ end
40
+ end
41
+ end
42
+
43
+ # Test that all migrations has been migrated. Thanks to Mike Naberezny for the orginal code.
44
+ def test_database_consistent_with_migration_version
45
+ db_version = ActiveRecord::Migrator.current_version rescue 0
46
+ highest_migration_version_in_project = Dir.glob("#{RAILS_ROOT}/db/migrate/*.rb" ).map { |f|
47
+ f.match(/(\d+)_.*\.rb$/) ? $1.to_i : 0
48
+ }.max || 0
49
+
50
+ assert_equal highest_migration_version_in_project, db_version, "Database version #{db_version} and migration version #{highest_migration_version_in_project} is inconsistent"+(db_version<highest_migration_version_in_project ? " (forgot to run db:migrate?)." : ".")
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,4 +1,4 @@
1
- require 'test/test_helper'
1
+ require File.dirname(__FILE__) +'/test_helper'
2
2
  require 'w3c_validators'
3
3
 
4
4
  module Railscheck
@@ -13,7 +13,7 @@ module Railscheck
13
13
  def test_all_css_validates
14
14
  @validator = CSSValidator.new
15
15
 
16
- Dir["#{RAILS_ROOT}/public/**/*.css", "#{RAILS_ROOT}/doc/**/*.css"].each do |fname|
16
+ (Dir["#{RAILS_ROOT}/public/**/*.css", "#{RAILS_ROOT}/doc/**/*.css"]-version_control_excludes).each do |fname|
17
17
  results = @validator.validate_file(fname)
18
18
 
19
19
  validation_errors = results.errors.length
@@ -34,7 +34,7 @@ module Railscheck
34
34
  def test_all_html_validates
35
35
  @validator = MarkupValidator.new
36
36
 
37
- Dir["#{RAILS_ROOT}/public/**/*.html", "#{RAILS_ROOT}/public/**/*.xhtml", "#{RAILS_ROOT}/doc/**/*.html", "#{RAILS_ROOT}/doc/**/*.xhtml"].each do |fname|
37
+ (Dir["#{RAILS_ROOT}/public/**/*.html", "#{RAILS_ROOT}/public/**/*.xhtml", "#{RAILS_ROOT}/doc/**/*.html", "#{RAILS_ROOT}/doc/**/*.xhtml"]-version_control_excludes).each do |fname|
38
38
  results = @validator.validate_file(fname)
39
39
 
40
40
  validation_errors = results.errors.length
@@ -1,8 +1,15 @@
1
- require 'test/test_helper'
1
+ require File.dirname(__FILE__) +'/test_helper'
2
2
 
3
3
  module Railscheck
4
4
  module Test
5
- class Associations < Railscheck::TestCase
5
+ class Models < Railscheck::TestCase
6
+ # Check that correctly named database tables exist for each rails model
7
+ def test_database_tables_and_models_consistency
8
+ lookup_active_record_models_classes.each do |clazz|
9
+ assert clazz.table_exists?, "Error - Could not find database table #{clazz.table_name} corresponding to rails model #{clazz.name}"
10
+ end
11
+ end
12
+
6
13
  # Test that associations uses the correct pluralization.
7
14
  def test_associations_pluralization
8
15
  lookup_active_record_models_classes.each do |clazz|
@@ -15,7 +22,7 @@ module Railscheck
15
22
  end
16
23
  end
17
24
  end
18
- end
25
+ end
19
26
  end
20
27
  end
21
28
  end
@@ -1,4 +1,4 @@
1
- require 'test/test_helper'
1
+ require File.dirname(__FILE__) +'/test_helper'
2
2
 
3
3
  module Railscheck
4
4
  module Test
@@ -0,0 +1,330 @@
1
+ require File.dirname(__FILE__) +'/test_helper'
2
+
3
+ CONFIG_FILE = File.dirname(__FILE__) +'/tc_rails_deprecations.yml'
4
+
5
+ module Railscheck
6
+ module Test
7
+ class RailsDeprecations < Railscheck::TestCase
8
+ # Adapted from code by Mislav Marohnić (http://pastie.caboo.se/private/krcevozww61drdeza13e3a)
9
+ # merged with code from deprecated plugin by Geoffrey Grosenbach (http://topfunky.net/svn/plugins/deprecated/)
10
+ # and added my own file deprecation support, simplified reporting, a version-specification and a explicit RAILS-ROOT etc.
11
+ #
12
+ # TODO: Move yaml specifications into sperate file (regular expressions will have to be updated).
13
+ def test_deprecations
14
+ specs = YAML::load <<YML
15
+ rhtml:
16
+ pattern: '\\.rhtml'
17
+ where: filename
18
+ info: '*.rhtml file extensions are deprecated in favor of *.erb'
19
+ solution: 'Rename your rhtml files'
20
+ version: 2.0
21
+
22
+ rxml:
23
+ pattern: '\\.rxml'
24
+ where: filename
25
+ info: '*.rxml file extensions are deprecated in favor of *.builder'
26
+ solution: 'Rename your rxml files'
27
+ version: 2.0
28
+
29
+ params instance:
30
+ pattern: '@params\\b'
31
+ where: controllers
32
+ info: 'Build-in instance variables has been removed in favor of accessors'
33
+ solution: 'Use params[] instead'
34
+ version: 1.1
35
+
36
+ session instance:
37
+ pattern: '@session\\b'
38
+ where: controllers
39
+ info: 'Build-in instance variables has been removed in favor of accessors'
40
+ solution: 'Use session[] instead'
41
+ version: 1.1
42
+
43
+ flash instance:
44
+ pattern: '@flash\\b'
45
+ where: controllers
46
+ info: 'Build-in instance variables has been removed in favor of accessors'
47
+ solution: 'Use flash[] instead'
48
+ version: 1.1
49
+
50
+ request instance:
51
+ pattern: '@request\\b'
52
+ where: controllers
53
+ info: 'Build-in instance variables has been removed in favor of accessors'
54
+ solution: 'Use request[] instead'
55
+ version: 1.1
56
+
57
+ env instance:
58
+ pattern: '@env\\b'
59
+ where: controllers
60
+ info: 'Build-in instance variables has been removed in favor of accessors'
61
+ solution: 'Use env[] instead'
62
+ version: 1.1
63
+
64
+ render partial:
65
+ pattern: '\\brender_partial\\b'
66
+ where: controllers
67
+ info: 'Similar render methods has been combined'
68
+ solution: 'Use render :partial instead'
69
+ version: 1.1
70
+
71
+ component:
72
+ pattern: 'components\\b'
73
+ where: filename
74
+ info: 'Use of components are frowned upon'
75
+ version: 1.1
76
+
77
+ start_form_tag:
78
+ pattern: 'start_form_tag\\b'
79
+ where: views
80
+ info: 'start_form_tag has been removed'
81
+ solution: 'Use form_for instead'
82
+ version: 1.1
83
+
84
+ start_form_tag:
85
+ pattern: 'end_form_tag\\b'
86
+ where: views
87
+ info: 'end_form_tag has been removed'
88
+ solution: 'Use form_for instead'
89
+ version: 1.1
90
+
91
+ post option:
92
+ pattern: ':post\\s*=>\\s*true\\b'
93
+ info: 'post option has been deprecated'
94
+ solution: 'Use :method => :post instead'
95
+ version: 1.1
96
+
97
+ breakpoint server:
98
+ pattern: '\\bbreakpoint_server\\b'
99
+ where: config
100
+ info: 'The configuration option has been removed in favor of the better ruby-debug library.'
101
+ gem: ruby-debug
102
+ solution: 'Remove the line(s) from configuration since the setting has no effect anymore. Instead, start `script/server` with the "-u" or "--debugger" option (or "-h" to see all the options).'
103
+ changeset: 6627
104
+ version: 2.0
105
+
106
+ with_scope:
107
+ pattern: '[A-Z]\\w+\\.with_scope\\b'
108
+ info: 'This class method has been declared private to model classes.'
109
+ solution: "Don't use it directly. You can only use it internally from the model class itself."
110
+ changeset: 6909
111
+ version: 2.0
112
+
113
+ singular resources:
114
+ pattern: "\\\\.resource\\\\s+[:\\"'](\\w+)"
115
+ eval: "File.exist?('app/controllers/' + $1 + '_controller.rb') and line !~ /:controller\\\\b/"
116
+ where: routes
117
+ info: "Singular resources map to pluralized controllers now (ie. map_resource(:post) maps to PostsController)."
118
+ solution: "Rename your singular controller(s) to plural or use the :controller option in `map.resource` to override the controller name it maps to."
119
+ changeset: 6922
120
+ version: 2.0
121
+
122
+ pagination:
123
+ pattern: '[^.\\w](paginate|(?:find|count)_collection_for_pagination|pagination_links(?:_each)?)\\b'
124
+ where: controllers, views
125
+ changeset: 6992
126
+ info: "Pagination has been extracted from Rails core."
127
+ solution: "Alternative: you can replace your pagination calls with will_paginate (find it on http://rock.errtheblog.com/)."
128
+ plugin: svn://errtheblog.com/svn/plugins/classic_pagination
129
+ version: 2.0
130
+
131
+ push_with_attributes:
132
+ pattern: '\\.push_with_attributes\\b'
133
+ info: This method on associations has been removed from Rails.
134
+ solution: "If you need attributes on associations, use has_many :through."
135
+ changeset: 6997
136
+ version: 2.0
137
+
138
+ find_first or find_all:
139
+ pattern: '\\b(find_first|[A-Z]\\w+\\.find_all)\\b'
140
+ where: models, controllers
141
+ info: "AR::Base `find_first` and `find_all` class methods have been removed. (If you're in fact using `find_all` method of Enumerable, ignore this warning.)"
142
+ solution: "Use `find(:first)` or `find(:all)`."
143
+ changeset: 6998
144
+ version: 2.0
145
+
146
+ Hash.create_from_xml:
147
+ pattern: '\\bHash.create_from_xml\\b'
148
+ info: "`Hash.create_from_xml` has been renamed to `from_xml`."
149
+ changeset: 7085
150
+ version: 2.0
151
+
152
+ nested resource named routes:
153
+ pattern: '\\b\\w+_(new|edit)_\\w+_(url|path)\\b'
154
+ where: controllers, views
155
+ info: "Nested resource named routes are now prefixed by their action name."
156
+ solution: "Rename your calls to such named routes from ie. 'group_new_user_path' to 'new_group_user_path'. Same applies for 'edit' paths."
157
+ changeset: 7138
158
+ version: 2.0
159
+
160
+ belongs_to foreign key assumption:
161
+ pattern: '\\bbelongs_to\\b.+:class_name\\b'
162
+ eval: 'line !~ /:foreign_key\\b/'
163
+ where: models
164
+ info: "The foreign key name is no longer inferred from the explicit class name, but from the association name."
165
+ solution: "Make sure the foreign key for your association is in the form of '{association_name}_id'. (See the changeset for an example)."
166
+ changeset: 7188
167
+ version: 2.0
168
+
169
+ old association dependencies:
170
+ pattern: ':dependent\\s*=>\\s*true|:exclusively_dependent\\b'
171
+ where: models
172
+ info: "Specifying dependencies in associations has a new form and the old API has been removed."
173
+ solution: "Change ':dependent => true' to ':dependent => :destroy' and ':exclusively_dependent' to ':dependent => :delete_all'."
174
+ changeset: 7402
175
+ version: 2.0
176
+
177
+ old render methods:
178
+ pattern: '\\brender_(action|with(out)?_layout|file|text|template)\\b'
179
+ where: controllers
180
+ info: "The old `render_{something}` API has been removed."
181
+ solution: "Change `render_action` to `render :action`, `render_text` to `render :text` (and so on) in your controllers."
182
+ changeset: 7403
183
+ version: 2.0
184
+
185
+ template root:
186
+ pattern: '\\btemplate_root\\b'
187
+ info: "`template_root` has been dropped in favor of `view_paths` array."
188
+ solution: 'Replace `template_root = "some/dir"` with `view_paths = "some/dir"`.'
189
+ changeset: 7426
190
+ version: 2.0
191
+
192
+ expire matched fragments:
193
+ pattern: '\\bexpire_matched_fragments\\b'
194
+ where: controllers
195
+ info: "`expire_matched_fragments` has been superseded by `expire_fragment`."
196
+ solution: "Simply call `expire_fragment` with a regular expression."
197
+ changeset: 7427
198
+ version: 2.0
199
+
200
+ expire matched fragments:
201
+ pattern: '\\bkeep_flash\\b'
202
+ where: controllers
203
+ info: "`keep flash` has been superseded by `flash.keep`."
204
+ changeset: 7428
205
+ version: 2.0
206
+
207
+ dynamic scaffold:
208
+ pattern: '\\bscaffold\\b'
209
+ where: controllers
210
+ plugin: scaffolding
211
+ info: "Dynamic scaffolding has gone the way of the dinosaurs."
212
+ solution: "Don't use it. Use the 'scaffold' generator to generate scaffolding for RESTful resources."
213
+ changeset: 7429
214
+ version: 2.0
215
+
216
+ image tag without extension:
217
+ pattern: "\\\\bimage_tag\\s*(\\(\\s*)?('[^'.]+'|\\"[^\\".]+\\")"
218
+ where: views
219
+ info: ".png is no longer the default extension for images."
220
+ solution: "Explicitly set the image extension when using `image_tag`: instead of just `image_tag 'logo'`, use 'logo.png'."
221
+ changeset: 7432
222
+ version: 2.0
223
+
224
+ cookie:
225
+ pattern: ^\\s*cookie\\b
226
+ where: controllers
227
+ info: "The `cookie` writer method was removed from controllers."
228
+ solution: "Use `cookies[name] = value` instead."
229
+ changeset: 7434
230
+ version: 2.0
231
+
232
+ javascript in-place editor:
233
+ pattern: \\b(in_place_editor_field|in_place_edit_for)\\b
234
+ where: views, controllers
235
+ plugin: in_place_editing
236
+ info: "The in-place editor has been extracted from Rails core."
237
+ changeset: 7442
238
+ version: 2.0
239
+
240
+ javascript autocompleter:
241
+ pattern: \\b(auto_complete_field|auto_complete_for)\\b
242
+ where: views, controllers
243
+ plugin: auto_complete
244
+ info: "The autocompleter has been extracted from Rails core."
245
+ changeset: 7450
246
+ version: 2.0
247
+
248
+ acts_as_list:
249
+ pattern: \\bacts_as_list\\b
250
+ where: models
251
+ plugin: acts_as_list
252
+ info: "acts_as_list has been extracted from Rails core."
253
+ changeset: 7444
254
+ version: 2.0
255
+
256
+ acts_as_nested_set:
257
+ pattern: \\bacts_as_nested_set\\b
258
+ where: models
259
+ plugin: acts_as_nested_set
260
+ info: "acts_as_nested_set has been extracted from Rails core."
261
+ changeset: 7453
262
+ version: 2.0
263
+
264
+ acts_as_tree:
265
+ pattern: \\bacts_as_tree\\b
266
+ where: models
267
+ plugin: acts_as_tree
268
+ info: "acts_as_tree has been extracted from Rails core."
269
+ changeset: 7454
270
+ version: 2.0
271
+
272
+ reloadable:
273
+ pattern: \\binclude\\s+Reloadable\\b
274
+ info: "Reloadable module is removed from Rails."
275
+ solution: "Don't include the module anymore. Dependencies code is smart enough to reload classes if they're not in 'load_once' paths."
276
+ changeset: 7473
277
+ version: 2.0
278
+ YML
279
+
280
+ for props in specs.values
281
+ next unless props['pattern']
282
+ props['pattern'] = Regexp.new props['pattern']
283
+ end
284
+
285
+ files = (Dir["#{RAILS_ROOT}/{app,config,db/migrate,lib,test}/**/*.rb"] + Dir["#{RAILS_ROOT}/app/views/**/*.{rhtml,rxml,erb,builder,haml}"]).sort
286
+ files -= ["#{RAILS_ROOT}/config/boot.rb"]
287
+ files -= version_control_excludes
288
+
289
+ plugins = Dir["#{RAILS_ROOT}/vendor/plugins/*"].map{ |p| File.basename p }.sort
290
+
291
+ files.each do |filename|
292
+ #puts "Checking "+filename
293
+ for props in specs.values
294
+ if props['where']=='filename' && filename =~ props['pattern'] and (props['eval'].nil? or eval(props['eval']))
295
+ warn "Rails v#{props['version']} deprecation found at #{filename} #{props['info']}. #{props['solution']}"
296
+ end
297
+ end
298
+
299
+ File.open(filename).each_with_index do |line, ln|
300
+ next if line =~ /^\s*#/ # skip commented lines
301
+ for props in specs.values
302
+ # puts "Checking "+props['pattern'].to_s
303
+ if props['where']
304
+ where = props['where'].scan /\w+/
305
+ next unless where.any? do |place|
306
+ case place
307
+ when 'filename'
308
+ false
309
+ when 'controllers', 'models'
310
+ filename.index("#{RAILS_ROOT}/app/#{place}/") == 0
311
+ when 'views'
312
+ filename.index("#{RAILS_ROOT}/app/views/") == 0 || filename.index("#{RAILS_ROOT}/app/helpers/") == 0
313
+ when 'routes'
314
+ filename == "#{RAILS_ROOT}/config/routes.rb"
315
+ else
316
+ filename.index("#{RAILS_ROOT}/#{place}/") == 0
317
+ end
318
+ end
319
+ end
320
+
321
+ if line =~ props['pattern'] and (props['eval'].nil? or eval(props['eval']))
322
+ warn "Rails v#{props['version']} deprecation found at #{filename}:#{ln + 1}: #{props['info']}. #{props['solution']}"
323
+ end
324
+ end
325
+ end
326
+ end
327
+ end
328
+ end
329
+ end
330
+ end
@@ -0,0 +1,24 @@
1
+ require File.dirname(__FILE__) +'/test_helper'
2
+
3
+ module Railscheck
4
+ module Test
5
+ class SyntaxCheckRuby < Railscheck::TestCase
6
+ # Test that every ruby file in the project can parse (except vendor plugins/rails) incl. rake and rjs varints.
7
+ def test_all_ruby_can_parse
8
+ (Dir["#{RAILS_ROOT}/**/*.rb", "#{RAILS_ROOT}/**/*.rake", "#{RAILS_ROOT}/**/*.rjs"]-Dir["#{RAILS_ROOT}/vendor/**/*.*"]-version_control_excludes).each do |fname|
9
+ #puts "CHECKING FILE "+fname
10
+ ruby_code = get_file_as_string(fname)
11
+ first_error = parse(ruby_code, fname)
12
+ assert_equal '', first_error, first_error
13
+ end
14
+ end
15
+
16
+ def parse(code, fname)
17
+ eval("BEGIN {return ''}\n#{code}", nil, fname, 0)
18
+ rescue SyntaxError => ex
19
+ ex.message
20
+ end
21
+
22
+ end
23
+ end
24
+ end
data/lib/test/tc_views.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'test/test_helper'
1
+ require File.dirname(__FILE__) +'/test_helper'
2
2
 
3
3
  module Railscheck
4
4
  module Test
@@ -8,7 +8,7 @@ module Railscheck
8
8
  # Test that every erb/rhtml file in the project can parse (except vendor plugins/rails).
9
9
  def test_views_can_parse
10
10
  # Nb. This task is inspired by a snippet by dseverin (http://snippets.dzone.com/posts/show/3397)
11
- Dir["#{RAILS_ROOT}/app/views/**/*.erb", "#{RAILS_ROOT}/app/views/**/*.rhtml"].each do |fname|
11
+ (Dir["#{RAILS_ROOT}/app/views/**/*.erb", "#{RAILS_ROOT}/app/views/**/*.rhtml"]-version_control_excludes).each do |fname|
12
12
  local_source = ERB.new(IO.read(fname), nil, '-').src
13
13
  template_source = "def _tmpl\n#{local_source}\nend"
14
14
 
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) +'/test_helper'
2
+
3
+ require "rexml/document"
4
+
5
+ module Railscheck
6
+ module Test
7
+ class SyntaxCheckXml < Railscheck::TestCase
8
+ # Test that every xml file in the project can parse (except vendor plugins/rails).
9
+ def test_all_xml_can_parse
10
+ (Dir["#{RAILS_ROOT}/**/*.xml"]-Dir["#{RAILS_ROOT}/vendor/**/*.*"]-version_control_excludes).each do |fname|
11
+ #puts "CHECKING FILE "+fname
12
+ File.open(fname) do |file|
13
+ assert_nothing_raised("Could not parse file \"#{fname}\".") do
14
+ begin
15
+ doc = REXML::Document.new(file)
16
+ rescue Exception => ex
17
+ raise SyntaxError.new("Syntax error(s) in #{fname} at line #{ex.line}")
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,4 @@
1
- require 'test/test_helper'
2
- require 'railscheck/testcase'
1
+ require File.dirname(__FILE__) +'/../railscheck/testcase'
3
2
 
4
3
  # Read and return filename content as string.
5
4
  def get_file_as_string(filename)
data/website/index.html CHANGED
@@ -1,23 +1,105 @@
1
1
  <html><head><title>Railscheck project home page</title></head>
2
+ <link rel="stylesheet" href="screen.css" type="text/css" media="screen">
2
3
  <body>
3
- <h1>Railscheck - The semi-static Q/A verification tool for your Ruby on Rails projects</h1>
4
+ <h1>Railscheck</h1>
5
+ <h2 style="padding-top: 0"><i>- The semi-static Q/A verification tool for your Ruby on Rails projects</i></h2>
4
6
 
5
- <p>This project is (or will be) a best effort semi-static verifier for your <a href="http://www.rubyonrails.com/">Ruby on Rails</a> projects. Delivered as a Ruby gem it provides a shell command task "railscheck" that you can run against your Rails projects to test for a number of typical bugs and inconsistencies. See <a href="http://railscheck.rubyforge.org/svn/trunk/README.txt"><b>here</b></a> for more information.</p>
7
+ <p>This project is (or will be) a best effort semi-static verifier for your <a href="http://www.rubyonrails.com/">Ruby on Rails</a> projects. Delivered as a Ruby gem it provides a shell command task "railscheck" that you can run against your Rails projects to test for a number of typical bugs and inconsistencies.</p>
8
+
9
+ <h2>Project site and detailed information</h2>
10
+ <p>This project is hosted on <a href="http://rubyforge.org/projects/railscheck/">http://rubyforge.org/projects/railscheck/</a>. Refer to the latest <a href="http://railscheck.rubyforge.org/svn/trunk/README.txt"><b>README</b></a> for up-to-date information on this gem or to the online <a href ="http://railscheck.rubyforge.org/rdoc/">RDoc's</a> for code details.</p>
11
+ <p/>
12
+
13
+ <h2>Featured checks</h2>
14
+
15
+ <h4>Syntax check and validation of (static files):</h4>
16
+ <ul>
17
+ <li>Syntax check of static <strong>*.rb, *.rake and *.rjs</strong> ruby files (test <code>tc_syntax_check_ruby.rb</code>)</li>
18
+ <li>Syntax check of <strong>*.yaml</strong> files (test <code>tc_config.rb</code>)</li>
19
+ <li>Syntax check of <strong>*.xml</strong> files (test <code>tc_xml.rb</code>)</li>
20
+ <li>Syntax check of <strong>*.erb, *.rhtml</strong> view files (test <code>tc_views.rb</code>)</li>
21
+ <li>Syntax check (online) of <strong>*.css</strong> files (test <code>tc_html_and_css.rb</code>) currently using W3C web services.</li>
22
+ <li>Syntax check (online) of <strong>*.(x)html</strong> files (test <code>tc_html_and_css.rb</code>) currently using W3C web services.</li>
23
+ <li><i>Nb. working on <strong>*.js</strong> javascript validation. Due soon but not quite ready.</i></li>
24
+ </ul>
25
+
26
+ <h4>Database:</h4>
27
+ <ul>
28
+ <li>Checks that <strong>database is configured correct</strong> in project with ability to connect to database. (test <code>tc_database.rb</code>)</li>
29
+ <li>Checks that <strong>database migration version corresponds to latest code migration</strong> version number in project. (test <code>tc_database.rb</code>)</li>
30
+ <li>Checks that <strong>database driver</strong> is fit for production use.. (test <code>tc_database.rb</code>)</li>
31
+ <li>Checks that <strong>test database does not overlap with development/production</strong> database. (test <code>tc_database.rb</code>)</li>
32
+ </ul>
33
+
34
+ <h4>Models:</h4>
35
+ <ul>
36
+ <li>Validates that <strong>tables with correct names exist for all ActiveRecord model classes</strong> in project. (test <code>tc_models.rb</code>)</li>
37
+ <li>Validates that <strong>has_many, has_one, belongs_to and has_and_belongs_to_many</strong> associations uses the <strong>correct pluralization</strong> for names (there are subtle problems with activerecord if this is not the case). (test <code>tc_models.rb</code>)</li>
38
+ </ul>
39
+
40
+ <h4>Warnings and deprecations :</h4>
41
+ <ul>
42
+ <li>Warns if <strong>deprecated</strong> Rails constructs are used. (test <code>tc_rails_deprecations.rb</code>)</li>
43
+ </ul>
44
+
45
+ <h4>Overall :</h4>
46
+ <ul>
47
+ <li>Validates Ruby On Rails <strong>project structure</strong> and <strong>existence of key files</strong> necessary to develop, test and deploy rails projects successfully. (test <code>tc_project.rb</code>)</li>
48
+ </ul>
6
49
 
7
50
  <h2>Installation</h2>
8
- <p>Install latest version using: "<b>sudo gem install railscheck</b>"</p>
51
+ This project is hosted on rubyforge. Install latest version using the gem command (sudo part is for linux/unix/mac os only - omit for Windows):
52
+ <pre class="syntax"><span class="optional">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">railscheck</span></pre>
9
53
 
10
54
  <h2>Running</h2>
11
- <p>The installation will place railscheck executables on your PATH. Invoke the following command for usage help: "<b>railscheck -h</b>" </p>
12
- <p><i>Note: First do make sure this gem is installed, your project is configured and that all your migrations are run for the project(s) you want to check. See <a href="http://railscheck.rubyforge.org/svn/trunk/README.txt"><b>here</b></a> for more information.</i></p>
55
+ <p><i>Note: Before running railscheck do make sure this gem is installed, your project is configured and that all your migrations are run for the project(s) you want to check. See <a href="http://railscheck.rubyforge.org/svn/trunk/README.txt"><b>here</b></a> for more information.</i></p>
56
+ Full usage instructions including useful details about including/excluding individual checks:
57
+ <pre class="syntax"><span class="ident">railscheck -h</span></pre>
58
+ Check your project using all build-in checks:
59
+ <pre>$ railscheck /mypath/myrailsproject
60
+ Railscheck 0.2.0 (nb. help & more information avilable with -h argument):
61
+ Booted RoR 2.0.2 project at "/mypath/myrailsproject".
62
+ Running all railscheck tests satisfying /.*/ and not satisfying /html/:
63
+ Loading test file "./../lib/test/tc_config.rb".
64
+ Loading test file "./../lib/test/tc_database.rb".
65
+ Loading test file "./../lib/test/tc_models.rb".
66
+ Loading test file "./../lib/test/tc_project.rb".
67
+ Loading test file "./../lib/test/tc_rails_deprecations.rb".
68
+ Loading test file "./../lib/test/tc_syntax_check_ruby.rb".
69
+ Loading test file "./../lib/test/tc_views.rb".
70
+ Loading test file "./../lib/test/tc_xml.rb".
71
+ Loading test file "./../lib/test/html_and_css.rb".
72
+ Loaded suite ./railscheck
73
+ Started
74
+ ..............
75
+ Finished in 0.352005 seconds.
13
76
 
14
- <h2>Project site and more information</h2>
15
- <p>This project is hosted on <a href="http://rubyforge.org/projects/railscheck/">http://rubyforge.org/projects/railscheck/</a>. Refer to the latest <a href="http://railscheck.rubyforge.org/svn/trunk/README.txt"><b>README</b></a> for up-to-date information on the plugin.</p>
16
- <p/>
77
+ 14 tests, 61 assertions, 0 failures, 0 errors
78
+ </pre>
79
+ <i>Note: The above project has no problems - what about your project?</i>
80
+
81
+ <h2>Implementation details and how to contribute</h2>
82
+ <p>You can <b>easily add your own checks</b> to the <code>"lib\test"</code> folder. Checks are tests based on the standard <b>ruby unit test framework</b> and following the standard conventions they should be placed in Ruby files starting with <code>"tc_"</code> in order to be picked up by Railscheck automatically. All test classes should inherit from <code>Railscheck::TestCase</code> which in turns inherits from <code>"Test::Unit::TestCase"</code>. See the existing test files for examples.</p>
83
+ <p>Any added code that you contribute will be given due credit! However make sure that you assign undersigned shared copyright so I am allowed to release and license your work together with this project.</p>
84
+ The source code is available anonymously (readonly) using subversion:
85
+ <pre class="syntax"><span class="ident">svn checkout svn://rubyforge.org/var/svn/railscheck/trunk</span></pre>
86
+ <p>Once you have added your tests write undersigned an email in order to get registered and get your contribution into Railscheck. When you are registered as a project contributor you may access the source code from subversion with full read/write rights using:<p>
87
+ <pre class="syntax"><span class="ident">svn checkout svn+ssh://YOUR-RUBYFORGE-LOGIN-NAME@rubyforge.org/var/svn/railscheck/trunk</span></pre>
17
88
  <h2>Authors</h2>
18
89
  <ol>
19
90
  <li><a href="http://workingwithrails.com/person/4802-morten-m-christensen">Morten Christensen</a>, senior consultant, software developer from Danish software development/consultancy company <a href="http://www.41concepts.com">41concepts</a>. (see also our <a href="http://techblog.41concepts.com/">R&D blog</a>).</li>
20
91
  </ol>
92
+ <h2>Special credits</h2>
93
+ <ol>
94
+ <li>Dr Nic Williams for the <a href="http://newgem.rubyforge.org/">newgem</a> tool and basic css design of website (with theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>)</li>
95
+ <li>Fail Early and MySQL driver Tasks written by <a href="http://maintainable.com/articles">Mike Naberezny</a> for <a href="http://www.oreilly.com/catalog/9780978739225/">Advanced Rail Recipes</a> etc.</li>
96
+ <li>DZone <a href="http://snippets.dzone.com/posts/show/3397">Snippet</a> Rails task to find code typos in rhtml templates by Dmitry Severin (dseverin)</li>
97
+ <li>Rails <a href="http://pastie.caboo.se/private/krcevozww61drdeza13e3a">2.0 deprecations snippet</a> by Mislav Marohnic</li>
98
+ <li>Rails <a href="http://topfunky.net/svn/plugins/deprecated/">deprecations plugin</a> by Geoffrey Grosenbach</li>
99
+ <li>Aaron Patterson for the <a href="http://github.com/jbarnette/johnson/wikis">Johnson</a> javascript gem used for javascript validation.</li>
100
+ <li>Alex Dunae for the <a href="http://code.dunae.ca/w3c_validators/">W3C wrapper gem</a> used for CSS/(X)HTML validation.</li>
101
+ </ol>
102
+
21
103
  <h2>License:</h2>
22
104
  This software is FREE for both public and commercial use - with the possible exception of commercial
23
105
  software development tool makers that require a license (see project <a href="http://railscheck.rubyforge.org/svn/trunk/License.txt"><b>license file</b></a> for details).
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railscheck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morten M. Christensen / 41concepts
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-27 00:00:00 +02:00
12
+ date: 2008-05-12 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -49,12 +49,15 @@ files:
49
49
  - lib/railscheck.rb
50
50
  - lib/railscheck/testcase.rb
51
51
  - lib/railscheck/version.rb
52
- - lib/test/tc_associations.rb
53
52
  - lib/test/tc_config.rb
54
- - lib/test/tc_database_models.rb
53
+ - lib/test/tc_database.rb
55
54
  - lib/test/tc_html_and_css.rb
55
+ - lib/test/tc_models.rb
56
56
  - lib/test/tc_project.rb
57
+ - lib/test/tc_rails_deprecations.rb
58
+ - lib/test/tc_syntax_check_ruby.rb
57
59
  - lib/test/tc_views.rb
60
+ - lib/test/tc_xml.rb
58
61
  - lib/test/test_helper.rb
59
62
  - log/debug.log
60
63
  - script/console
@@ -65,8 +68,6 @@ files:
65
68
  - tasks/deployment.rake
66
69
  - tasks/environment.rake
67
70
  - tasks/website.rake
68
- - test/test_helper.rb
69
- - test/test_railscheck.rb
70
71
  - website/index.html
71
72
  has_rdoc: true
72
73
  homepage: http://railscheck.rubyforge.org
@@ -95,6 +96,5 @@ rubygems_version: 1.1.1
95
96
  signing_key:
96
97
  specification_version: 2
97
98
  summary: Static verifier for Ruby On Rails projects
98
- test_files:
99
- - test/test_helper.rb
100
- - test/test_railscheck.rb
99
+ test_files: []
100
+
@@ -1,35 +0,0 @@
1
- require 'test/test_helper'
2
-
3
- module Railscheck
4
- module Test
5
- class DataBaseModels < Railscheck::TestCase
6
- # Test that database connection can be established.
7
- def test_database_connection_working
8
- assert File.file?("#{RAILS_ROOT}/config/database.yml"), "Database configuration file database.yml must be present"
9
-
10
- assert_nothing_raised("Could not open database connection / no migration schema_info table in database") do
11
- ActiveRecord::Base.establish_connection
12
- ActiveRecord::Base.connection.select_all('select * from schema_info')
13
- end
14
- end
15
-
16
- # Test that all migrations has been migrated.
17
- def test_database_consistent_with_migration_version
18
- db_version = ActiveRecord::Migrator.current_version rescue 0
19
- highest_migration_version_in_project = Dir.glob("#{RAILS_ROOT}/db/migrate/*.rb" ).map { |f|
20
- f.match(/(\d+)_.*\.rb$/) ? $1.to_i : 0
21
- }.max
22
-
23
- assert_equal highest_migration_version_in_project, db_version, "Database version is not up-to-date with migrations (forgot to run db:migrate?)."
24
- end
25
-
26
- # Check that correctly named database tables exist for each rails model
27
- def test_database_tables_and_models_consistency
28
- lookup_active_record_models_classes.each do |clazz|
29
- assert clazz.table_exists?, "Error - Could not find database table #{clazz.table_name} corresponding to rails model #{clazz.name}"
30
- end
31
- end
32
-
33
- end
34
- end
35
- end
data/test/test_helper.rb DELETED
@@ -1,2 +0,0 @@
1
- require 'test/unit'
2
- require File.dirname(__FILE__) + '/../lib/railscheck'
@@ -1,11 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class TestRailscheck < Test::Unit::TestCase
4
-
5
- def setup
6
- end
7
-
8
- def test_truth
9
- assert true
10
- end
11
- end