formtastic-rails3 0.9.10.1 → 1.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/README.textile +32 -16
  2. data/Rakefile +11 -11
  3. data/lib/formtastic.rb +95 -30
  4. data/lib/formtastic/railtie.rb +1 -1
  5. data/lib/formtastic/util.rb +3 -2
  6. data/lib/generators/formtastic/form/form_generator.rb +4 -4
  7. data/spec/buttons_spec.rb +1 -1
  8. data/spec/commit_button_spec.rb +1 -1
  9. data/spec/custom_builder_spec.rb +1 -1
  10. data/spec/defaults_spec.rb +1 -1
  11. data/spec/error_proc_spec.rb +1 -1
  12. data/spec/errors_spec.rb +1 -1
  13. data/spec/form_helper_spec.rb +1 -1
  14. data/spec/helpers/layout_helper_spec.rb +21 -0
  15. data/spec/i18n_spec.rb +1 -1
  16. data/spec/include_blank_spec.rb +1 -1
  17. data/spec/input_spec.rb +99 -93
  18. data/spec/inputs/boolean_input_spec.rb +1 -1
  19. data/spec/inputs/check_boxes_input_spec.rb +120 -6
  20. data/spec/inputs/country_input_spec.rb +1 -1
  21. data/spec/inputs/date_input_spec.rb +1 -1
  22. data/spec/inputs/datetime_input_spec.rb +1 -1
  23. data/spec/inputs/file_input_spec.rb +1 -1
  24. data/spec/inputs/hidden_input_spec.rb +1 -1
  25. data/spec/inputs/numeric_input_spec.rb +1 -1
  26. data/spec/inputs/password_input_spec.rb +1 -1
  27. data/spec/inputs/radio_input_spec.rb +61 -2
  28. data/spec/inputs/select_input_spec.rb +1 -1
  29. data/spec/inputs/string_input_spec.rb +36 -19
  30. data/spec/inputs/text_input_spec.rb +1 -1
  31. data/spec/inputs/time_input_spec.rb +24 -2
  32. data/spec/inputs/time_zone_input_spec.rb +1 -1
  33. data/spec/inputs_spec.rb +37 -2
  34. data/spec/label_spec.rb +42 -1
  35. data/spec/semantic_errors_spec.rb +1 -1
  36. data/spec/semantic_fields_for_spec.rb +1 -1
  37. data/spec/spec_helper.rb +15 -39
  38. data/spec/{custom_macros.rb → support/custom_macros.rb} +0 -7
  39. data/spec/support/output_buffer.rb +4 -0
  40. data/spec/support/test_environment.rb +45 -0
  41. metadata +20 -14
  42. data/spec/layout_helper_spec.rb +0 -31
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'country input' do
5
5
 
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'date input' do
5
5
 
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'datetime input' do
5
5
 
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'file input' do
5
5
 
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'hidden input' do
5
5
 
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'numeric input' do
5
5
 
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'password input' do
5
5
 
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'radio input' do
5
5
 
@@ -31,7 +31,7 @@ describe 'radio input' do
31
31
 
32
32
  it 'should not link the label within the legend to any input' do
33
33
  output_buffer.concat(@form) if Formtastic::Util.rails3?
34
- output_buffer.should_not have_tag('form li fieldset legend label[@for^="post_author_id_"]')
34
+ output_buffer.should_not have_tag('form li fieldset legend label[@for]')
35
35
  end
36
36
 
37
37
  it 'should generate an ordered list with a list item for each choice' do
@@ -84,6 +84,17 @@ describe 'radio input' do
84
84
  output_buffer.concat(form) if Formtastic::Util.rails3?
85
85
  output_buffer.should have_tag("form li fieldset ol li label input[@checked='checked']")
86
86
  end
87
+
88
+ it "should not contain invalid HTML attributes" do
89
+
90
+ form = semantic_form_for(@new_post) do |builder|
91
+ concat(builder.input(:author, :as => :radio))
92
+ end
93
+
94
+ output_buffer.concat(form) if Formtastic::Util.rails3?
95
+ output_buffer.should_not have_tag("form li fieldset ol li input[@find_options]")
96
+ end
97
+
87
98
  end
88
99
 
89
100
  describe 'and no object is given' do
@@ -112,6 +123,17 @@ describe 'radio input' do
112
123
  end
113
124
  end
114
125
 
126
+ it 'should html escape the label string' do
127
+ output_buffer.replace ''
128
+ form = semantic_form_for(:project, :url => 'http://test.host') do |builder|
129
+ concat(builder.input(:author_id, :as => :radio, :collection => [["<b>Item 1</b>", 1], ["<b>Item 2</b>", 2]]))
130
+ end
131
+ output_buffer.concat(form) if Formtastic::Util.rails3?
132
+ output_buffer.should have_tag('form li fieldset ol li label') do |label|
133
+ label.body.should match /&lt;b&gt;Item [12]&lt;\/b&gt;$/
134
+ end
135
+ end
136
+
115
137
  it 'should generate inputs for each item' do
116
138
  output_buffer.concat(@form) if Formtastic::Util.rails3?
117
139
  ::Author.find(:all).each do |author|
@@ -165,5 +187,42 @@ describe 'radio input' do
165
187
  end
166
188
 
167
189
  end
190
+
191
+ describe "with i18n of the legend label" do
192
+
193
+ before do
194
+ ::I18n.backend.store_translations :en, :formtastic => { :labels => { :post => { :authors => "Translated!" }}}
168
195
 
196
+ Formtastic::SemanticFormBuilder.i18n_lookups_by_default = true
197
+ @new_post.stub!(:author_ids).and_return(nil)
198
+ @form = semantic_form_for(@new_post) do |builder|
199
+ concat(builder.input(:authors, :as => :radio))
200
+ end
201
+ end
202
+
203
+ after do
204
+ ::I18n.backend.reload!
205
+ Formtastic::SemanticFormBuilder.i18n_lookups_by_default = false
206
+ end
207
+
208
+ it "should do foo" do
209
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
210
+ output_buffer.should have_tag("legend.label label", /Translated/)
211
+ end
212
+
213
+ end
214
+
215
+ describe "when :label option is set" do
216
+ before do
217
+ @new_post.stub!(:author_ids).and_return(nil)
218
+ @form = semantic_form_for(@new_post) do |builder|
219
+ concat(builder.input(:authors, :as => :radio, :label => 'The authors'))
220
+ end
221
+ end
222
+
223
+ it "should output the correct label title" do
224
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
225
+ output_buffer.should have_tag("legend.label label", /The authors/)
226
+ end
227
+ end
169
228
  end
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'select input' do
5
5
 
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'string input' do
5
5
 
@@ -8,26 +8,30 @@ describe 'string input' do
8
8
  before do
9
9
  @output_buffer = ''
10
10
  mock_everything
11
-
12
- @form = semantic_form_for(@new_post) do |builder|
13
- concat(builder.input(:title, :as => :string))
11
+ end
12
+
13
+ describe "when object is provided" do
14
+ before do
15
+ @form = semantic_form_for(@new_post) do |builder|
16
+ concat(builder.input(:title, :as => :string))
17
+ end
14
18
  end
19
+
20
+ it_should_have_input_wrapper_with_class(:string)
21
+ it_should_have_input_wrapper_with_id("post_title_input")
22
+ it_should_have_label_with_text(/Title/)
23
+ it_should_have_label_for("post_title")
24
+ it_should_have_input_with_id("post_title")
25
+ it_should_have_input_with_type(:text)
26
+ it_should_have_input_with_name("post[title]")
27
+ it_should_have_maxlength_matching_column_limit
28
+ it_should_use_default_text_field_size_for_columns_longer_than_default_text_field_size(:string)
29
+ it_should_use_column_size_for_columns_shorter_than_default_text_field_size(:string)
30
+ it_should_use_default_text_field_size_when_method_has_no_database_column(:string)
31
+ it_should_apply_custom_input_attributes_when_input_html_provided(:string)
32
+ it_should_apply_custom_for_to_label_when_input_html_id_provided(:string)
33
+ it_should_apply_error_logic_for_input_type(:string)
15
34
  end
16
-
17
- it_should_have_input_wrapper_with_class(:string)
18
- it_should_have_input_wrapper_with_id("post_title_input")
19
- it_should_have_label_with_text(/Title/)
20
- it_should_have_label_for("post_title")
21
- it_should_have_input_with_id("post_title")
22
- it_should_have_input_with_type(:text)
23
- it_should_have_input_with_name("post[title]")
24
- it_should_have_maxlength_matching_column_limit
25
- it_should_use_default_text_field_size_for_columns_longer_than_default_text_field_size(:string)
26
- it_should_use_column_size_for_columns_shorter_than_default_text_field_size(:string)
27
- it_should_use_default_text_field_size_when_method_has_no_database_column(:string)
28
- it_should_apply_custom_input_attributes_when_input_html_provided(:string)
29
- it_should_apply_custom_for_to_label_when_input_html_id_provided(:string)
30
- it_should_apply_error_logic_for_input_type(:string)
31
35
 
32
36
  describe "when no object is provided" do
33
37
  before do
@@ -43,5 +47,18 @@ describe 'string input' do
43
47
  it_should_have_input_with_name("project[title]")
44
48
  end
45
49
 
50
+ describe "when size is nil" do
51
+ before do
52
+ @form = semantic_form_for(:project, :url => 'http://test.host/') do |builder|
53
+ concat(builder.input(:title, :as => :string, :input_html => {:size => nil}))
54
+ end
55
+ end
56
+
57
+ it "should have no size attribute" do
58
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
59
+ output_buffer.should_not have_tag("input[@size]")
60
+ end
61
+ end
62
+
46
63
  end
47
64
 
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'text input' do
5
5
 
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'time input' do
5
5
 
@@ -15,7 +15,29 @@ describe 'time input' do
15
15
  ::I18n.backend.reload!
16
16
  output_buffer.replace ''
17
17
  end
18
-
18
+
19
+ describe "with :ignore_date" do
20
+ before do
21
+ @form = semantic_form_for(@new_post) do |builder|
22
+ concat(builder.input(:publish_at, :as => :time, :ignore_date => true))
23
+ end
24
+ end
25
+
26
+ it 'should not have an input for day, month and year' do
27
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
28
+ output_buffer.should_not have_tag('#post_publish_at_1i')
29
+ output_buffer.should_not have_tag('#post_publish_at_2i')
30
+ output_buffer.should_not have_tag('#post_publish_at_3i')
31
+ end
32
+
33
+ it 'should have an input for hour and minute' do
34
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
35
+ output_buffer.should have_tag('#post_publish_at_4i')
36
+ output_buffer.should have_tag('#post_publish_at_5i')
37
+ end
38
+
39
+ end
40
+
19
41
  describe "without seconds" do
20
42
  before do
21
43
  @form = semantic_form_for(@new_post) do |builder|
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'time_zone input' do
5
5
 
data/spec/inputs_spec.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'SemanticFormBuilder#inputs' do
5
5
 
@@ -82,7 +82,23 @@ describe 'SemanticFormBuilder#inputs' do
82
82
  output_buffer.should_not have_tag("form fieldset.inputs #author_login")
83
83
 
84
84
  end
85
-
85
+
86
+ it 'should concat rendered nested inputs to the template under rails3' do
87
+ @bob.stub!(:column_for_attribute).and_return(mock('column', :type => :string, :limit => 255))
88
+ ::Formtastic::Util.stub!(:rails3?).and_return(true)
89
+
90
+ form = semantic_form_for(@new_post) do |builder|
91
+ builder.inputs :for => [:author, @bob] do |bob_builder|
92
+ concat(bob_builder.input(:login))
93
+ end
94
+ end
95
+
96
+ output_buffer.concat(form) if Formtastic::Util.rails3?
97
+ output_buffer.should have_tag("form fieldset.inputs #post_author_attributes_login")
98
+ output_buffer.should_not have_tag("form fieldset.inputs #author_login")
99
+
100
+ end
101
+
86
102
  describe "as a symbol representing the association name" do
87
103
 
88
104
  it 'should nest the inputs with an _attributes suffix on the association name' do
@@ -98,6 +114,25 @@ describe 'SemanticFormBuilder#inputs' do
98
114
 
99
115
  end
100
116
 
117
+ describe "as a symbol representing a has_many association name" do
118
+ before do
119
+ @new_post.stub!(:authors).and_return([@bob, @fred])
120
+ @new_post.stub!(:authors_attributes=)
121
+ end
122
+
123
+ it 'should nest the inputs with a name input for each item' do
124
+ form = semantic_form_for(@new_post) do |post|
125
+ post.inputs :for => :authors do |author|
126
+ concat(author.input(:login))
127
+ end
128
+ end
129
+
130
+ output_buffer.concat(form) if Formtastic::Util.rails3?
131
+ output_buffer.should have_tag("form input[@name='post[authors_attributes][0][login]']")
132
+ output_buffer.should have_tag("form input[@name='post[authors_attributes][1][login]']")
133
+ end
134
+ end
135
+
101
136
  describe 'as an array containing the a symbole for the association name and the associated object' do
102
137
 
103
138
  it 'should nest the inputs with an _attributes suffix on the association name' do
data/spec/label_spec.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'SemanticFormBuilder#label' do
5
5
 
@@ -30,6 +30,26 @@ describe 'SemanticFormBuilder#label' do
30
30
  end
31
31
  end
32
32
 
33
+ describe 'when a collection is given' do
34
+ it 'should use a supplied label_method for simple collections' do
35
+ form = semantic_form_for(:project, :url => 'http://test.host') do |builder|
36
+ concat(builder.input(:author_id, :as => :check_boxes, :collection => [:a, :b, :c], :value_method => :to_s, :label_method => proc {|f| ('Label_%s' % [f])}))
37
+ end
38
+ output_buffer.concat(form) if Formtastic::Util.rails3?
39
+ output_buffer.should have_tag('form li fieldset ol li label', :with => /Label_[abc]/, :count => 3)
40
+ end
41
+
42
+ it 'should use a supplied value_method for simple collections' do
43
+ form = semantic_form_for(:project, :url => 'http://test.host') do |builder|
44
+ concat(builder.input(:author_id, :as => :check_boxes, :collection => [:a, :b, :c], :value_method => proc {|f| ('Value_%s' % [f.to_s])}))
45
+ end
46
+ output_buffer.concat(form) if Formtastic::Util.rails3?
47
+ output_buffer.should have_tag('form li fieldset ol li label input[value="Value_a"]')
48
+ output_buffer.should have_tag('form li fieldset ol li label input[value="Value_b"]')
49
+ output_buffer.should have_tag('form li fieldset ol li label input[value="Value_c"]')
50
+ end
51
+ end
52
+
33
53
  describe 'when label is given' do
34
54
  it 'should allow the text to be given as label option' do
35
55
  semantic_form_for(@new_post) do |builder|
@@ -42,6 +62,27 @@ describe 'SemanticFormBuilder#label' do
42
62
  builder.label(:login, :label => false).should be_blank
43
63
  end
44
64
  end
65
+
66
+ it 'should html escape the label string by default' do
67
+ semantic_form_for(@new_post) do |builder|
68
+ builder.label(:login, :required => false, :label => '<b>My label</b>').should == "<label for=\"post_login\">&lt;b&gt;My label&lt;/b&gt;</label>"
69
+ end
70
+ end
71
+
72
+ it 'should not html escape the label if configured that way' do
73
+ ::Formtastic::SemanticFormBuilder.escape_html_entities_in_hints_and_labels = false
74
+ semantic_form_for(@new_post) do |builder|
75
+ builder.label(:login, :required => false, :label => '<b>My label</b>').should == "<label for=\"post_login\"><b>My label</b></label>"
76
+ end
77
+ end
78
+
79
+ it 'should not html escape the label string for html_safe strings' do
80
+ ::Formtastic::SemanticFormBuilder.escape_html_entities_in_hints_and_labels = true
81
+ semantic_form_for(@new_post) do |builder|
82
+ builder.label(:login, :required => false, :label => '<b>My label</b>'.html_safe).should == "<label for=\"post_login\"><b>My label</b></label>"
83
+ end
84
+ end
85
+
45
86
  end
46
87
 
47
88
  end
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'SemanticFormBuilder#semantic_errors' do
5
5
 
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.dirname(__FILE__) + '/spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe 'SemanticFormBuilder#semantic_fields_for' do
5
5
 
data/spec/spec_helper.rb CHANGED
@@ -1,53 +1,23 @@
1
1
  # coding: utf-8
2
2
  require 'rubygems'
3
-
4
- gem 'activesupport', '>=2.3.8'
5
- gem 'actionpack', '>=2.3.8'
6
3
  require 'active_support'
7
4
  require 'action_pack'
8
5
  require 'action_view'
9
6
  require 'action_controller'
7
+ require 'action_mailer'
10
8
 
11
- begin
12
- gem 'activemodel', '>= 3.0.0.beta'
13
- require 'active_model'
14
- rescue Exception
15
- end
16
-
17
- gem 'rspec', '>= 1.2.6'
18
- gem 'rspec-rails', '>= 1.2.6'
19
- gem 'hpricot', '>= 0.6.1'
20
- gem 'rspec_tag_matchers', '>= 1.0.0'
21
- require 'rspec_tag_matchers'
22
-
23
- require 'custom_macros'
24
-
25
- begin
26
- Spec::Runner.configure do |config|
27
- config.include(RspecTagMatchers)
28
- config.include(CustomMacros)
29
- end
30
- rescue
31
- require 'rspec/core'
32
- Rspec.configure do |config|
33
- config.include RspecTagMatchers
34
- config.include CustomMacros
35
- config.mock_with :rspec
36
- end
37
- end
38
-
39
- require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic'))
40
9
  require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic/util'))
10
+ require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic'))
41
11
  require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic/layout_helper'))
42
12
 
43
- module ActionView
44
- class OutputBuffer < Formtastic::Util.rails_safe_buffer_class
45
- end
46
- end
13
+ # Requires supporting files with custom matchers and macros, etc,
14
+ # in ./support/ and its subdirectories in alphabetic order.
15
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each {|f| require f}
47
16
 
48
17
  module FormtasticSpecHelper
49
18
  include ActionPack
50
19
  include ActionView::Context if defined?(ActionView::Context)
20
+ include ActionController::RecordIdentifier
51
21
  include ActionView::Helpers::FormHelper
52
22
  include ActionView::Helpers::FormTagHelper
53
23
  include ActionView::Helpers::FormOptionsHelper
@@ -56,12 +26,11 @@ module FormtasticSpecHelper
56
26
  include ActionView::Helpers::TextHelper
57
27
  include ActionView::Helpers::ActiveRecordHelper if defined?(ActionView::Helpers::ActiveRecordHelper)
58
28
  include ActionView::Helpers::ActiveModelHelper if defined?(ActionView::Helpers::ActiveModelHelper)
59
- include ActionView::Helpers::RecordIdentificationHelper
60
29
  include ActionView::Helpers::DateHelper
61
30
  include ActionView::Helpers::CaptureHelper
62
31
  include ActionView::Helpers::AssetTagHelper
63
32
  include ActiveSupport
64
- include ActionController::PolymorphicRoutes
33
+ include ActionController::PolymorphicRoutes if defined?(ActionController::PolymorphicRoutes)
65
34
 
66
35
  include Formtastic::SemanticFormHelper
67
36
 
@@ -123,11 +92,17 @@ module FormtasticSpecHelper
123
92
  extend ActiveModel::Naming if defined?(ActiveModel::Naming)
124
93
  include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
125
94
  end
95
+ class ::PostModel
96
+ extend ActiveModel::Naming if defined?(ActiveModel::Naming)
97
+ include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
98
+ end
126
99
 
127
100
  def mock_everything
128
101
 
129
102
  # Resource-oriented styles like form_for(@post) will expect a path method for the object,
130
103
  # so we're defining some here.
104
+ def post_models_path; "/postmodels/1"; end
105
+
131
106
  def post_path(o); "/posts/1"; end
132
107
  def posts_path; "/posts"; end
133
108
  def new_post_path; "/posts/new"; end
@@ -147,6 +122,7 @@ module FormtasticSpecHelper
147
122
  @fred.stub!(:persisted?).and_return(nil)
148
123
 
149
124
  @bob = mock('user')
125
+ @bob.stub!(:to_ary)
150
126
  @bob.stub!(:class).and_return(::Author)
151
127
  @bob.stub!(:to_label).and_return('Bob Rock')
152
128
  @bob.stub!(:login).and_return('bob')
@@ -212,7 +188,7 @@ module FormtasticSpecHelper
212
188
  ::Post.stub!(:human_attribute_name).and_return { |column_name| column_name.humanize }
213
189
  ::Post.stub!(:human_name).and_return('Post')
214
190
  ::Post.stub!(:reflect_on_all_validations).and_return([])
215
- ::Post.stub!(:reflect_on_validations_for).and_return([]) if defined?(Rspec)
191
+ ::Post.stub!(:reflect_on_validations_for).and_return([])
216
192
  ::Post.stub!(:reflections).and_return({})
217
193
  ::Post.stub!(:reflect_on_association).and_return do |column_name|
218
194
  case column_name