lperichon-formtastic 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format=progress
@@ -0,0 +1,159 @@
1
+ # coding: utf-8
2
+ require 'rubygems'
3
+
4
+ def smart_require(lib_name, gem_name, gem_version = '>= 0.0.0')
5
+ begin
6
+ require lib_name if lib_name
7
+ rescue LoadError
8
+ if gem_name
9
+ gem gem_name, gem_version
10
+ require lib_name if lib_name
11
+ end
12
+ end
13
+ end
14
+
15
+ smart_require 'spec', 'spec', '>= 1.2.6'
16
+ smart_require false, 'rspec-rails', '>= 1.2.6'
17
+ smart_require 'hpricot', 'hpricot', '>= 0.6.1'
18
+ smart_require 'rspec_hpricot_matchers', 'rspec_hpricot_matchers', '>= 1.0.0'
19
+ smart_require 'active_support', 'activesupport', '>= 2.3.4'
20
+ smart_require 'action_controller', 'actionpack', '>= 2.3.4'
21
+ smart_require 'action_view', 'actionpack', '>= 2.3.4'
22
+
23
+ Spec::Runner.configure do |config|
24
+ config.include(RspecHpricotMatchers)
25
+ end
26
+
27
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
28
+
29
+ require 'formtastic'
30
+
31
+ module FormtasticSpecHelper
32
+ include ActionView::Helpers::FormHelper
33
+ include ActionView::Helpers::FormTagHelper
34
+ include ActionView::Helpers::FormOptionsHelper
35
+ include ActionView::Helpers::UrlHelper
36
+ include ActionView::Helpers::TagHelper
37
+ include ActionView::Helpers::TextHelper
38
+ include ActionView::Helpers::ActiveRecordHelper
39
+ include ActionView::Helpers::RecordIdentificationHelper
40
+ include ActionView::Helpers::DateHelper
41
+ include ActionView::Helpers::CaptureHelper
42
+ include ActiveSupport
43
+ include ActionController::PolymorphicRoutes
44
+
45
+ include Formtastic::SemanticFormHelper
46
+
47
+ def default_input_type(column_type, column_name = :generic_column_name)
48
+ @new_post.stub!(column_name)
49
+ @new_post.stub!(:column_for_attribute).and_return(mock('column', :type => column_type)) unless column_type.nil?
50
+
51
+ semantic_form_for(@new_post) do |builder|
52
+ @default_type = builder.send(:default_input_type, column_name)
53
+ end
54
+
55
+ return @default_type
56
+ end
57
+
58
+ class ::Post
59
+ def id
60
+ end
61
+ end
62
+ class ::Author
63
+ end
64
+
65
+ def mock_everything
66
+
67
+ # Resource-oriented styles like form_for(@post) will expect a path method for the object,
68
+ # so we're defining some here.
69
+ def post_path(o); "/posts/1"; end
70
+ def posts_path; "/posts"; end
71
+ def new_post_path; "/posts/new"; end
72
+
73
+ def author_path(o); "/authors/1"; end
74
+ def authors_path; "/authors"; end
75
+ def new_author_path; "/authors/new"; end
76
+
77
+ @fred = mock('user')
78
+ @fred.stub!(:class).and_return(::Author)
79
+ @fred.stub!(:to_label).and_return('Fred Smith')
80
+ @fred.stub!(:login).and_return('fred_smith')
81
+ @fred.stub!(:id).and_return(37)
82
+ @fred.stub!(:new_record?).and_return(false)
83
+ @fred.stub!(:errors).and_return(mock('errors', :[] => nil))
84
+
85
+ @bob = mock('user')
86
+ @bob.stub!(:class).and_return(::Author)
87
+ @bob.stub!(:to_label).and_return('Bob Rock')
88
+ @bob.stub!(:login).and_return('bob')
89
+ @bob.stub!(:id).and_return(42)
90
+ @bob.stub!(:posts).and_return([])
91
+ @bob.stub!(:post_ids).and_return([])
92
+ @bob.stub!(:new_record?).and_return(false)
93
+ @bob.stub!(:errors).and_return(mock('errors', :[] => nil))
94
+
95
+ ::Author.stub!(:find).and_return([@fred, @bob])
96
+ ::Author.stub!(:human_attribute_name).and_return { |column_name| column_name.humanize }
97
+ ::Author.stub!(:human_name).and_return('::Author')
98
+ ::Author.stub!(:reflect_on_validations_for).and_return([])
99
+ ::Author.stub!(:reflect_on_association).and_return { |column_name| mock('reflection', :options => {}, :klass => Post, :macro => :has_many) if column_name == :posts }
100
+
101
+ # Sometimes we need a mock @post object and some Authors for belongs_to
102
+ @new_post = mock('post')
103
+ @new_post.stub!(:class).and_return(::Post)
104
+ @new_post.stub!(:id).and_return(nil)
105
+ @new_post.stub!(:new_record?).and_return(true)
106
+ @new_post.stub!(:errors).and_return(mock('errors', :[] => nil))
107
+ @new_post.stub!(:author).and_return(nil)
108
+
109
+ @freds_post = mock('post')
110
+ @freds_post.stub!(:class).and_return(::Post)
111
+ @freds_post.stub!(:to_label).and_return('Fred Smith')
112
+ @freds_post.stub!(:id).and_return(19)
113
+ @freds_post.stub!(:author).and_return(@fred)
114
+ @freds_post.stub!(:author_id).and_return(@fred.id)
115
+ @freds_post.stub!(:authors).and_return([@fred])
116
+ @freds_post.stub!(:author_ids).and_return([@fred.id])
117
+ @freds_post.stub!(:new_record?).and_return(false)
118
+ @freds_post.stub!(:errors).and_return(mock('errors', :[] => nil))
119
+ @fred.stub!(:posts).and_return([@freds_post])
120
+ @fred.stub!(:post_ids).and_return([@freds_post.id])
121
+
122
+ ::Post.stub!(:human_attribute_name).and_return { |column_name| column_name.humanize }
123
+ ::Post.stub!(:human_name).and_return('Post')
124
+ ::Post.stub!(:reflect_on_all_validations).and_return([])
125
+ ::Post.stub!(:reflect_on_validations_for).and_return([])
126
+ ::Post.stub!(:reflect_on_association).and_return do |column_name|
127
+ case column_name
128
+ when :author, :author_status
129
+ mock('reflection', :options => {}, :klass => ::Author, :macro => :belongs_to)
130
+ when :authors
131
+ mock('reflection', :options => {}, :klass => ::Author, :macro => :has_and_belongs_to_many)
132
+ end
133
+ end
134
+ ::Post.stub!(:find).and_return([@freds_post])
135
+
136
+ @new_post.stub!(:title)
137
+ @new_post.stub!(:body)
138
+ @new_post.stub!(:published)
139
+ @new_post.stub!(:column_for_attribute).with(:meta_description).and_return(mock('column', :type => :string, :limit => 255))
140
+ @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :string, :limit => 255))
141
+ @new_post.stub!(:column_for_attribute).with(:body).and_return(mock('column', :type => :text))
142
+ @new_post.stub!(:column_for_attribute).with(:published).and_return(mock('column', :type => :boolean))
143
+ end
144
+
145
+ def self.included(base)
146
+ base.class_eval do
147
+
148
+ attr_accessor :output_buffer
149
+
150
+ def protect_against_forgery?
151
+ false
152
+ end
153
+
154
+ end
155
+ end
156
+
157
+ end
158
+
159
+ ::ActiveSupport::Deprecation.silenced = true
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lperichon-formtastic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.2
5
+ platform: ruby
6
+ authors:
7
+ - Justin French / Luis Perichon
8
+ autorequire: formtastic
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-14 00:00:00 -03:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: A Rails form builder plugin/gem with semantically rich and accessible markup
17
+ email: info@luisperichon.com.ar
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.textile
24
+ files:
25
+ - MIT-LICENSE
26
+ - README.textile
27
+ - Rakefile
28
+ - generators/form/USAGE
29
+ - generators/form/form_generator.rb
30
+ - generators/form/templates/view__form.html.erb
31
+ - generators/form/templates/view__form.html.haml
32
+ - generators/formtastic/formtastic_generator.rb
33
+ - generators/formtastic/templates/formtastic.css
34
+ - generators/formtastic/templates/formtastic.rb
35
+ - generators/formtastic/templates/formtastic_changes.css
36
+ - generators/formtastic_stylesheets/formtastic_stylesheets_generator.rb
37
+ - lib/formtastic.rb
38
+ - lib/locale/en.yml
39
+ - rails/init.rb
40
+ - spec/buttons_spec.rb
41
+ - spec/commit_button_spec.rb
42
+ - spec/custom_builder_spec.rb
43
+ - spec/error_proc_spec.rb
44
+ - spec/errors_spec.rb
45
+ - spec/form_helper_spec.rb
46
+ - spec/include_blank_spec.rb
47
+ - spec/input_spec.rb
48
+ - spec/inputs_spec.rb
49
+ - spec/label_spec.rb
50
+ - spec/semantic_fields_for_spec.rb
51
+ - spec/spec.opts
52
+ - spec/test_helper.rb
53
+ has_rdoc: true
54
+ homepage: http://github.com/lperichon/formtastic
55
+ licenses: []
56
+
57
+ post_install_message: "\n ========================================================================\n\n Thanks for installing Formtastic!\n \n You can now (optionally) run the generater to copy some stylesheets and\n a config initializer into your application:\n \n ./script/generate formtastic\n \n The following files will be added:\n \n RAILS_ROOT/public/stylesheets/formtastic.css\n RAILS_ROOT/public/stylesheets/formtastic_changes.css\n RAILS_ROOT/config/initializers/formtastic.rb\n \n Find out more and get involved:\n\n http://github.com/justinfrench/formtastic\n http://groups.google.com.au/group/formtastic\n \n ========================================================================\n "
58
+ rdoc_options:
59
+ - --charset=UTF-8
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ requirements: []
75
+
76
+ rubyforge_project:
77
+ rubygems_version: 1.3.5
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: A Rails form builder plugin/gem with semantically rich and accessible markup
81
+ test_files:
82
+ - spec/test_helper.rb
83
+ - spec/form_helper_spec.rb
84
+ - spec/include_blank_spec.rb
85
+ - spec/inputs_spec.rb
86
+ - spec/errors_spec.rb
87
+ - spec/error_proc_spec.rb
88
+ - spec/buttons_spec.rb
89
+ - spec/custom_builder_spec.rb
90
+ - spec/commit_button_spec.rb
91
+ - spec/label_spec.rb
92
+ - spec/input_spec.rb
93
+ - spec/semantic_fields_for_spec.rb