Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

switching the readme to markdown

  • Loading branch information...
commit ab31b71ad22dfbfc30d6f87e47d6bca37ba879c0 1 parent 7b9e463
@dan-manges authored
Showing with 110 additions and 67 deletions.
  1. +20 −0 LICENSE
  2. +83 −0 README.markdown
  3. +0 −67 README.rdoc
  4. +7 −0 Rakefile
View
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2007-2008 Dan Manges
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
83 README.markdown
@@ -0,0 +1,83 @@
+UnitRecord
+==========
+
+Enables unit testing ActiveRecord classes without hitting the database.
+
+Why?
+----
+
+Rationale: [http://www.dcmanges.com/blog/rails-unit-record-test-without-the-database](http://www.dcmanges.com/blog/rails-unit-record-test-without-the-database)
+
+The biggest benefit to disconnecting unit tests from the database is having a faster test suite. Here is the benchmark from one of my current projects:
+
+ Finished in 19.302702 seconds.
+ 4920 tests, 7878 assertions, 0 failures, 0 errors
+
+4 seconds per 1,000 tests is a good guideline.
+
+Installation
+------------
+
+ gem install unit_record
+
+Usage
+-----
+
+Restructuring the Rails Test Directory
+--------------------------------------
+
+The Rails test directory typically places testing for models under <tt>test/unit</tt> and tests for controllers under <tt>test/functional</tt>. However, we need to change the definition of unit and functional. Controllers can be unit tested (mocking out models and not rendering the view). Models can be functionally tested (hitting the database). Also, each type of test needs its own test\_helper. I recommend restructuring your test directory like this:
+
+ test
+ test_helper.rb
+ unit
+ unit_test_helper.rb
+ controllers
+ models
+ functional
+ functional_test_helper.rb
+ controllers
+ models
+
+You should move existing functional tests into functional/controllers. You will also need to change the require line at the top of those tests to require the functional\_test\_helper.rb file instead of the test\_helper.rb file.
+
+The <tt>functional_test_helper.rb</tt> file only needs to require <tt>test_helper.rb</tt>:
+
+ require File.dirname(__FILE__) + "/../test_helper"
+
+For moving unit tests, you have a few options. I recommend moving them to unit/models and then disconnecting your unit tests from the database. Any tests that fail should then be modified to not hit the database or moved to functional/models.
+
+Disconnecting
+-------------
+
+In the <tt>test/unit/unit\_test\_helper.rb</tt> file you created when restructuring your test directory, you should add these lines:
+
+ require File.dirname(__FILE__) + "/../test_helper"
+ require "unit_record"
+ ActiveRecord::Base.disconnect!
+
+The <tt>disconnect!</tt> method will do everything necessary to run your unit tests without hitting the database.
+
+Development
+-----------
+
+Active development occurs on the [GitHub](http://github.com/dan-manges/unit-record). Changes are pushed to the Rubyforge git repository.
+
+Thanks
+------
+Thanks to Jay Fields for the [original implementation](http://blog.jayfields.com/2007/03/rails-activerecord-unit-testing-part-ii.html).
+
+Maintainer
+----------
+
+[Dan Manges](http://www.dcmanges.com)
+
+Contributors
+------------
+
+* David Lowenfels
+* Rob Sanheim
+
+License
+-------
+Released under the MIT license
View
67 README.rdoc
@@ -1,67 +0,0 @@
-= UnitRecord
-
-Enables unit testing ActiveRecord classes without hitting the database.
-
-== Why?
-
-Rationale: http://www.dcmanges.com/blog/rails-unit-record-test-without-the-database
-
-The biggest benefit to disconnecting unit tests from the database is having a faster test suite. Here is the benchmark from one of my current projects:
-
- Finished in 19.302702 seconds.
- 4920 tests, 7878 assertions, 0 failures, 0 errors
-
-4 seconds per 1,000 tests is a good guideline.
-
-== Installation
-
- gem install unit_record
-
-== Usage
-
-=== Restructuring the Rails Test Directory
-
-The Rails test directory typically places testing for models under <tt>test/unit</tt> and tests for controllers under <tt>test/functional</tt>. However, we need to change the definition of unit and functional. Controllers can be unit tested (mocking out models and not rendering the view). Models can be functionally tested (hitting the database). Also, each type of test needs its own test_helper. I recommend restructuring your test directory like this:
-
- test
- test_helper.rb
- unit
- unit_test_helper.rb
- controllers
- models
- functional
- functional_test_helper.rb
- controllers
- models
-
-You should move existing functional tests into functional/controllers. You will also need to change the require line at the top of those tests to require the functional_test_helper.rb file instead of the test_helper.rb file.
-
-The <tt>functional_test_helper.rb</tt> file only needs to require <tt>test_helper.rb</tt>:
- require File.dirname(__FILE__) + "/../test_helper"
-
-For moving unit tests, you have a few options. I recommend moving them to unit/models and then disconnecting your unit tests from the database. Any tests that fail should then be modified to not hit the database or moved to functional/models.
-
-== Disconnecting
-
-In the <tt>test/unit/unit_test_helper.rb</tt> file you created when restructuring your test directory, you should add these lines:
- require File.dirname(__FILE__) + "/../test_helper"
- require "unit_record"
- ActiveRecord::Base.disconnect!
-
-The <tt>disconnect!</tt> method will do everything necessary to run your unit tests without hitting the database.
-
-== Development
-
-Active development occurs on the GitHub.[http://github.com/dan-manges/unit-record] Changes are pushed to the Rubyforge git repository.
-
-== Thanks
-Thanks to Jay Fields for the original implementation.[http://blog.jayfields.com/2007/03/rails-activerecord-unit-testing-part-ii.html]
-
-== Contributors
-
-* Dan Manges
-* David Lowenfels
-* Rob Sanheim
-
-== License
-Released under Ruby's[http://www.ruby-lang.org/en/LICENSE.txt] license.[http://www.ruby-lang.org/en/LICENSE.txt]
View
7 Rakefile
@@ -72,6 +72,13 @@ namespace :gemspec do
end
end
+task :readme do
+ require "rubygems"; gem "BlueCloth"; require "BlueCloth"; require 'tmpdir'
+ file = "#{Dir.tmpdir}/readme.html"
+ File.open(file, "w") { |f| f.write BlueCloth.new(File.read("README.markdown")).to_html }
+ sh "open #{file}"
+end
+
RAILS_VERSIONS = %w[1.2.6 2.0.2 2.1.0 2.1.1]
namespace :test do
Please sign in to comment.
Something went wrong with that request. Please try again.