francois-shoulda 2.0.5.4 → 2.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/README.rdoc +60 -10
  2. data/Rakefile +7 -7
  3. data/lib/shoulda.rb +7 -15
  4. data/lib/shoulda/action_controller.rb +28 -0
  5. data/lib/shoulda/action_controller/helpers.rb +47 -0
  6. data/lib/shoulda/action_controller/macros.rb +277 -0
  7. data/lib/shoulda/action_controller/matchers.rb +37 -0
  8. data/lib/shoulda/action_controller/matchers/assign_to_matcher.rb +109 -0
  9. data/lib/shoulda/action_controller/matchers/filter_param_matcher.rb +57 -0
  10. data/lib/shoulda/action_controller/matchers/render_with_layout_matcher.rb +81 -0
  11. data/lib/shoulda/action_controller/matchers/respond_with_content_type_matcher.rb +70 -0
  12. data/lib/shoulda/action_controller/matchers/respond_with_matcher.rb +81 -0
  13. data/lib/shoulda/action_controller/matchers/route_matcher.rb +93 -0
  14. data/lib/shoulda/action_controller/matchers/set_session_matcher.rb +87 -0
  15. data/lib/shoulda/action_controller/matchers/set_the_flash_matcher.rb +85 -0
  16. data/lib/shoulda/action_mailer.rb +1 -1
  17. data/lib/shoulda/action_mailer/assertions.rb +32 -33
  18. data/lib/shoulda/action_view.rb +10 -0
  19. data/lib/shoulda/action_view/macros.rb +56 -0
  20. data/lib/shoulda/active_record.rb +6 -2
  21. data/lib/shoulda/active_record/assertions.rb +62 -89
  22. data/lib/shoulda/active_record/helpers.rb +40 -0
  23. data/lib/shoulda/active_record/macros.rb +520 -684
  24. data/lib/shoulda/active_record/matchers.rb +42 -0
  25. data/lib/shoulda/active_record/matchers/allow_mass_assignment_of_matcher.rb +83 -0
  26. data/lib/shoulda/active_record/matchers/allow_value_matcher.rb +102 -0
  27. data/lib/shoulda/active_record/matchers/association_matcher.rb +226 -0
  28. data/lib/shoulda/active_record/matchers/ensure_inclusion_of_matcher.rb +87 -0
  29. data/lib/shoulda/active_record/matchers/ensure_length_of_matcher.rb +141 -0
  30. data/lib/shoulda/active_record/matchers/have_db_column_matcher.rb +169 -0
  31. data/lib/shoulda/active_record/matchers/have_index_matcher.rb +105 -0
  32. data/lib/shoulda/active_record/matchers/have_named_scope_matcher.rb +125 -0
  33. data/lib/shoulda/active_record/matchers/have_readonly_attribute_matcher.rb +59 -0
  34. data/lib/shoulda/active_record/matchers/validate_acceptance_of_matcher.rb +41 -0
  35. data/lib/shoulda/active_record/matchers/validate_numericality_of_matcher.rb +39 -0
  36. data/lib/shoulda/active_record/matchers/validate_presence_of_matcher.rb +60 -0
  37. data/lib/shoulda/active_record/matchers/validate_uniqueness_of_matcher.rb +148 -0
  38. data/lib/shoulda/active_record/matchers/validation_matcher.rb +56 -0
  39. data/lib/shoulda/assertions.rb +50 -40
  40. data/lib/shoulda/autoload_macros.rb +46 -0
  41. data/lib/shoulda/context.rb +124 -126
  42. data/lib/shoulda/helpers.rb +5 -7
  43. data/lib/shoulda/macros.rb +63 -64
  44. data/lib/shoulda/private_helpers.rb +16 -18
  45. data/lib/shoulda/rails.rb +5 -11
  46. data/lib/shoulda/rspec.rb +11 -0
  47. data/lib/shoulda/tasks/list_tests.rake +6 -1
  48. data/lib/shoulda/test_unit.rb +19 -0
  49. data/rails/init.rb +7 -1
  50. data/test/README +2 -2
  51. data/test/fail_macros.rb +15 -15
  52. data/test/fixtures/tags.yml +1 -1
  53. data/test/functional/posts_controller_test.rb +46 -26
  54. data/test/functional/users_controller_test.rb +0 -19
  55. data/test/matchers/active_record/allow_mass_assignment_of_matcher_test.rb +68 -0
  56. data/test/matchers/active_record/allow_value_matcher_test.rb +41 -0
  57. data/test/matchers/active_record/association_matcher_test.rb +258 -0
  58. data/test/matchers/active_record/ensure_inclusion_of_matcher_test.rb +80 -0
  59. data/test/matchers/active_record/ensure_length_of_matcher_test.rb +158 -0
  60. data/test/matchers/active_record/have_db_column_matcher_test.rb +169 -0
  61. data/test/matchers/active_record/have_index_matcher_test.rb +74 -0
  62. data/test/matchers/active_record/have_named_scope_matcher_test.rb +65 -0
  63. data/test/matchers/active_record/have_readonly_attributes_matcher_test.rb +29 -0
  64. data/test/matchers/active_record/validate_acceptance_of_matcher_test.rb +44 -0
  65. data/test/matchers/active_record/validate_numericality_of_matcher_test.rb +52 -0
  66. data/test/matchers/active_record/validate_presence_of_matcher_test.rb +86 -0
  67. data/test/matchers/active_record/validate_uniqueness_of_matcher_test.rb +147 -0
  68. data/test/matchers/controller/assign_to_matcher_test.rb +35 -0
  69. data/test/matchers/controller/filter_param_matcher_test.rb +32 -0
  70. data/test/matchers/controller/render_with_layout_matcher_test.rb +33 -0
  71. data/test/matchers/controller/respond_with_content_type_matcher_test.rb +27 -0
  72. data/test/matchers/controller/respond_with_matcher_test.rb +106 -0
  73. data/test/matchers/controller/route_matcher_test.rb +58 -0
  74. data/test/matchers/controller/set_session_matcher_test.rb +31 -0
  75. data/test/matchers/controller/set_the_flash_matcher.rb +41 -0
  76. data/test/model_builder.rb +106 -0
  77. data/test/other/autoload_macro_test.rb +18 -0
  78. data/test/other/helpers_test.rb +58 -0
  79. data/test/other/private_helpers_test.rb +1 -1
  80. data/test/other/should_test.rb +16 -16
  81. data/test/rails_root/app/controllers/posts_controller.rb +6 -5
  82. data/test/rails_root/app/models/pets/dog.rb +10 -0
  83. data/test/rails_root/app/models/treat.rb +3 -0
  84. data/test/rails_root/app/models/user.rb +4 -3
  85. data/test/rails_root/app/views/layouts/posts.rhtml +2 -0
  86. data/test/rails_root/config/database.yml +1 -1
  87. data/test/rails_root/config/environment.rb +1 -1
  88. data/test/rails_root/config/environments/{sqlite3.rb → test.rb} +0 -0
  89. data/test/rails_root/db/migrate/001_create_users.rb +3 -2
  90. data/test/rails_root/db/migrate/011_create_treats.rb +12 -0
  91. data/test/rails_root/test/shoulda_macros/custom_macro.rb +6 -0
  92. data/test/rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro.rb +6 -0
  93. data/test/rails_root/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_macro.rb +6 -0
  94. data/test/rspec_test.rb +207 -0
  95. data/test/test_helper.rb +3 -1
  96. data/test/unit/address_test.rb +1 -23
  97. data/test/unit/dog_test.rb +5 -2
  98. data/test/unit/post_test.rb +7 -3
  99. data/test/unit/product_test.rb +2 -2
  100. data/test/unit/tag_test.rb +2 -1
  101. data/test/unit/user_test.rb +25 -9
  102. metadata +84 -23
  103. data/lib/shoulda/controller.rb +0 -30
  104. data/lib/shoulda/controller/formats/html.rb +0 -201
  105. data/lib/shoulda/controller/formats/xml.rb +0 -170
  106. data/lib/shoulda/controller/helpers.rb +0 -64
  107. data/lib/shoulda/controller/macros.rb +0 -316
  108. data/lib/shoulda/controller/resource_options.rb +0 -236
  109. data/test/rails_root/app/models/dog.rb +0 -5
@@ -1,6 +1,7 @@
1
1
  require 'fileutils'
2
+
2
3
  # Load the environment
3
- ENV['RAILS_ENV'] = 'sqlite3'
4
+ ENV['RAILS_ENV'] = 'test'
4
5
 
5
6
  rails_root = File.dirname(__FILE__) + '/rails_root'
6
7
 
@@ -31,3 +32,4 @@ class Test::Unit::TestCase #:nodoc:
31
32
  end
32
33
 
33
34
  require 'test/fail_macros'
35
+ require 'test/model_builder'
@@ -4,29 +4,7 @@ class AddressTest < Test::Unit::TestCase
4
4
  fixtures :all
5
5
 
6
6
  should_belong_to :addressable
7
- should_require_unique_attributes :title, :scoped_to => [:addressable_id, :addressable_type]
7
+ should_validate_uniqueness_of :title, :scoped_to => [:addressable_id, :addressable_type]
8
8
  should_ensure_length_at_least :zip, 5
9
9
  should_only_allow_numeric_values_for :zip
10
-
11
- context "A non-numeric zip" do
12
- setup do
13
- @address = Address.new(:zip => "bc")
14
- end
15
-
16
- should "be invalid" do
17
- assert_invalid @address
18
- end
19
- end
20
-
21
- context "A numeric zip" do
22
- setup do
23
- @address = Address.new(:zip => "90210")
24
- end
25
-
26
- should_fail do
27
- should "NOT be invalid" do
28
- assert_invalid @address
29
- end
30
- end
31
- end
32
10
  end
@@ -1,7 +1,10 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
- class DogTest < Test::Unit::TestCase
3
+ class Pets::DogTest < Test::Unit::TestCase
4
4
  should_belong_to :user
5
- should_belong_to :address
5
+ should_belong_to :address, :dependent => :destroy
6
+ should_have_many :treats
6
7
  should_have_and_belong_to_many :fleas
8
+ should_require_attributes :treats, :fleas
9
+ should_validate_presence_of :owner_id
7
10
  end
@@ -9,7 +9,11 @@ class PostTest < Test::Unit::TestCase
9
9
  should_have_many :through_tags, :through => :taggings
10
10
 
11
11
  should_require_unique_attributes :title
12
- should_require_attributes :body, :message => /wtf/
13
- should_require_attributes :title
14
- should_only_allow_numeric_values_for :user_id
12
+ should_validate_presence_of :body, :message => /wtf/
13
+ should_validate_presence_of :title
14
+ should_validate_numericality_of :user_id
15
+
16
+ should_fail do
17
+ should_validate_uniqueness_of :title, :case_sensitive => false
18
+ end
15
19
  end
@@ -6,7 +6,7 @@ class ProductTest < ActiveSupport::TestCase
6
6
  @product = Product.new(:tangible => false)
7
7
  end
8
8
 
9
- should_require_attributes :title
9
+ should_validate_presence_of :title
10
10
  should_not_allow_values_for :size, "22"
11
11
  should_allow_values_for :size, "22kb"
12
12
  should_ensure_value_in_range :price, 0..99
@@ -17,7 +17,7 @@ class ProductTest < ActiveSupport::TestCase
17
17
  @product = Product.new(:tangible => true)
18
18
  end
19
19
 
20
- should_require_attributes :price
20
+ should_validate_presence_of :price
21
21
  should_ensure_value_in_range :price, 1..9999
22
22
  should_ensure_value_in_range :weight, 1..100
23
23
  should_not_allow_values_for :size, "22", "10x15"
@@ -6,7 +6,8 @@ class TagTest < Test::Unit::TestCase
6
6
 
7
7
  should_ensure_length_at_least :name, 2
8
8
 
9
- should_not_allow_mass_assignment_of :secret
9
+ should_protect_attributes :secret
10
+ should_allow_mass_assignment_of :name
10
11
 
11
12
  should_fail do
12
13
  should_not_allow_mass_assignment_of :name
@@ -14,8 +14,16 @@ class UserTest < Test::Unit::TestCase
14
14
  should_have_one :address
15
15
  should_have_one :address, :dependent => :destroy
16
16
 
17
- should_have_indices :email, :name, [:email, :name]
17
+ should_have_indices :email, :name
18
18
  should_have_index :age
19
+ should_have_index [:email, :name], :unique => true
20
+ should_have_index :age, :unique => false
21
+
22
+ should_fail do
23
+ should_have_index :phone
24
+ should_have_index :email, :unique => false
25
+ should_have_index :age, :unique => true
26
+ end
19
27
 
20
28
  should_have_named_scope :old, :conditions => "age > 50"
21
29
  should_have_named_scope :eighteen, :conditions => { :age => 18 }
@@ -32,25 +40,33 @@ class UserTest < Test::Unit::TestCase
32
40
  should_not_allow_values_for :email, "blah", "b lah"
33
41
  should_allow_values_for :email, "a@b.com", "asdf@asdf.com"
34
42
  should_ensure_length_in_range :email, 1..100
35
- should_ensure_value_in_range :age, 1..100
43
+ should_ensure_value_in_range :age, 1..100, :low_message => /greater/,
44
+ :high_message => /less/
45
+ should_fail do
46
+ should_ensure_value_in_range :age, 1..100, :low_message => /more/,
47
+ :high_message => /less/
48
+ end
49
+ should_fail do
50
+ should_ensure_value_in_range :age, 1..100, :low_message => /greater/,
51
+ :high_message => /fewer/
52
+ end
36
53
  should_not_allow_mass_assignment_of :password
37
- should_allow_mass_assignment_of :name, :email
38
54
  should_have_class_methods :find, :destroy
39
55
  should_have_instance_methods :email, :age, :email=, :valid?
40
56
  should_have_db_columns :name, :email, :age
41
- should_have_db_column :id, :type => "integer", :primary => true
42
- should_have_db_column :email, :type => "string", :default => nil, :precision => nil, :limit => 255,
43
- :null => true, :primary => false, :scale => nil, :sql_type => 'varchar(255)'
57
+ should_have_db_column :id, :type => "integer"
58
+ should_have_db_column :email, :type => "string", :default => nil, :precision => nil, :limit => 255,
59
+ :null => true, :scale => nil
60
+ should_validate_acceptance_of :eula
44
61
  should_require_acceptance_of :eula
45
- should_require_unique_attributes :email, :scoped_to => :name
62
+ should_validate_uniqueness_of :email, :scoped_to => :name, :case_sensitive => false
46
63
 
47
64
  should_ensure_length_is :ssn, 9, :message => "Social Security Number is not the right length"
48
- should_only_allow_numeric_values_for :ssn
65
+ should_validate_numericality_of :ssn
49
66
 
50
67
  should_have_readonly_attributes :name
51
68
 
52
69
  should_fail do
53
70
  should_not_allow_mass_assignment_of :name, :age
54
- should_allow_mass_assignment_of :password
55
71
  end
56
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: francois-shoulda
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5.4
4
+ version: 2.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tammer Saleh
@@ -9,18 +9,10 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-15 00:00:00 -07:00
12
+ date: 2009-03-05 00:00:00 -08:00
13
13
  default_executable: convert_to_should_syntax
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: activesupport
17
- version_requirement:
18
- version_requirements: !ruby/object:Gem::Requirement
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 2.0.0
23
- version:
14
+ dependencies: []
15
+
24
16
  description:
25
17
  email: tsaleh@thoughtbot.com
26
18
  executables:
@@ -37,32 +29,61 @@ files:
37
29
  - README.rdoc
38
30
  - bin/convert_to_should_syntax
39
31
  - lib/shoulda
32
+ - lib/shoulda/action_controller
33
+ - lib/shoulda/action_controller/helpers.rb
34
+ - lib/shoulda/action_controller/macros.rb
35
+ - lib/shoulda/action_controller/matchers
36
+ - lib/shoulda/action_controller/matchers/assign_to_matcher.rb
37
+ - lib/shoulda/action_controller/matchers/filter_param_matcher.rb
38
+ - lib/shoulda/action_controller/matchers/render_with_layout_matcher.rb
39
+ - lib/shoulda/action_controller/matchers/respond_with_content_type_matcher.rb
40
+ - lib/shoulda/action_controller/matchers/respond_with_matcher.rb
41
+ - lib/shoulda/action_controller/matchers/route_matcher.rb
42
+ - lib/shoulda/action_controller/matchers/set_session_matcher.rb
43
+ - lib/shoulda/action_controller/matchers/set_the_flash_matcher.rb
44
+ - lib/shoulda/action_controller/matchers.rb
45
+ - lib/shoulda/action_controller.rb
40
46
  - lib/shoulda/action_mailer
41
47
  - lib/shoulda/action_mailer/assertions.rb
42
48
  - lib/shoulda/action_mailer.rb
49
+ - lib/shoulda/action_view
50
+ - lib/shoulda/action_view/macros.rb
51
+ - lib/shoulda/action_view.rb
43
52
  - lib/shoulda/active_record
44
53
  - lib/shoulda/active_record/assertions.rb
54
+ - lib/shoulda/active_record/helpers.rb
45
55
  - lib/shoulda/active_record/macros.rb
56
+ - lib/shoulda/active_record/matchers
57
+ - lib/shoulda/active_record/matchers/allow_mass_assignment_of_matcher.rb
58
+ - lib/shoulda/active_record/matchers/allow_value_matcher.rb
59
+ - lib/shoulda/active_record/matchers/association_matcher.rb
60
+ - lib/shoulda/active_record/matchers/ensure_inclusion_of_matcher.rb
61
+ - lib/shoulda/active_record/matchers/ensure_length_of_matcher.rb
62
+ - lib/shoulda/active_record/matchers/have_db_column_matcher.rb
63
+ - lib/shoulda/active_record/matchers/have_index_matcher.rb
64
+ - lib/shoulda/active_record/matchers/have_named_scope_matcher.rb
65
+ - lib/shoulda/active_record/matchers/have_readonly_attribute_matcher.rb
66
+ - lib/shoulda/active_record/matchers/validate_acceptance_of_matcher.rb
67
+ - lib/shoulda/active_record/matchers/validate_numericality_of_matcher.rb
68
+ - lib/shoulda/active_record/matchers/validate_presence_of_matcher.rb
69
+ - lib/shoulda/active_record/matchers/validate_uniqueness_of_matcher.rb
70
+ - lib/shoulda/active_record/matchers/validation_matcher.rb
71
+ - lib/shoulda/active_record/matchers.rb
46
72
  - lib/shoulda/active_record.rb
47
73
  - lib/shoulda/assertions.rb
74
+ - lib/shoulda/autoload_macros.rb
48
75
  - lib/shoulda/context.rb
49
- - lib/shoulda/controller
50
- - lib/shoulda/controller/formats
51
- - lib/shoulda/controller/formats/html.rb
52
- - lib/shoulda/controller/formats/xml.rb
53
- - lib/shoulda/controller/helpers.rb
54
- - lib/shoulda/controller/macros.rb
55
- - lib/shoulda/controller/resource_options.rb
56
- - lib/shoulda/controller.rb
57
76
  - lib/shoulda/helpers.rb
58
77
  - lib/shoulda/macros.rb
59
78
  - lib/shoulda/private_helpers.rb
60
79
  - lib/shoulda/proc_extensions.rb
61
80
  - lib/shoulda/rails.rb
81
+ - lib/shoulda/rspec.rb
62
82
  - lib/shoulda/tasks
63
83
  - lib/shoulda/tasks/list_tests.rake
64
84
  - lib/shoulda/tasks/yaml_to_shoulda.rake
65
85
  - lib/shoulda/tasks.rb
86
+ - lib/shoulda/test_unit.rb
66
87
  - lib/shoulda.rb
67
88
  - rails/init.rb
68
89
  - test/fail_macros.rb
@@ -77,7 +98,33 @@ files:
77
98
  - test/functional
78
99
  - test/functional/posts_controller_test.rb
79
100
  - test/functional/users_controller_test.rb
101
+ - test/matchers
102
+ - test/matchers/active_record
103
+ - test/matchers/active_record/allow_mass_assignment_of_matcher_test.rb
104
+ - test/matchers/active_record/allow_value_matcher_test.rb
105
+ - test/matchers/active_record/association_matcher_test.rb
106
+ - test/matchers/active_record/ensure_inclusion_of_matcher_test.rb
107
+ - test/matchers/active_record/ensure_length_of_matcher_test.rb
108
+ - test/matchers/active_record/have_db_column_matcher_test.rb
109
+ - test/matchers/active_record/have_index_matcher_test.rb
110
+ - test/matchers/active_record/have_named_scope_matcher_test.rb
111
+ - test/matchers/active_record/have_readonly_attributes_matcher_test.rb
112
+ - test/matchers/active_record/validate_acceptance_of_matcher_test.rb
113
+ - test/matchers/active_record/validate_numericality_of_matcher_test.rb
114
+ - test/matchers/active_record/validate_presence_of_matcher_test.rb
115
+ - test/matchers/active_record/validate_uniqueness_of_matcher_test.rb
116
+ - test/matchers/controller
117
+ - test/matchers/controller/assign_to_matcher_test.rb
118
+ - test/matchers/controller/filter_param_matcher_test.rb
119
+ - test/matchers/controller/render_with_layout_matcher_test.rb
120
+ - test/matchers/controller/respond_with_content_type_matcher_test.rb
121
+ - test/matchers/controller/respond_with_matcher_test.rb
122
+ - test/matchers/controller/route_matcher_test.rb
123
+ - test/matchers/controller/set_session_matcher_test.rb
124
+ - test/matchers/controller/set_the_flash_matcher.rb
125
+ - test/model_builder.rb
80
126
  - test/other
127
+ - test/other/autoload_macro_test.rb
81
128
  - test/other/context_test.rb
82
129
  - test/other/convert_to_should_syntax_test.rb
83
130
  - test/other/helpers_test.rb
@@ -95,13 +142,15 @@ files:
95
142
  - test/rails_root/app/helpers/users_helper.rb
96
143
  - test/rails_root/app/models
97
144
  - test/rails_root/app/models/address.rb
98
- - test/rails_root/app/models/dog.rb
99
145
  - test/rails_root/app/models/flea.rb
100
146
  - test/rails_root/app/models/friendship.rb
147
+ - test/rails_root/app/models/pets
148
+ - test/rails_root/app/models/pets/dog.rb
101
149
  - test/rails_root/app/models/post.rb
102
150
  - test/rails_root/app/models/product.rb
103
151
  - test/rails_root/app/models/tag.rb
104
152
  - test/rails_root/app/models/tagging.rb
153
+ - test/rails_root/app/models/treat.rb
105
154
  - test/rails_root/app/models/user.rb
106
155
  - test/rails_root/app/views
107
156
  - test/rails_root/app/views/layouts
@@ -123,7 +172,7 @@ files:
123
172
  - test/rails_root/config/database.yml
124
173
  - test/rails_root/config/environment.rb
125
174
  - test/rails_root/config/environments
126
- - test/rails_root/config/environments/sqlite3.rb
175
+ - test/rails_root/config/environments/test.rb
127
176
  - test/rails_root/config/initializers
128
177
  - test/rails_root/config/initializers/new_rails_defaults.rb
129
178
  - test/rails_root/config/initializers/shoulda.rb
@@ -140,9 +189,11 @@ files:
140
189
  - test/rails_root/db/migrate/008_create_dogs_fleas.rb
141
190
  - test/rails_root/db/migrate/009_create_products.rb
142
191
  - test/rails_root/db/migrate/010_create_friendships.rb
192
+ - test/rails_root/db/migrate/011_create_treats.rb
143
193
  - test/rails_root/db/schema.rb
144
194
  - test/rails_root/log
145
195
  - test/rails_root/log/sqlite3.log
196
+ - test/rails_root/log/test.log
146
197
  - test/rails_root/public
147
198
  - test/rails_root/public/404.html
148
199
  - test/rails_root/public/422.html
@@ -150,9 +201,20 @@ files:
150
201
  - test/rails_root/script
151
202
  - test/rails_root/script/console
152
203
  - test/rails_root/script/generate
204
+ - test/rails_root/test
205
+ - test/rails_root/test/shoulda_macros
206
+ - test/rails_root/test/shoulda_macros/custom_macro.rb
153
207
  - test/rails_root/vendor
208
+ - test/rails_root/vendor/gems
209
+ - test/rails_root/vendor/gems/gem_with_macro-0.0.1
210
+ - test/rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros
211
+ - test/rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro.rb
154
212
  - test/rails_root/vendor/plugins
213
+ - test/rails_root/vendor/plugins/plugin_with_macro
214
+ - test/rails_root/vendor/plugins/plugin_with_macro/shoulda_macros
215
+ - test/rails_root/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_macro.rb
155
216
  - test/README
217
+ - test/rspec_test.rb
156
218
  - test/test_helper.rb
157
219
  - test/unit
158
220
  - test/unit/address_test.rb
@@ -169,7 +231,6 @@ homepage: http://thoughtbot.com/projects/shoulda
169
231
  post_install_message:
170
232
  rdoc_options:
171
233
  - --line-numbers
172
- - --inline-source
173
234
  - --main
174
235
  - README.rdoc
175
236
  require_paths:
@@ -1,30 +0,0 @@
1
- require 'shoulda'
2
- require 'shoulda/controller/helpers'
3
- require 'shoulda/controller/resource_options'
4
- require 'shoulda/controller/macros'
5
-
6
- module Test # :nodoc: all
7
- module Unit
8
- class TestCase
9
- extend ThoughtBot::Shoulda::Controller::Macros
10
- include ThoughtBot::Shoulda::Controller::Helpers
11
- ThoughtBot::Shoulda::Controller::VALID_FORMATS.each do |format|
12
- include "ThoughtBot::Shoulda::Controller::#{format.to_s.upcase}".constantize
13
- end
14
- end
15
- end
16
- end
17
-
18
- require 'shoulda/active_record/assertions'
19
- require 'shoulda/action_mailer/assertions'
20
-
21
- module ActionController #:nodoc: all
22
- module Integration
23
- class Session
24
- include ThoughtBot::Shoulda::Assertions
25
- include ThoughtBot::Shoulda::Helpers
26
- include ThoughtBot::Shoulda::ActiveRecord::Assertions
27
- include ThoughtBot::Shoulda::ActionMailer::Assertions
28
- end
29
- end
30
- end
@@ -1,201 +0,0 @@
1
- module ThoughtBot # :nodoc:
2
- module Shoulda # :nodoc:
3
- module Controller # :nodoc:
4
- module HTML # :nodoc: all
5
- def self.included(other)
6
- other.class_eval do
7
- extend ThoughtBot::Shoulda::Controller::HTML::ClassMethods
8
- end
9
- end
10
-
11
- module ClassMethods
12
- def controller_name_from_class
13
- self.name.gsub(/Test/, '')
14
- end
15
-
16
- def make_show_html_tests(res)
17
- context "on GET to #{controller_name_from_class}#show" do
18
- setup do
19
- record = get_existing_record(res)
20
- parent_params = make_parent_params(res, record)
21
- get :show, parent_params.merge({ res.identifier => record.to_param })
22
- end
23
-
24
- if res.denied.actions.include?(:show)
25
- should_not_assign_to res.object
26
- should_redirect_to res.denied.redirect
27
- should_set_the_flash_to res.denied.flash
28
- else
29
- should_assign_to res.object
30
- should_respond_with :success
31
- should_render_template :show
32
- should_not_set_the_flash
33
- end
34
- end
35
- end
36
-
37
- def make_edit_html_tests(res)
38
- context "on GET to #{controller_name_from_class}#edit" do
39
- setup do
40
- @record = get_existing_record(res)
41
- parent_params = make_parent_params(res, @record)
42
- get :edit, parent_params.merge({ res.identifier => @record.to_param })
43
- end
44
-
45
- if res.denied.actions.include?(:edit)
46
- should_not_assign_to res.object
47
- should_redirect_to res.denied.redirect
48
- should_set_the_flash_to res.denied.flash
49
- else
50
- should_assign_to res.object
51
- should_respond_with :success
52
- should_render_template :edit
53
- should_not_set_the_flash
54
- should_render_a_form
55
- should "set @#{res.object} to requested instance" do
56
- assert_equal @record, assigns(res.object)
57
- end
58
- end
59
- end
60
- end
61
-
62
- def make_index_html_tests(res)
63
- context "on GET to #{controller_name_from_class}#index" do
64
- setup do
65
- record = get_existing_record(res) rescue nil
66
- parent_params = make_parent_params(res, record)
67
- get(:index, parent_params)
68
- end
69
-
70
- if res.denied.actions.include?(:index)
71
- should_not_assign_to res.object.to_s.pluralize
72
- should_redirect_to res.denied.redirect
73
- should_set_the_flash_to res.denied.flash
74
- else
75
- should_respond_with :success
76
- should_assign_to res.object.to_s.pluralize
77
- should_render_template :index
78
- should_not_set_the_flash
79
- end
80
- end
81
- end
82
-
83
- def make_new_html_tests(res)
84
- context "on GET to #{controller_name_from_class}#new" do
85
- setup do
86
- record = get_existing_record(res) rescue nil
87
- parent_params = make_parent_params(res, record)
88
- get(:new, parent_params)
89
- end
90
-
91
- if res.denied.actions.include?(:new)
92
- should_not_assign_to res.object
93
- should_redirect_to res.denied.redirect
94
- should_set_the_flash_to res.denied.flash
95
- else
96
- should_respond_with :success
97
- should_assign_to res.object
98
- should_not_set_the_flash
99
- should_render_template :new
100
- should_render_a_form
101
- end
102
- end
103
- end
104
-
105
- def make_destroy_html_tests(res)
106
- context "on DELETE to #{controller_name_from_class}#destroy" do
107
- setup do
108
- @record = get_existing_record(res)
109
- parent_params = make_parent_params(res, @record)
110
- delete :destroy, parent_params.merge({ res.identifier => @record.to_param })
111
- end
112
-
113
- if res.denied.actions.include?(:destroy)
114
- should_redirect_to res.denied.redirect
115
- should_set_the_flash_to res.denied.flash
116
-
117
- should "not destroy record" do
118
- assert_nothing_raised { assert @record.reload }
119
- end
120
- else
121
- should_set_the_flash_to res.destroy.flash
122
- if res.destroy.redirect.is_a? Symbol
123
- should_respond_with res.destroy.redirect
124
- else
125
- should_redirect_to res.destroy.redirect
126
- end
127
-
128
- should "destroy record" do
129
- assert_raises(::ActiveRecord::RecordNotFound, "@#{res.object} was not destroyed.") do
130
- @record.reload
131
- end
132
- end
133
- end
134
- end
135
- end
136
-
137
- def make_create_html_tests(res)
138
- context "on POST to #{controller_name_from_class}#create with #{res.create.params.inspect}" do
139
- setup do
140
- record = get_existing_record(res) rescue nil
141
- parent_params = make_parent_params(res, record)
142
- @count = res.klass.count
143
- post :create, parent_params.merge(res.object => res.create.params)
144
- end
145
-
146
- if res.denied.actions.include?(:create)
147
- should_redirect_to res.denied.redirect
148
- should_set_the_flash_to res.denied.flash
149
- should_not_assign_to res.object
150
-
151
- should "not create new record" do
152
- assert_equal @count, res.klass.count
153
- end
154
- else
155
- should_assign_to res.object
156
- should_set_the_flash_to res.create.flash
157
- if res.create.redirect.is_a? Symbol
158
- should_respond_with res.create.redirect
159
- else
160
- should_redirect_to res.create.redirect
161
- end
162
-
163
- should "not have errors on @#{res.object}" do
164
- assert_equal [], pretty_error_messages(assigns(res.object)), "@#{res.object} has errors:"
165
- end
166
- end
167
- end
168
- end
169
-
170
- def make_update_html_tests(res)
171
- context "on PUT to #{controller_name_from_class}#update with #{res.create.params.inspect}" do
172
- setup do
173
- @record = get_existing_record(res)
174
- parent_params = make_parent_params(res, @record)
175
- put :update, parent_params.merge(res.identifier => @record.to_param, res.object => res.update.params)
176
- end
177
-
178
- if res.denied.actions.include?(:update)
179
- should_not_assign_to res.object
180
- should_redirect_to res.denied.redirect
181
- should_set_the_flash_to res.denied.flash
182
- else
183
- should_assign_to res.object
184
- should_set_the_flash_to(res.update.flash)
185
- if res.update.redirect.is_a? Symbol
186
- should_respond_with res.update.redirect
187
- else
188
- should_redirect_to res.update.redirect
189
- end
190
-
191
- should "not have errors on @#{res.object}" do
192
- assert_equal [], pretty_error_messages(assigns(res.object)), "@#{res.object} has errors:"
193
- end
194
- end
195
- end
196
- end
197
- end
198
- end
199
- end
200
- end
201
- end