Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 306 lines (261 sloc) 12.401 kB
0a59e0c @yabawock Always use # encoding: utf-8 declaration
yabawock authored
1 # encoding: utf-8
281dd18 @xaviershay rspec support - test_helper and rake task
xaviershay authored
2 require 'rubygems'
9604949 @justinfrench smart_require is tripping up the CI build, and also tripped me up a f…
authored
3 require 'active_support'
4 require 'action_pack'
5 require 'action_view'
6 require 'action_controller'
3244014 @asanghi make spec pass on rails3
asanghi authored
7 #require 'action_mailer'
542d308 @grimen Fixing some issues with the specs to get them to run on Ruby 1.9.x. S…
grimen authored
8
fe63045 @yabawock Use HTML safe strings in tests
yabawock authored
9 require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic/util'))
b86266e @yabawock Separate test environment setup and misc setup blocks into spec/suppo…
yabawock authored
10 require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic'))
127a6b9 @justinfrench Added a Formtastic::LayoutHelper with formtastic_stylesheets so that …
authored
11 require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic/layout_helper'))
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
12
b86266e @yabawock Separate test environment setup and misc setup blocks into spec/suppo…
yabawock authored
13 # Requires supporting files with custom matchers and macros, etc,
2c68cd3 @huerlisi Sort list of files to require in spec helper.
huerlisi authored
14 # in ./support/ and its subdirectories in alphabetic order.
15 Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each {|f| require f}
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
16
17 module FormtasticSpecHelper
82f6c8d @justinfrench Fixes deprecation warnings with form_for(:name, @resource) in rails3 …
authored
18 include ActionPack
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
19 include ActionView::Context if defined?(ActionView::Context)
229eb53 @yabawock Make testsuite work with Rails 3.0.0.rc and RSpec 2.0.0.beta19
yabawock authored
20 include ActionController::RecordIdentifier
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
21 include ActionView::Helpers::FormHelper
22 include ActionView::Helpers::FormTagHelper
23 include ActionView::Helpers::FormOptionsHelper
24 include ActionView::Helpers::UrlHelper
25 include ActionView::Helpers::TagHelper
26 include ActionView::Helpers::TextHelper
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
27 include ActionView::Helpers::ActiveRecordHelper if defined?(ActionView::Helpers::ActiveRecordHelper)
28 include ActionView::Helpers::ActiveModelHelper if defined?(ActionView::Helpers::ActiveModelHelper)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
29 include ActionView::Helpers::DateHelper
30 include ActionView::Helpers::CaptureHelper
127a6b9 @justinfrench Added a Formtastic::LayoutHelper with formtastic_stylesheets so that …
authored
31 include ActionView::Helpers::AssetTagHelper
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
32 include ActiveSupport
229eb53 @yabawock Make testsuite work with Rails 3.0.0.rc and RSpec 2.0.0.beta19
yabawock authored
33 include ActionController::PolymorphicRoutes if defined?(ActionController::PolymorphicRoutes)
433dae2 @yabawock Whitespace Cleanup
yabawock authored
34
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
35 include Formtastic::SemanticFormHelper
433dae2 @yabawock Whitespace Cleanup
yabawock authored
36
82f6c8d @justinfrench Fixes deprecation warnings with form_for(:name, @resource) in rails3 …
authored
37 def rails3?
38 ActionPack::VERSION::MAJOR > 2
39 end
40
41 def rails2?
42 ActionPack::VERSION::MAJOR == 2
43 end
433dae2 @yabawock Whitespace Cleanup
yabawock authored
44
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
45 def default_input_type(column_type, column_name = :generic_column_name)
46 @new_post.stub!(column_name)
47 @new_post.stub!(:column_for_attribute).and_return(mock('column', :type => column_type)) unless column_type.nil?
48
49 semantic_form_for(@new_post) do |builder|
50 @default_type = builder.send(:default_input_type, column_name)
51 end
52
53 return @default_type
54 end
433dae2 @yabawock Whitespace Cleanup
yabawock authored
55
98ceff5 @koppen Automatically set maxlength if object is an ActiveModel and the field…
koppen authored
56 def active_model_validator(kind, attributes, options = {})
57 validator = mock("ActiveModel::Validations::#{kind.to_s.titlecase}Validator", :attributes => attributes, :options => options)
58 validator.stub!(:kind).and_return(kind)
59 validator
60 end
61
2769784 @tetsuo692 add active_model_presence_validator helper and clean up test
tetsuo692 authored
62 def active_model_presence_validator(attributes, options = {})
98ceff5 @koppen Automatically set maxlength if object is an ActiveModel and the field…
koppen authored
63 active_model_validator(:presence, attributes, options)
2769784 @tetsuo692 add active_model_presence_validator helper and clean up test
tetsuo692 authored
64 end
98ceff5 @koppen Automatically set maxlength if object is an ActiveModel and the field…
koppen authored
65
66 def active_model_length_validator(attributes, options = {})
67 active_model_validator(:length, attributes, options)
68 end
69
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
70 class ::Post
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
71 extend ActiveModel::Naming if defined?(ActiveModel::Naming)
72 include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
73
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
74 def id
75 end
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
76
77 def persisted?
78 end
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
79 end
d33fad4 @akaspick Fix incorrect html class name being generated for namespaced objects.
akaspick authored
80 module ::Namespaced
81 class Post
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
82 extend ActiveModel::Naming if defined?(ActiveModel::Naming)
83 include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
84
d33fad4 @akaspick Fix incorrect html class name being generated for namespaced objects.
akaspick authored
85 def id
86 end
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
87
88 def persisted?
89 end
d33fad4 @akaspick Fix incorrect html class name being generated for namespaced objects.
akaspick authored
90 end
91 end
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
92 class ::Author
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
93 extend ActiveModel::Naming if defined?(ActiveModel::Naming)
94 include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
95
33a5d23 Added :group_by option to select input (issue #54)
Jeroen van Dijk authored
96 def to_label
97 end
98 end
99 class ::Continent
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
100 extend ActiveModel::Naming if defined?(ActiveModel::Naming)
101 include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
102 end
506182b @yabawock Make ActiveModel Tests work without relying on RSpec unstub!
yabawock authored
103 class ::PostModel
104 extend ActiveModel::Naming if defined?(ActiveModel::Naming)
105 include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
106 end
433dae2 @yabawock Whitespace Cleanup
yabawock authored
107
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
108 def mock_everything
433dae2 @yabawock Whitespace Cleanup
yabawock authored
109
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
110 # Resource-oriented styles like form_for(@post) will expect a path method for the object,
111 # so we're defining some here.
506182b @yabawock Make ActiveModel Tests work without relying on RSpec unstub!
yabawock authored
112 def post_models_path; "/postmodels/1"; end
113
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
114 def post_path(o); "/posts/1"; end
115 def posts_path; "/posts"; end
116 def new_post_path; "/posts/new"; end
117
118 def author_path(o); "/authors/1"; end
119 def authors_path; "/authors"; end
120 def new_author_path; "/authors/new"; end
433dae2 @yabawock Whitespace Cleanup
yabawock authored
121
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
122 @fred = mock('user')
efbb09c @yabawock More ruby 1.9.2 fixes for the testsuite
yabawock authored
123 @fred.stub!(:to_ary)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
124 @fred.stub!(:class).and_return(::Author)
125 @fred.stub!(:to_label).and_return('Fred Smith')
126 @fred.stub!(:login).and_return('fred_smith')
127 @fred.stub!(:id).and_return(37)
128 @fred.stub!(:new_record?).and_return(false)
129 @fred.stub!(:errors).and_return(mock('errors', :[] => nil))
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
130 @fred.stub!(:to_key).and_return(nil)
131 @fred.stub!(:persisted?).and_return(nil)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
132
133 @bob = mock('user')
57a16f4 @yabawock Make tests work with ruby 1.9.2
yabawock authored
134 @bob.stub!(:to_ary)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
135 @bob.stub!(:class).and_return(::Author)
136 @bob.stub!(:to_label).and_return('Bob Rock')
137 @bob.stub!(:login).and_return('bob')
b326984 @justinfrench trying to move as much set up as possible into mock_everything
authored
138 @bob.stub!(:created_at)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
139 @bob.stub!(:id).and_return(42)
140 @bob.stub!(:posts).and_return([])
141 @bob.stub!(:post_ids).and_return([])
142 @bob.stub!(:new_record?).and_return(false)
143 @bob.stub!(:errors).and_return(mock('errors', :[] => nil))
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
144 @bob.stub!(:to_key).and_return(nil)
145 @bob.stub!(:persisted?).and_return(nil)
433dae2 @yabawock Whitespace Cleanup
yabawock authored
146
33a5d23 Added :group_by option to select input (issue #54)
Jeroen van Dijk authored
147 @james = mock('user')
efbb09c @yabawock More ruby 1.9.2 fixes for the testsuite
yabawock authored
148 @james.stub!(:to_ary)
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
149 @james.stub!(:class).and_return(::Author)
150 @james.stub!(:to_label).and_return('James Shock')
151 @james.stub!(:login).and_return('james')
152 @james.stub!(:id).and_return(75)
153 @james.stub!(:posts).and_return([])
154 @james.stub!(:post_ids).and_return([])
155 @james.stub!(:new_record?).and_return(false)
156 @james.stub!(:errors).and_return(mock('errors', :[] => nil))
157 @james.stub!(:to_key).and_return(nil)
158 @james.stub!(:persisted?).and_return(nil)
433dae2 @yabawock Whitespace Cleanup
yabawock authored
159
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
160
161 ::Author.stub!(:find).and_return([@fred, @bob])
2f27975 @yabawock Fix testsuite to match use of :all.
yabawock authored
162 ::Author.stub!(:all).and_return([@fred, @bob])
efbb09c @yabawock More ruby 1.9.2 fixes for the testsuite
yabawock authored
163 ::Author.stub!(:to_ary)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
164 ::Author.stub!(:human_attribute_name).and_return { |column_name| column_name.humanize }
165 ::Author.stub!(:human_name).and_return('::Author')
166 ::Author.stub!(:reflect_on_association).and_return { |column_name| mock('reflection', :options => {}, :klass => Post, :macro => :has_many) if column_name == :posts }
17f6668 @justinfrench Revert "This reverts commit 440bd2d8da117acdbca57fa199c115caefcd87c0."
authored
167 ::Author.stub!(:content_columns).and_return([mock('column', :name => 'login'), mock('column', :name => 'created_at')])
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
168 ::Author.stub!(:to_key).and_return(nil)
169 ::Author.stub!(:persisted?).and_return(nil)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
170
171 # Sometimes we need a mock @post object and some Authors for belongs_to
172 @new_post = mock('post')
efbb09c @yabawock More ruby 1.9.2 fixes for the testsuite
yabawock authored
173 @new_post.stub!(:to_ary)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
174 @new_post.stub!(:class).and_return(::Post)
175 @new_post.stub!(:id).and_return(nil)
176 @new_post.stub!(:new_record?).and_return(true)
177 @new_post.stub!(:errors).and_return(mock('errors', :[] => nil))
178 @new_post.stub!(:author).and_return(nil)
2814011 @yabawock Merge branch 'master' into rails3
yabawock authored
179 @new_post.stub!(:reviewer).and_return(nil)
9c1daba Added regression spec for a belongs_to association with :group_by => …
Jacob Kjeldahl authored
180 @new_post.stub!(:main_post).and_return(nil)
181 @new_post.stub!(:sub_posts).and_return([]) #TODO should be a mock with methods for adding sub posts
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
182 @new_post.stub!(:to_key).and_return(nil)
183 @new_post.stub!(:to_model).and_return(@new_post)
184 @new_post.stub!(:persisted?).and_return(nil)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
185
186 @freds_post = mock('post')
efbb09c @yabawock More ruby 1.9.2 fixes for the testsuite
yabawock authored
187 @freds_post.stub!(:to_ary)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
188 @freds_post.stub!(:class).and_return(::Post)
189 @freds_post.stub!(:to_label).and_return('Fred Smith')
190 @freds_post.stub!(:id).and_return(19)
191 @freds_post.stub!(:author).and_return(@fred)
192 @freds_post.stub!(:author_id).and_return(@fred.id)
193 @freds_post.stub!(:authors).and_return([@fred])
194 @freds_post.stub!(:author_ids).and_return([@fred.id])
195 @freds_post.stub!(:new_record?).and_return(false)
196 @freds_post.stub!(:errors).and_return(mock('errors', :[] => nil))
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
197 @freds_post.stub!(:to_key).and_return(nil)
198 @freds_post.stub!(:persisted?).and_return(nil)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
199 @fred.stub!(:posts).and_return([@freds_post])
200 @fred.stub!(:post_ids).and_return([@freds_post.id])
201
202 ::Post.stub!(:human_attribute_name).and_return { |column_name| column_name.humanize }
203 ::Post.stub!(:human_name).and_return('Post')
204 ::Post.stub!(:reflect_on_all_validations).and_return([])
506182b @yabawock Make ActiveModel Tests work without relying on RSpec unstub!
yabawock authored
205 ::Post.stub!(:reflect_on_validations_for).and_return([])
1bd9545 @justinfrench belongs_to associations will now render errors attached to the associ…
authored
206 ::Post.stub!(:reflections).and_return({})
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
207 ::Post.stub!(:reflect_on_association).and_return do |column_name|
208 case column_name
209 when :author, :author_status
33a5d23 Added :group_by option to select input (issue #54)
Jeroen van Dijk authored
210 mock = mock('reflection', :options => {}, :klass => ::Author, :macro => :belongs_to)
211 mock.stub!(:[]).with(:class_name).and_return("Author")
212 mock
2814011 @yabawock Merge branch 'master' into rails3
yabawock authored
213 when :reviewer
214 mock = mock('reflection', :options => {:class_name => 'Author'}, :klass => ::Author, :macro => :belongs_to)
74eaf33 @gpetrica added test case for model that has 2 belongs_to fields pointing to sa…
gpetrica authored
215 mock.stub!(:[]).with(:class_name).and_return("Author")
216 mock
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
217 when :authors
218 mock('reflection', :options => {}, :klass => ::Author, :macro => :has_and_belongs_to_many)
9c1daba Added regression spec for a belongs_to association with :group_by => …
Jacob Kjeldahl authored
219 when :sub_posts
220 mock('reflection', :options => {}, :klass => ::Post, :macro => :has_many)
221 when :main_post
222 mock('reflection', :options => {}, :klass => ::Post, :macro => :belongs_to)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
223 end
433dae2 @yabawock Whitespace Cleanup
yabawock authored
224
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
225 end
226 ::Post.stub!(:find).and_return([@freds_post])
2f27975 @yabawock Fix testsuite to match use of :all.
yabawock authored
227 ::Post.stub!(:all).and_return([@freds_post])
17f6668 @justinfrench Revert "This reverts commit 440bd2d8da117acdbca57fa199c115caefcd87c0."
authored
228 ::Post.stub!(:content_columns).and_return([mock('column', :name => 'title'), mock('column', :name => 'body'), mock('column', :name => 'created_at')])
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
229 ::Post.stub!(:to_key).and_return(nil)
230 ::Post.stub!(:persisted?).and_return(nil)
efbb09c @yabawock More ruby 1.9.2 fixes for the testsuite
yabawock authored
231 ::Post.stub!(:to_ary)
433dae2 @yabawock Whitespace Cleanup
yabawock authored
232
7466c77 @justinfrench moved the #inputs and #input specs out to their own file, and moved m…
authored
233 @new_post.stub!(:title)
efbb09c @yabawock More ruby 1.9.2 fixes for the testsuite
yabawock authored
234 @new_post.stub!(:to_ary)
7466c77 @justinfrench moved the #inputs and #input specs out to their own file, and moved m…
authored
235 @new_post.stub!(:body)
236 @new_post.stub!(:published)
b326984 @justinfrench trying to move as much set up as possible into mock_everything
authored
237 @new_post.stub!(:publish_at)
17f6668 @justinfrench Revert "This reverts commit 440bd2d8da117acdbca57fa199c115caefcd87c0."
authored
238 @new_post.stub!(:created_at)
b326984 @justinfrench trying to move as much set up as possible into mock_everything
authored
239 @new_post.stub!(:secret)
e0a7874 @asanghi Added auto-guessing and updated some docs
asanghi authored
240 @new_post.stub!(:url)
241 @new_post.stub!(:email)
242 @new_post.stub!(:search)
243 @new_post.stub!(:phone)
b326984 @justinfrench trying to move as much set up as possible into mock_everything
authored
244 @new_post.stub!(:time_zone)
245 @new_post.stub!(:category_name)
246 @new_post.stub!(:allow_comments)
3ae6b20 @justinfrench An input without an :as option will only route to country_input if th…
authored
247 @new_post.stub!(:country)
248 @new_post.stub!(:country_subdivision)
249 @new_post.stub!(:country_code)
7466c77 @justinfrench moved the #inputs and #input specs out to their own file, and moved m…
authored
250 @new_post.stub!(:column_for_attribute).with(:meta_description).and_return(mock('column', :type => :string, :limit => 255))
b326984 @justinfrench trying to move as much set up as possible into mock_everything
authored
251 @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :string, :limit => 50))
7466c77 @justinfrench moved the #inputs and #input specs out to their own file, and moved m…
authored
252 @new_post.stub!(:column_for_attribute).with(:body).and_return(mock('column', :type => :text))
253 @new_post.stub!(:column_for_attribute).with(:published).and_return(mock('column', :type => :boolean))
b326984 @justinfrench trying to move as much set up as possible into mock_everything
authored
254 @new_post.stub!(:column_for_attribute).with(:publish_at).and_return(mock('column', :type => :date))
255 @new_post.stub!(:column_for_attribute).with(:time_zone).and_return(mock('column', :type => :string))
256 @new_post.stub!(:column_for_attribute).with(:allow_comments).and_return(mock('column', :type => :boolean))
1bd9545 @justinfrench belongs_to associations will now render errors attached to the associ…
authored
257 @new_post.stub!(:column_for_attribute).with(:author).and_return(mock('column', :type => :integer))
3ae6b20 @justinfrench An input without an :as option will only route to country_input if th…
authored
258 @new_post.stub!(:column_for_attribute).with(:country).and_return(mock('column', :type => :string, :limit => 255))
259 @new_post.stub!(:column_for_attribute).with(:country_subdivision).and_return(mock('column', :type => :string, :limit => 255))
260 @new_post.stub!(:column_for_attribute).with(:country_code).and_return(mock('column', :type => :string, :limit => 255))
e0a7874 @asanghi Added auto-guessing and updated some docs
asanghi authored
261 @new_post.stub!(:column_for_attribute).with(:email).and_return(mock('column', :type => :string, :limit => 255))
262 @new_post.stub!(:column_for_attribute).with(:url).and_return(mock('column', :type => :string, :limit => 255))
263 @new_post.stub!(:column_for_attribute).with(:phone).and_return(mock('column', :type => :string, :limit => 255))
264 @new_post.stub!(:column_for_attribute).with(:search).and_return(mock('column', :type => :string, :limit => 255))
433dae2 @yabawock Whitespace Cleanup
yabawock authored
265
b326984 @justinfrench trying to move as much set up as possible into mock_everything
authored
266 @new_post.stub!(:author).and_return(@bob)
267 @new_post.stub!(:author_id).and_return(@bob.id)
9c1daba Added regression spec for a belongs_to association with :group_by => …
Jacob Kjeldahl authored
268
2814011 @yabawock Merge branch 'master' into rails3
yabawock authored
269 @new_post.stub!(:reviewer).and_return(@fred)
270 @new_post.stub!(:reviewer_id).and_return(@fred.id)
a745de3 @gpetrica test case
gpetrica authored
271
c453c36 @grimen Failing spec and a "for some reason a non-working solution" for issue…
grimen authored
272 @new_post.should_receive(:publish_at=).any_number_of_times
273 @new_post.should_receive(:title=).any_number_of_times
9c1daba Added regression spec for a belongs_to association with :group_by => …
Jacob Kjeldahl authored
274 @new_post.stub!(:main_post_id).and_return(nil)
433dae2 @yabawock Whitespace Cleanup
yabawock authored
275
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
276 end
433dae2 @yabawock Whitespace Cleanup
yabawock authored
277
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
278 def self.included(base)
279 base.class_eval do
433dae2 @yabawock Whitespace Cleanup
yabawock authored
280
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
281 attr_accessor :output_buffer
433dae2 @yabawock Whitespace Cleanup
yabawock authored
282
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
283 def protect_against_forgery?
284 false
285 end
433dae2 @yabawock Whitespace Cleanup
yabawock authored
286
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
287 end
288 end
433dae2 @yabawock Whitespace Cleanup
yabawock authored
289
ffa9e37 @justinfrench Added a with_config method for specs.
authored
290 def with_config(config_method_name, value, &block)
291 old_value = ::Formtastic::SemanticFormBuilder.send(config_method_name)
292 ::Formtastic::SemanticFormBuilder.send(:"#{config_method_name}=", value)
293 yield
294 ::Formtastic::SemanticFormBuilder.send(:"#{config_method_name}=", old_value)
295 end
433dae2 @yabawock Whitespace Cleanup
yabawock authored
296
b07e2d1 @justinfrench added helper method for testing deprecation warnings in a silenced block
authored
297 def with_deprecation_silenced(&block)
298 ::ActiveSupport::Deprecation.silenced = true
299 yield
300 ::ActiveSupport::Deprecation.silenced = false
301 end
433dae2 @yabawock Whitespace Cleanup
yabawock authored
302
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
303 end
304
39a5079 @justinfrench ensure that deprecation errors are always shown in specs... if you wa…
authored
305 ::ActiveSupport::Deprecation.silenced = false
Something went wrong with that request. Please try again.