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 +6 -0
- data/Manifest.txt +1 -0
- data/README.txt +60 -44
- data/lib/test/rails.rb +5 -1
- data/lib/test/rails/controller_test_case.rb +0 -3
- data/lib/test/rails/functional_test_case.rb +2 -2
- data/lib/test/rails/helper_test_case.rb +0 -3
- data/lib/test/rails/test_case.rb +1 -5
- data/lib/test/rails/version.rb +1 -1
- data/lib/test/rails/view_test_case.rb +2 -5
- data/test/test_help.rb +4 -1
- metadata +4 -4
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -1,68 +1,84 @@
|
|
1
|
-
=
|
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
|
-
|
10
|
-
|
14
|
+
Test::Rails helps you build industrial-strength Rails code.
|
15
|
+
|
16
|
+
== FEATURES
|
11
17
|
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
17
|
-
actual results and allow you to quickly see exactly what is wrong.
|
25
|
+
== SYNOPSYS
|
18
26
|
|
19
|
-
|
20
|
-
|
21
|
-
corresponding dependent tests.
|
27
|
+
# Typical View Test
|
28
|
+
class RouteViewTest < Test::Rails::ViewTestCase
|
22
29
|
|
23
|
-
|
24
|
-
for compatibility checking! Use multiruby_setup to manage your
|
25
|
-
installed versions.
|
30
|
+
fixtures :users, :routes, :points, :photos
|
26
31
|
|
27
|
-
|
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
|
-
|
37
|
+
# render template for the delete action in RouteController
|
38
|
+
render
|
30
39
|
|
31
|
-
|
32
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
40
|
-
tests, allowing for very rapid development of both tests and
|
41
|
-
implementation.
|
52
|
+
end
|
42
53
|
|
43
|
-
|
54
|
+
# Typical Layout Test
|
55
|
+
require 'test/test_helper'
|
44
56
|
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
61
|
+
class LayoutsViewTest < Test::Rails::ViewTestCase
|
55
62
|
|
56
|
-
|
63
|
+
fixtures :users, :routes, :points, :photos
|
57
64
|
|
58
|
-
|
65
|
+
def test_default
|
66
|
+
# Template set-up
|
67
|
+
@request.request_uri = '/foo'
|
68
|
+
assigns[:action_title] = 'Hello & Goodbye'
|
59
69
|
|
60
|
-
|
70
|
+
# Render an empty string with the 'application' layout.
|
71
|
+
render :text => '', :layout => 'application'
|
61
72
|
|
62
|
-
|
63
|
-
|
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 & Goodbye'
|
78
|
+
assert_h 1, 'Hello & Goodbye'
|
79
|
+
end
|
64
80
|
|
65
|
-
|
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
|
-
*
|
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
|
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
|
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
|
295
|
+
class ActiveSupport::TestCase # :nodoc:
|
292
296
|
self.use_transactional_fixtures = true
|
293
297
|
self.use_instantiated_fixtures = false
|
294
298
|
end
|
@@ -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
|
-
|
10
|
-
|
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.
|
data/lib/test/rails/test_case.rb
CHANGED
@@ -3,14 +3,10 @@
|
|
3
3
|
#--
|
4
4
|
# Eventually this will hold the fixture setup stuff.
|
5
5
|
|
6
|
-
class Test::Rails::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
|
data/lib/test/rails/version.rb
CHANGED
@@ -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 = {},
|
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,
|
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
|
-
|
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.
|
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-
|
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:
|
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:
|
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
|