Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 457 lines (386 sloc) 17.383 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'
152f04e @sobrinho Use `require 'bundler/setup'` instead of calling Bundler.setup manually
sobrinho authored
3 require 'bundler/setup'
9604949 @justinfrench smart_require is tripping up the CI build, and also tripped me up a f…
authored
4 require 'active_support'
5 require 'action_pack'
6 require 'action_view'
7 require 'action_controller'
f7d9cfd @justinfrench A bunch of Rails 3.1 compatability stuff for #564
authored
8 require 'action_dispatch'
542d308 @grimen Fixing some issues with the specs to get them to run on Ruby 1.9.x. S…
grimen authored
9
fe63045 @yabawock Use HTML safe strings in tests
yabawock authored
10 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
11 require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic'))
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
12
392cdfa @alexrothenberg added generator specs using ammeter gem
alexrothenberg authored
13 require 'ammeter/init'
14
b86266e @yabawock Separate test environment setup and misc setup blocks into spec/suppo…
yabawock authored
15 # Requires supporting files with custom matchers and macros, etc,
2c68cd3 @huerlisi Sort list of files to require in spec helper.
huerlisi authored
16 # in ./support/ and its subdirectories in alphabetic order.
17 Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each {|f| require f}
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
18
f7d9cfd @justinfrench A bunch of Rails 3.1 compatability stuff for #564
authored
19 module FakeHelpersModule
20 end
21
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
22 module FormtasticSpecHelper
82f6c8d @justinfrench Fixes deprecation warnings with form_for(:name, @resource) in rails3 …
authored
23 include ActionPack
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
24 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
25 include ActionController::RecordIdentifier
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
26 include ActionView::Helpers::FormHelper
27 include ActionView::Helpers::FormTagHelper
28 include ActionView::Helpers::FormOptionsHelper
29 include ActionView::Helpers::UrlHelper
30 include ActionView::Helpers::TagHelper
31 include ActionView::Helpers::TextHelper
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
32 include ActionView::Helpers::ActiveRecordHelper if defined?(ActionView::Helpers::ActiveRecordHelper)
33 include ActionView::Helpers::ActiveModelHelper if defined?(ActionView::Helpers::ActiveModelHelper)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
34 include ActionView::Helpers::DateHelper
35 include ActionView::Helpers::CaptureHelper
127a6b9 @justinfrench Added a Formtastic::LayoutHelper with formtastic_stylesheets so that …
authored
36 include ActionView::Helpers::AssetTagHelper
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
37 include ActiveSupport
229eb53 @yabawock Make testsuite work with Rails 3.0.0.rc and RSpec 2.0.0.beta19
yabawock authored
38 include ActionController::PolymorphicRoutes if defined?(ActionController::PolymorphicRoutes)
433dae2 @yabawock Whitespace Cleanup
yabawock authored
39
549ef7a @justinfrench Renamed all instances of Formtastic::SemanticFormBuilder to Formtasti…
authored
40 include Formtastic::Helpers::FormHelper
433dae2 @yabawock Whitespace Cleanup
yabawock authored
41
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
42 def default_input_type(column_type, column_name = :generic_column_name)
43 @new_post.stub!(column_name)
44 @new_post.stub!(:column_for_attribute).and_return(mock('column', :type => column_type)) unless column_type.nil?
45
46 semantic_form_for(@new_post) do |builder|
47 @default_type = builder.send(:default_input_type, column_name)
48 end
49
50 return @default_type
51 end
433dae2 @yabawock Whitespace Cleanup
yabawock authored
52
98ceff5 @koppen Automatically set maxlength if object is an ActiveModel and the field…
koppen authored
53 def active_model_validator(kind, attributes, options = {})
54 validator = mock("ActiveModel::Validations::#{kind.to_s.titlecase}Validator", :attributes => attributes, :options => options)
55 validator.stub!(:kind).and_return(kind)
56 validator
57 end
58
2769784 @tetsuo692 add active_model_presence_validator helper and clean up test
tetsuo692 authored
59 def active_model_presence_validator(attributes, options = {})
98ceff5 @koppen Automatically set maxlength if object is an ActiveModel and the field…
koppen authored
60 active_model_validator(:presence, attributes, options)
2769784 @tetsuo692 add active_model_presence_validator helper and clean up test
tetsuo692 authored
61 end
98ceff5 @koppen Automatically set maxlength if object is an ActiveModel and the field…
koppen authored
62
63 def active_model_length_validator(attributes, options = {})
64 active_model_validator(:length, attributes, options)
65 end
66
e38a068 @sobrinho Spec for last commit
sobrinho authored
67 def active_model_inclusion_validator(attributes, options = {})
68 active_model_validator(:inclusion, attributes, options)
d6e6265 @justinfrench NumericInput now provides default min, max and step attributes by ref…
authored
69 end
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
70
d6e6265 @justinfrench NumericInput now provides default min, max and step attributes by ref…
authored
71 def active_model_numericality_validator(attributes, options = {})
72 active_model_validator(:numericality, attributes, options)
e38a068 @sobrinho Spec for last commit
sobrinho authored
73 end
74
c6c6d2b @ijonas specs for support of polymorphic association checking on top of Mongo…
ijonas authored
75 class ::MongoPost
76 include MongoMapper::Document if defined?(MongoMapper::Document)
77
78 def id
79 end
80
81 def persisted?
82 end
83 end
84
85
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
86 class ::Post
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
87 extend ActiveModel::Naming if defined?(ActiveModel::Naming)
88 include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
89
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
90 def id
91 end
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
92
93 def persisted?
94 end
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
95 end
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
96
d33fad4 @akaspick Fix incorrect html class name being generated for namespaced objects.
akaspick authored
97 module ::Namespaced
98 class Post
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
99 extend ActiveModel::Naming if defined?(ActiveModel::Naming)
100 include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
101
d33fad4 @akaspick Fix incorrect html class name being generated for namespaced objects.
akaspick authored
102 def id
103 end
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
104
105 def persisted?
106 end
d33fad4 @akaspick Fix incorrect html class name being generated for namespaced objects.
akaspick authored
107 end
108 end
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
109
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
110 class ::Author
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
111 extend ActiveModel::Naming if defined?(ActiveModel::Naming)
112 include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
113
33a5d23 Added :group_by option to select input (issue #54)
Jeroen van Dijk authored
114 def to_label
115 end
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
116
f7d9cfd @justinfrench A bunch of Rails 3.1 compatability stuff for #564
authored
117 def persisted?
118 end
33a5d23 Added :group_by option to select input (issue #54)
Jeroen van Dijk authored
119 end
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
120
131f350 @justinfrench Fix bug when simple_fields_for is used with a hask like model
authored
121 class ::HashBackedAuthor < Hash
122 extend ActiveModel::Naming if defined?(ActiveModel::Naming)
123 include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
124 def persisted?; false; end
125 def name
126 'hash backed author'
127 end
128 end
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
129
33a5d23 Added :group_by option to select input (issue #54)
Jeroen van Dijk authored
130 class ::Continent
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
131 extend ActiveModel::Naming if defined?(ActiveModel::Naming)
132 include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
133 end
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
134
506182b @yabawock Make ActiveModel Tests work without relying on RSpec unstub!
yabawock authored
135 class ::PostModel
136 extend ActiveModel::Naming if defined?(ActiveModel::Naming)
137 include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
138 end
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
139
a09a6db @rgarner Fix for #740 - Mongoid belongs_to select raises NoMethodError and alw…
rgarner authored
140 ##
141 # We can't mock :respond_to?, so we need a concrete class override
142 class ::MongoidReflectionMock < RSpec::Mocks::Mock
143 def initialize(name=nil, stubs_and_options={})
144 super name, stubs_and_options
145 end
146
147 def respond_to?(sym)
148 sym == :options ? false : super
149 end
150 end
151
f7d9cfd @justinfrench A bunch of Rails 3.1 compatability stuff for #564
authored
152 def _routes
153 url_helpers = mock('url_helpers')
154 url_helpers.stub!(:hash_for_posts_path).and_return({})
155 url_helpers.stub!(:hash_for_post_path).and_return({})
156 url_helpers.stub!(:hash_for_post_models_path).and_return({})
157 url_helpers.stub!(:hash_for_authors_path).and_return({})
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
158
159 mock('_routes',
f7d9cfd @justinfrench A bunch of Rails 3.1 compatability stuff for #564
authored
160 :url_helpers => url_helpers,
161 :url_for => "/mock/path"
162 )
163 end
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
164
f7d9cfd @justinfrench A bunch of Rails 3.1 compatability stuff for #564
authored
165 def controller
7723de7 @justinfrench Introducing actions for submit, cancel and reset buttons
authored
166 env = mock('env', :[] => nil)
167 request = mock('request', :env => env)
168 mock('controller', :controller_path= => '', :params => {}, :request => request)
f7d9cfd @justinfrench A bunch of Rails 3.1 compatability stuff for #564
authored
169 end
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
170
f7d9cfd @justinfrench A bunch of Rails 3.1 compatability stuff for #564
authored
171 def default_url_options
172 {}
173 end
433dae2 @yabawock Whitespace Cleanup
yabawock authored
174
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
175 def mock_everything
433dae2 @yabawock Whitespace Cleanup
yabawock authored
176
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
177 # Resource-oriented styles like form_for(@post) will expect a path method for the object,
178 # so we're defining some here.
8b8e86c @justinfrench fix epic failing tests under Rails 3.1.0.rc5 due to our fake URL help…
authored
179 def post_models_path(*args); "/postmodels/1"; end
506182b @yabawock Make ActiveModel Tests work without relying on RSpec unstub!
yabawock authored
180
8b8e86c @justinfrench fix epic failing tests under Rails 3.1.0.rc5 due to our fake URL help…
authored
181 def post_path(*args); "/posts/1"; end
182 def posts_path(*args); "/posts"; end
183 def new_post_path(*args); "/posts/new"; end
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
184
8b8e86c @justinfrench fix epic failing tests under Rails 3.1.0.rc5 due to our fake URL help…
authored
185 def author_path(*args); "/authors/1"; end
186 def authors_path(*args); "/authors"; end
187 def new_author_path(*args); "/authors/new"; end
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
188
4fcd1e8 @lardawge Use real object to get specs passing in ruby 192
lardawge authored
189 @fred = ::Author.new
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
190 @fred.stub!(:class).and_return(::Author)
191 @fred.stub!(:to_label).and_return('Fred Smith')
192 @fred.stub!(:login).and_return('fred_smith')
5733f7b @farnoy Tests for RangeInput and minor code refactoring. New column for Author
farnoy authored
193 @fred.stub!(:age).and_return(27)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
194 @fred.stub!(:id).and_return(37)
195 @fred.stub!(:new_record?).and_return(false)
196 @fred.stub!(:errors).and_return(mock('errors', :[] => nil))
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
197 @fred.stub!(:to_key).and_return(nil)
198 @fred.stub!(:persisted?).and_return(nil)
f7d9cfd @justinfrench A bunch of Rails 3.1 compatability stuff for #564
authored
199 @fred.stub!(:name).and_return('Fred')
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
200
4fcd1e8 @lardawge Use real object to get specs passing in ruby 192
lardawge authored
201 @bob = ::Author.new
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
202 @bob.stub!(:to_label).and_return('Bob Rock')
203 @bob.stub!(:login).and_return('bob')
5733f7b @farnoy Tests for RangeInput and minor code refactoring. New column for Author
farnoy authored
204 @bob.stub!(:age).and_return(43)
b326984 @justinfrench trying to move as much set up as possible into mock_everything
authored
205 @bob.stub!(:created_at)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
206 @bob.stub!(:id).and_return(42)
207 @bob.stub!(:posts).and_return([])
208 @bob.stub!(:post_ids).and_return([])
209 @bob.stub!(:new_record?).and_return(false)
210 @bob.stub!(:errors).and_return(mock('errors', :[] => nil))
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
211 @bob.stub!(:to_key).and_return(nil)
212 @bob.stub!(:persisted?).and_return(nil)
f7d9cfd @justinfrench A bunch of Rails 3.1 compatability stuff for #564
authored
213 @bob.stub!(:name).and_return('Bob')
433dae2 @yabawock Whitespace Cleanup
yabawock authored
214
4fcd1e8 @lardawge Use real object to get specs passing in ruby 192
lardawge authored
215 @james = ::Author.new
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
216 @james.stub!(:to_label).and_return('James Shock')
217 @james.stub!(:login).and_return('james')
5733f7b @farnoy Tests for RangeInput and minor code refactoring. New column for Author
farnoy authored
218 @james.stub!(:age).and_return(38)
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
219 @james.stub!(:id).and_return(75)
220 @james.stub!(:posts).and_return([])
221 @james.stub!(:post_ids).and_return([])
222 @james.stub!(:new_record?).and_return(false)
223 @james.stub!(:errors).and_return(mock('errors', :[] => nil))
224 @james.stub!(:to_key).and_return(nil)
225 @james.stub!(:persisted?).and_return(nil)
f7d9cfd @justinfrench A bunch of Rails 3.1 compatability stuff for #564
authored
226 @james.stub!(:name).and_return('James')
433dae2 @yabawock Whitespace Cleanup
yabawock authored
227
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
228
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
229 ::Author.stub!(:scoped).and_return(::Author)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
230 ::Author.stub!(:find).and_return([@fred, @bob])
2f27975 @yabawock Fix testsuite to match use of :all.
yabawock authored
231 ::Author.stub!(:all).and_return([@fred, @bob])
4134c12 @justinfrench fix a bunch of issues and failing select input specs around #where vs…
authored
232 ::Author.stub!(:where).and_return([@fred, @bob])
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
233 ::Author.stub!(:human_attribute_name).and_return { |column_name| column_name.humanize }
234 ::Author.stub!(:human_name).and_return('::Author')
235 ::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
236 ::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
237 ::Author.stub!(:to_key).and_return(nil)
238 ::Author.stub!(:persisted?).and_return(nil)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
239
131f350 @justinfrench Fix bug when simple_fields_for is used with a hask like model
authored
240 @hash_backed_author = HashBackedAuthor.new
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
241
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
242 # Sometimes we need a mock @post object and some Authors for belongs_to
243 @new_post = mock('post')
244 @new_post.stub!(:class).and_return(::Post)
245 @new_post.stub!(:id).and_return(nil)
246 @new_post.stub!(:new_record?).and_return(true)
247 @new_post.stub!(:errors).and_return(mock('errors', :[] => nil))
248 @new_post.stub!(:author).and_return(nil)
f7d9cfd @justinfrench A bunch of Rails 3.1 compatability stuff for #564
authored
249 @new_post.stub!(:author_attributes=).and_return(nil)
250 @new_post.stub!(:authors).and_return([@fred])
251 @new_post.stub!(:authors_attributes=)
2814011 @yabawock Merge branch 'master' into rails3
yabawock authored
252 @new_post.stub!(:reviewer).and_return(nil)
9c1daba Added regression spec for a belongs_to association with :group_by => …
Jacob Kjeldahl authored
253 @new_post.stub!(:main_post).and_return(nil)
254 @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
255 @new_post.stub!(:to_key).and_return(nil)
256 @new_post.stub!(:to_model).and_return(@new_post)
257 @new_post.stub!(:persisted?).and_return(nil)
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
258
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
259 @freds_post = mock('post')
4fcd1e8 @lardawge Use real object to get specs passing in ruby 192
lardawge authored
260 @freds_post.stub!(:to_ary)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
261 @freds_post.stub!(:class).and_return(::Post)
262 @freds_post.stub!(:to_label).and_return('Fred Smith')
263 @freds_post.stub!(:id).and_return(19)
03ef4a1 @justinfrench Spec coverage to confirm that a work-around exists for GH-398.
authored
264 @freds_post.stub!(:title).and_return("Hello World")
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
265 @freds_post.stub!(:author).and_return(@fred)
266 @freds_post.stub!(:author_id).and_return(@fred.id)
267 @freds_post.stub!(:authors).and_return([@fred])
268 @freds_post.stub!(:author_ids).and_return([@fred.id])
269 @freds_post.stub!(:new_record?).and_return(false)
270 @freds_post.stub!(:errors).and_return(mock('errors', :[] => nil))
b88bd5b @yabawock Changed spec_helper to allow for Rails 3 / Rspec 2 environment
yabawock authored
271 @freds_post.stub!(:to_key).and_return(nil)
272 @freds_post.stub!(:persisted?).and_return(nil)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
273 @fred.stub!(:posts).and_return([@freds_post])
274 @fred.stub!(:post_ids).and_return([@freds_post.id])
275
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
276 ::Post.stub!(:scoped).and_return(::Post)
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
277 ::Post.stub!(:human_attribute_name).and_return { |column_name| column_name.humanize }
278 ::Post.stub!(:human_name).and_return('Post')
279 ::Post.stub!(:reflect_on_all_validations).and_return([])
506182b @yabawock Make ActiveModel Tests work without relying on RSpec unstub!
yabawock authored
280 ::Post.stub!(:reflect_on_validations_for).and_return([])
1bd9545 @justinfrench belongs_to associations will now render errors attached to the associ…
authored
281 ::Post.stub!(:reflections).and_return({})
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
282 ::Post.stub!(:reflect_on_association).and_return do |column_name|
283 case column_name
284 when :author, :author_status
33a5d23 Added :group_by option to select input (issue #54)
Jeroen van Dijk authored
285 mock = mock('reflection', :options => {}, :klass => ::Author, :macro => :belongs_to)
286 mock.stub!(:[]).with(:class_name).and_return("Author")
287 mock
2814011 @yabawock Merge branch 'master' into rails3
yabawock authored
288 when :reviewer
289 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
290 mock.stub!(:[]).with(:class_name).and_return("Author")
291 mock
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
292 when :authors
293 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
294 when :sub_posts
295 mock('reflection', :options => {}, :klass => ::Post, :macro => :has_many)
296 when :main_post
297 mock('reflection', :options => {}, :klass => ::Post, :macro => :belongs_to)
fb643c7 spec for mongoid references fix
smix authored
298 when :mongoid_reviewer
a09a6db @rgarner Fix for #740 - Mongoid belongs_to select raises NoMethodError and alw…
rgarner authored
299 ::MongoidReflectionMock.new('reflection',
300 :options => Proc.new { raise NoMethodError, "Mongoid has no reflection.options" },
301 :klass => ::Author, :macro => :referenced_in, :foreign_key => "reviewer_id") # custom id
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
302 end
303 end
304 ::Post.stub!(:find).and_return([@freds_post])
2f27975 @yabawock Fix testsuite to match use of :all.
yabawock authored
305 ::Post.stub!(:all).and_return([@freds_post])
4134c12 @justinfrench fix a bunch of issues and failing select input specs around #where vs…
authored
306 ::Post.stub!(:where).and_return([@freds_post])
17f6668 @justinfrench Revert "This reverts commit 440bd2d8da117acdbca57fa199c115caefcd87c0."
authored
307 ::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
308 ::Post.stub!(:to_key).and_return(nil)
309 ::Post.stub!(:persisted?).and_return(nil)
4fcd1e8 @lardawge Use real object to get specs passing in ruby 192
lardawge authored
310 ::Post.stub!(:to_ary)
433dae2 @yabawock Whitespace Cleanup
yabawock authored
311
c6c6d2b @ijonas specs for support of polymorphic association checking on top of Mongo…
ijonas authored
312 ::MongoPost.stub!(:human_attribute_name).and_return { |column_name| column_name.humanize }
313 ::MongoPost.stub!(:human_name).and_return('MongoPost')
6034e77 @hypomodern this should fix the remaining problems.
hypomodern authored
314 ::MongoPost.stub!(:associations).and_return({
315 :sub_posts => mock('reflection', :options => {:polymorphic => true}, :klass => ::MongoPost, :macro => :has_many),
316 :options => []
317 })
c6c6d2b @ijonas specs for support of polymorphic association checking on top of Mongo…
ijonas authored
318 ::MongoPost.stub!(:find).and_return([@freds_post])
319 ::MongoPost.stub!(:all).and_return([@freds_post])
320 ::MongoPost.stub!(:where).and_return([@freds_post])
321 ::MongoPost.stub!(:to_key).and_return(nil)
322 ::MongoPost.stub!(:persisted?).and_return(nil)
323 ::MongoPost.stub!(:to_ary)
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
324 ::MongoPost.stub!(:model_name).and_return( mock(:model_name_mock, :singular => "post", :plural => "posts", :param_key => "post", :route_key => "posts") )
c6c6d2b @ijonas specs for support of polymorphic association checking on top of Mongo…
ijonas authored
325
326 @new_mm_post = mock('mm_post')
327 @new_mm_post.stub!(:class).and_return(::MongoPost)
328 @new_mm_post.stub!(:id).and_return(nil)
329 @new_mm_post.stub!(:new_record?).and_return(true)
330 @new_mm_post.stub!(:errors).and_return(mock('errors', :[] => nil))
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
331 @new_mm_post.stub!(:title).and_return("Hello World")
c6c6d2b @ijonas specs for support of polymorphic association checking on top of Mongo…
ijonas authored
332 @new_mm_post.stub!(:sub_posts).and_return([]) #TODO should be a mock with methods for adding sub posts
333 @new_mm_post.stub!(:to_key).and_return(nil)
334 @new_mm_post.stub!(:to_model).and_return(@new_mm_post)
335 @new_mm_post.stub!(:persisted?).and_return(nil)
336
deb9f9b @asanghi automatic deduction of errors related to file type fields
asanghi authored
337 @mock_file = mock('file')
549ef7a @justinfrench Renamed all instances of Formtastic::SemanticFormBuilder to Formtasti…
authored
338 Formtastic::FormBuilder.file_methods.each do |method|
deb9f9b @asanghi automatic deduction of errors related to file type fields
asanghi authored
339 @mock_file.stub!(method).and_return(true)
340 end
341
7466c77 @justinfrench moved the #inputs and #input specs out to their own file, and moved m…
authored
342 @new_post.stub!(:title)
f8e4100 @asanghi string type html defaults for newer fields
asanghi authored
343 @new_post.stub!(:email)
344 @new_post.stub!(:url)
345 @new_post.stub!(:phone)
346 @new_post.stub!(:search)
4fcd1e8 @lardawge Use real object to get specs passing in ruby 192
lardawge authored
347 @new_post.stub!(:to_ary)
7466c77 @justinfrench moved the #inputs and #input specs out to their own file, and moved m…
authored
348 @new_post.stub!(:body)
349 @new_post.stub!(:published)
b326984 @justinfrench trying to move as much set up as possible into mock_everything
authored
350 @new_post.stub!(:publish_at)
17f6668 @justinfrench Revert "This reverts commit 440bd2d8da117acdbca57fa199c115caefcd87c0."
authored
351 @new_post.stub!(:created_at)
6edfbfb @twalpole verify value is taken from object
twalpole authored
352 @new_post.stub!(:secret).and_return(1)
e0a7874 @asanghi Added auto-guessing and updated some docs
asanghi authored
353 @new_post.stub!(:url)
354 @new_post.stub!(:email)
355 @new_post.stub!(:search)
356 @new_post.stub!(:phone)
b326984 @justinfrench trying to move as much set up as possible into mock_everything
authored
357 @new_post.stub!(:time_zone)
358 @new_post.stub!(:category_name)
77ae6ad @lardawge [Fix] Input boolean checked values do not reflect database values
lardawge authored
359 @new_post.stub!(:allow_comments).and_return(true)
8f75fc7 @lardawge input_html should be passed to checkbox_tag
lardawge authored
360 @new_post.stub!(:answer_comments)
3ae6b20 @justinfrench An input without an :as option will only route to country_input if th…
authored
361 @new_post.stub!(:country)
362 @new_post.stub!(:country_subdivision)
363 @new_post.stub!(:country_code)
deb9f9b @asanghi automatic deduction of errors related to file type fields
asanghi authored
364 @new_post.stub!(:document).and_return(@mock_file)
7466c77 @justinfrench moved the #inputs and #input specs out to their own file, and moved m…
authored
365 @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
366 @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
367 @new_post.stub!(:column_for_attribute).with(:body).and_return(mock('column', :type => :text))
368 @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
369 @new_post.stub!(:column_for_attribute).with(:publish_at).and_return(mock('column', :type => :date))
370 @new_post.stub!(:column_for_attribute).with(:time_zone).and_return(mock('column', :type => :string))
371 @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
372 @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
373 @new_post.stub!(:column_for_attribute).with(:country).and_return(mock('column', :type => :string, :limit => 255))
374 @new_post.stub!(:column_for_attribute).with(:country_subdivision).and_return(mock('column', :type => :string, :limit => 255))
375 @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
376 @new_post.stub!(:column_for_attribute).with(:email).and_return(mock('column', :type => :string, :limit => 255))
377 @new_post.stub!(:column_for_attribute).with(:url).and_return(mock('column', :type => :string, :limit => 255))
378 @new_post.stub!(:column_for_attribute).with(:phone).and_return(mock('column', :type => :string, :limit => 255))
379 @new_post.stub!(:column_for_attribute).with(:search).and_return(mock('column', :type => :string, :limit => 255))
deb9f9b @asanghi automatic deduction of errors related to file type fields
asanghi authored
380 @new_post.stub!(:column_for_attribute).with(:document).and_return(nil)
433dae2 @yabawock Whitespace Cleanup
yabawock authored
381
b326984 @justinfrench trying to move as much set up as possible into mock_everything
authored
382 @new_post.stub!(:author).and_return(@bob)
383 @new_post.stub!(:author_id).and_return(@bob.id)
9c1daba Added regression spec for a belongs_to association with :group_by => …
Jacob Kjeldahl authored
384
2814011 @yabawock Merge branch 'master' into rails3
yabawock authored
385 @new_post.stub!(:reviewer).and_return(@fred)
386 @new_post.stub!(:reviewer_id).and_return(@fred.id)
a745de3 @gpetrica test case
gpetrica authored
387
c453c36 @grimen Failing spec and a "for some reason a non-working solution" for issue…
grimen authored
388 @new_post.should_receive(:publish_at=).any_number_of_times
389 @new_post.should_receive(:title=).any_number_of_times
9c1daba Added regression spec for a belongs_to association with :group_by => …
Jacob Kjeldahl authored
390 @new_post.stub!(:main_post_id).and_return(nil)
433dae2 @yabawock Whitespace Cleanup
yabawock authored
391
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
392 end
433dae2 @yabawock Whitespace Cleanup
yabawock authored
393
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
394 def self.included(base)
395 base.class_eval do
433dae2 @yabawock Whitespace Cleanup
yabawock authored
396
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
397 attr_accessor :output_buffer
433dae2 @yabawock Whitespace Cleanup
yabawock authored
398
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
399 def protect_against_forgery?
400 false
401 end
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
402
f7d9cfd @justinfrench A bunch of Rails 3.1 compatability stuff for #564
authored
403 def _helpers
404 FakeHelpersModule
405 end
70986a2 @eneagoe collection_from_association now works with Proc conditions for the as…
eneagoe authored
406
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
407 end
408 end
433dae2 @yabawock Whitespace Cleanup
yabawock authored
409
ffa9e37 @justinfrench Added a with_config method for specs.
authored
410 def with_config(config_method_name, value, &block)
549ef7a @justinfrench Renamed all instances of Formtastic::SemanticFormBuilder to Formtasti…
authored
411 old_value = Formtastic::FormBuilder.send(config_method_name)
412 Formtastic::FormBuilder.send(:"#{config_method_name}=", value)
ffa9e37 @justinfrench Added a with_config method for specs.
authored
413 yield
549ef7a @justinfrench Renamed all instances of Formtastic::SemanticFormBuilder to Formtasti…
authored
414 Formtastic::FormBuilder.send(:"#{config_method_name}=", old_value)
ffa9e37 @justinfrench Added a with_config method for specs.
authored
415 end
f39d1bd @twalpole Revert "Revert "Merge pull request #820 from twalpole/rails4""
twalpole authored
416
417 class ToSMatcher
418 def initialize(str)
419 @str=str.to_s
420 end
421
422 def matches?(value)
423 value.to_s==@str
424 end
425
426 def failure_message_for_should
427 "Expected argument that converted to #{@str}"
428 end
429 end
430
431 def errors_matcher(method)
432 # In edge rails (Rails 4) tags store method_name as a string and index the errors object using a string
433 # therefore allow stubs to match on either string or symbol. The errors object calls to_sym on all index
434 # accesses so @object.errors[:abc] is equivalent to @object.errors["abc"]
435 if Rails::VERSION::MAJOR == 4
436 ToSMatcher.new(method)
437 else
438 method
439 end
440 end
9690e9b @justinfrench Start of The Big Spec Refactor:
authored
441 end
442
39a5079 @justinfrench ensure that deprecation errors are always shown in specs... if you wa…
authored
443 ::ActiveSupport::Deprecation.silenced = false
2787d87 @justinfrench Deferring garbage collection cuts the time to run the test suite down…
authored
444
a0d6092 @justinfrench Rspec => RSpec in spec_helper
authored
445 RSpec.configure do |config|
a6dad77 Cache I18n lookups in Formtastic::Localizer
Sascha Konietzke authored
446 config.before(:each) do
447 Formtastic::Localizer.cache.clear!
448 end
449
2787d87 @justinfrench Deferring garbage collection cuts the time to run the test suite down…
authored
450 config.before(:all) do
0baec94 @justinfrench check ENV['DEFER_GC'] isn't 'false' before doing the the DeferredGarb…
authored
451 DeferredGarbageCollection.start unless ENV["DEFER_GC"] == "false"
2787d87 @justinfrench Deferring garbage collection cuts the time to run the test suite down…
authored
452 end
453 config.after(:all) do
a6dad77 Cache I18n lookups in Formtastic::Localizer
Sascha Konietzke authored
454 DeferredGarbageCollection.reconsider unless ENV["DEFER_GC"] == "false"
2787d87 @justinfrench Deferring garbage collection cuts the time to run the test suite down…
authored
455 end
152f04e @sobrinho Use `require 'bundler/setup'` instead of calling Bundler.setup manually
sobrinho authored
456 end
Something went wrong with that request. Please try again.