omghax-test_rails 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 1.1.0 / 2009-05-21
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * Test::Rails is now compatible with Rails 2.3.2, thanks to Erik Ostrom.
6
+
1
7
  === 1.0.0 / 2009-03-12
2
8
 
3
9
  * 1 major enhancement:
data/Manifest.txt CHANGED
@@ -19,3 +19,4 @@ test/test_rails_controller_test_case.rb
19
19
  test/test_rails_helper_test_case.rb
20
20
  test/test_rails_view_test_case.rb
21
21
  test/test_zentest_assertions.rb
22
+ test_rails.gemspec
data/README.txt CHANGED
@@ -1,68 +1,84 @@
1
- = ZenTest
1
+ = Test::Rails
2
2
 
3
3
  * http://www.zenspider.com/ZSS/Products/ZenTest/
4
4
  * http://rubyforge.org/projects/zentest/
5
5
  * mailto:ryand-ruby@zenspider.com
6
6
 
7
+ Test::Rails was dropped from ZenTest for the 4.0 release, but there
8
+ are still a lot of tests that use it. This is Dray Lacy's extraction of
9
+ Test::Rails from ZenTest, updated to work with Rails 2.3.2 (at least
10
+ partially).
11
+
7
12
  == DESCRIPTION
8
13
 
9
- ZenTest provides 4 different tools and 1 library: zentest, unit_diff,
10
- autotest, multiruby, and Test::Rails.
14
+ Test::Rails helps you build industrial-strength Rails code.
15
+
16
+ == FEATURES
11
17
 
12
- ZenTest scans your target and unit-test code and writes your missing
13
- code based on simple naming rules, enabling XP at a much quicker
14
- pace. ZenTest only works with Ruby and Test::Unit.
18
+ * Test your controllers and views in isolation from each other.
19
+ * Test helper methods in isolation from your controllers, including those that
20
+ use routing.
21
+ * Test::Rails provides some helpful assertions for dealing with collections,
22
+ like #assert_empty and #assert_includes, as well as negated versions
23
+ (#deny_empty, #deny_includes, etc.)
15
24
 
16
- unit_diff is a command-line filter to diff expected results from
17
- actual results and allow you to quickly see exactly what is wrong.
25
+ == SYNOPSYS
18
26
 
19
- autotest is a continous testing facility meant to be used during
20
- development. As soon as you save a file, autotest will run the
21
- corresponding dependent tests.
27
+ # Typical View Test
28
+ class RouteViewTest < Test::Rails::ViewTestCase
22
29
 
23
- multiruby runs anything you want on multiple versions of ruby. Great
24
- for compatibility checking! Use multiruby_setup to manage your
25
- installed versions.
30
+ fixtures :users, :routes, :points, :photos
26
31
 
27
- Test::Rails helps you build industrial-strength Rails code.
32
+ def test_delete
33
+ # Set up instance variables for template
34
+ assigns[:loggedin_user] = users(:herbert)
35
+ assigns[:route] = routes(:work)
28
36
 
29
- == STRATEGERY
37
+ # render template for the delete action in RouteController
38
+ render
30
39
 
31
- There are two strategeries intended for ZenTest: test conformance
32
- auditing and rapid XP.
40
+ # assert that there's a form with an action of "/route/destroy"
41
+ assert_form form_url, :post do
42
+ # with a hidden id field
43
+ assert_input :hidden, :id
44
+ # And a submit button that says 'Delete!'
45
+ assert_submit 'Delete!'
46
+ end
33
47
 
34
- For auditing, ZenTest provides an excellent means of finding methods
35
- that have slipped through the testing process. I've run it against my
36
- own software and found I missed a lot in a well tested
37
- package. Writing those tests found 4 bugs I had no idea existed.
48
+ # And a link back to the route so you don't delete it
49
+ assert_links_to "/route/show/#{routes(:work).id}", 'No, I do not!'
50
+ end
38
51
 
39
- ZenTest can also be used to evaluate generated code and execute your
40
- tests, allowing for very rapid development of both tests and
41
- implementation.
52
+ end
42
53
 
43
- == FEATURES
54
+ # Typical Layout Test
55
+ require 'test/test_helper'
44
56
 
45
- * Scans your ruby code and tests and generates missing methods for you.
46
- * Includes a very helpful filter for Test::Unit output called unit_diff.
47
- * Continually and intelligently test only those files you change with autotest.
48
- * Test against multiple versions with multiruby.
49
- * Enhance and automatically audit your rails tests using Test::Rails.
50
- * Includes a LinuxJournal article on testing with ZenTest written by Pat Eyler.
51
- * See also: http://blog.zenspider.com/archives/zentest/
52
- * See also: http://blog.segment7.net/articles/category/zentest
57
+ # Create a dummy controller for layout views. This lets the setup use the
58
+ # right path with minimum fuss.
59
+ class LayoutsController < ApplicationController; end
53
60
 
54
- == SYNOPSYS
61
+ class LayoutsViewTest < Test::Rails::ViewTestCase
55
62
 
56
- ZenTest MyProject.rb TestMyProject.rb > missing.rb
63
+ fixtures :users, :routes, :points, :photos
57
64
 
58
- ./TestMyProject.rb | unit_diff
65
+ def test_default
66
+ # Template set-up
67
+ @request.request_uri = '/foo'
68
+ assigns[:action_title] = 'Hello & Goodbye'
59
69
 
60
- autotest
70
+ # Render an empty string with the 'application' layout.
71
+ render :text => '', :layout => 'application'
61
72
 
62
- multiruby_setup mri:svn:current
63
- multiruby ./TestMyProject.rb
73
+ # Assert content just like a regular view test.
74
+ assert_links_to '/', 'Home'
75
+ assert_links_to '/user', 'Login'
76
+ deny_links_to '/user/logout', 'Logout'
77
+ assert_title 'Hello &amp; Goodbye'
78
+ assert_h 1, 'Hello &amp; Goodbye'
79
+ end
64
80
 
65
- (and other stuff for Test::Rails)
81
+ end
66
82
 
67
83
  == REQUIREMENTS
68
84
 
@@ -70,18 +86,18 @@ implementation.
70
86
  * Test::Unit or miniunit
71
87
  * Hoe
72
88
  * rubygems
73
- * diff.exe on windoze. Try http://gnuwin32.sourceforge.net/packages.html
89
+ * Rails 2.3.2 (for older versions of Rails, use Test::Rails 1.0.0)
74
90
 
75
91
  == INSTALL
76
92
 
77
93
  Using Rubygems:
78
94
 
79
- * sudo gem install ZenTest
95
+ * sudo gem install omghax-test_rails -s http://gems.github.com
80
96
 
81
97
  Using Rake:
82
98
 
83
99
  * rake test
84
- * sudo rake install
100
+ * sudo rake install_gem
85
101
 
86
102
  == LICENSE
87
103
 
data/lib/test/rails.rb CHANGED
@@ -277,6 +277,10 @@ class Object # :nodoc:
277
277
  end
278
278
  end
279
279
 
280
+ require 'active_support'
281
+ require 'active_support/test_case'
282
+ require 'active_record/fixtures'
283
+
280
284
  require 'test/zentest_assertions'
281
285
  require 'test/rails/test_case'
282
286
  require 'test/rails/functional_test_case'
@@ -288,7 +292,7 @@ require 'test/rails/view_test_case'
288
292
  ##
289
293
  # Use sensible defaults.
290
294
 
291
- class Test::Unit::TestCase # :nodoc:
295
+ class ActiveSupport::TestCase # :nodoc:
292
296
  self.use_transactional_fixtures = true
293
297
  self.use_instantiated_fixtures = false
294
298
  end
@@ -112,9 +112,6 @@
112
112
 
113
113
  class Test::Rails::ControllerTestCase < Test::Rails::FunctionalTestCase
114
114
 
115
- self.use_transactional_fixtures = true
116
- self.use_instantiated_fixtures = false
117
-
118
115
  NOTHING = Object.new # :nodoc:
119
116
 
120
117
  DEFAULT_ASSIGNS = %w[
@@ -6,8 +6,8 @@ $TESTING_RTC = defined?($TESTING_RTC) && $TESTING_RTC
6
6
 
7
7
  class Test::Rails::FunctionalTestCase < Test::Rails::TestCase
8
8
 
9
- self.use_transactional_fixtures = true
10
- self.use_instantiated_fixtures = false
9
+ include ActionController::Assertions::SelectorAssertions
10
+ include ActionController::TestProcess
11
11
 
12
12
  ##
13
13
  # Sets up instance variables to allow tests depending on a controller work.
@@ -23,9 +23,6 @@ end
23
23
 
24
24
  class Test::Rails::HelperTestCase < Test::Rails::FunctionalTestCase
25
25
 
26
- self.use_transactional_fixtures = true
27
- self.use_instantiated_fixtures = false
28
-
29
26
  # Are other helpers needed?
30
27
 
31
28
  include ActionView::Helpers::ActiveRecordHelper
@@ -3,14 +3,10 @@
3
3
  #--
4
4
  # Eventually this will hold the fixture setup stuff.
5
5
 
6
- class Test::Rails::TestCase < Test::Unit::TestCase
6
+ class Test::Rails::TestCase < ActiveSupport::TestCase
7
7
 
8
8
  undef_method :default_test
9
9
 
10
- # Set defaults because Rails has poor ones (and these don't inherit properly)
11
- self.use_transactional_fixtures = true
12
- self.use_instantiated_fixtures = false
13
-
14
10
  end
15
11
 
16
12
  module Test::Unit::Assertions
@@ -2,7 +2,7 @@ module Test
2
2
  module Rails
3
3
  module VERSION # :nodoc:
4
4
  MAJOR = 1
5
- MINOR = 0
5
+ MINOR = 1
6
6
  TINY = 0
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
@@ -95,9 +95,6 @@
95
95
 
96
96
  class Test::Rails::ViewTestCase < Test::Rails::FunctionalTestCase
97
97
 
98
- self.use_transactional_fixtures = true
99
- self.use_instantiated_fixtures = false
100
-
101
98
  ##
102
99
  # Sets up the test case.
103
100
 
@@ -204,7 +201,7 @@ class Test::Rails::ViewTestCase < Test::Rails::FunctionalTestCase
204
201
  #
205
202
  # If a view cannot be found the test will flunk.
206
203
 
207
- def render(options = {}, deprecated_status = nil)
204
+ def render(options = {}, *rest_args)
208
205
  @action_name = action_name caller[0] if options.empty?
209
206
  assigns[:action_name] = @action_name
210
207
 
@@ -238,7 +235,7 @@ class Test::Rails::ViewTestCase < Test::Rails::FunctionalTestCase
238
235
 
239
236
  # Do the render
240
237
  options[:TR_force] = true
241
- @controller.render options, deprecated_status
238
+ @controller.send(:render, options, *rest_args)
242
239
 
243
240
  # Rails 1.1
244
241
  @controller.send :process_cleanup rescue nil
data/test/test_help.rb CHANGED
@@ -22,7 +22,10 @@ module ActionView::Helpers::FormHelper; end
22
22
  module ActionView::Helpers::UrlHelper; end
23
23
  module ActionView::Helpers::AssetTagHelper; end
24
24
 
25
- class << Test::Unit::TestCase
25
+ # ActiveSupport
26
+ require 'active_support'
27
+ require 'active_support/test_case'
28
+ class << ActiveSupport::TestCase
26
29
  attr_accessor :use_transactional_fixtures
27
30
  attr_accessor :use_instantiated_fixtures
28
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omghax-test_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-03-12 00:00:00 -07:00
14
+ date: 2009-05-21 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -24,7 +24,7 @@ dependencies:
24
24
  - !ruby/object:Gem::Version
25
25
  version: 1.8.3
26
26
  version:
27
- description: "ZenTest provides 4 different tools and 1 library: zentest, unit_diff, autotest, multiruby, and Test::Rails. ZenTest scans your target and unit-test code and writes your missing code based on simple naming rules, enabling XP at a much quicker pace. ZenTest only works with Ruby and Test::Unit. unit_diff is a command-line filter to diff expected results from actual results and allow you to quickly see exactly what is wrong. autotest is a continous testing facility meant to be used during development. As soon as you save a file, autotest will run the corresponding dependent tests. multiruby runs anything you want on multiple versions of ruby. Great for compatibility checking! Use multiruby_setup to manage your installed versions. Test::Rails helps you build industrial-strength Rails code."
27
+ description: Test::Rails helps you build industrial-strength Rails code.
28
28
  email:
29
29
  - ryand-ruby@zenspider.com
30
30
  - drbrain@segment7.net
@@ -85,7 +85,7 @@ rubyforge_project: test_rails
85
85
  rubygems_version: 1.2.0
86
86
  signing_key:
87
87
  specification_version: 2
88
- summary: "ZenTest provides 4 different tools and 1 library: zentest, unit_diff, autotest, multiruby, and Test::Rails"
88
+ summary: Test::Rails helps you build industrial-strength Rails code.
89
89
  test_files:
90
90
  - test/test_help.rb
91
91
  - test/test_rails_controller_test_case.rb