foundation_rails_helper 2.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.rubocop.yml +3 -6
- data/.rubocop_todo.yml +6 -48
- data/.travis.yml +29 -11
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -0
- data/README.md +49 -50
- data/Rakefile +1 -0
- data/foundation_rails_helper.gemspec +31 -32
- data/lib/foundation_rails_helper.rb +2 -0
- data/lib/foundation_rails_helper/action_view_extension.rb +1 -0
- data/lib/foundation_rails_helper/configuration.rb +4 -1
- data/lib/foundation_rails_helper/flash_helper.rb +43 -16
- data/lib/foundation_rails_helper/form_builder.rb +61 -83
- data/lib/foundation_rails_helper/size_class_calculator.rb +32 -0
- data/lib/foundation_rails_helper/version.rb +2 -1
- data/lib/railtie.rb +1 -0
- data/spec/.rubocop.yml +3 -0
- data/spec/foundation_rails_helper/configuration_spec.rb +30 -3
- data/spec/foundation_rails_helper/flash_helper_spec.rb +37 -23
- data/spec/foundation_rails_helper/form_builder_spec.rb +464 -178
- data/spec/spec_helper.rb +1 -0
- data/spec/support/classes/author.rb +13 -0
- data/spec/support/classes/book.rb +13 -0
- data/spec/support/classes/genre.rb +13 -0
- data/spec/support/mock_rails.rb +64 -100
- metadata +39 -30
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'active_model'
|
3
|
+
|
4
|
+
class Author
|
5
|
+
extend ActiveModel::Naming if defined?(ActiveModel::Naming)
|
6
|
+
include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
|
7
|
+
|
8
|
+
def to_label
|
9
|
+
end
|
10
|
+
|
11
|
+
def persisted?
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'active_model'
|
3
|
+
|
4
|
+
class Book
|
5
|
+
extend ActiveModel::Naming if defined?(ActiveModel::Naming)
|
6
|
+
include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
|
7
|
+
|
8
|
+
def to_label
|
9
|
+
end
|
10
|
+
|
11
|
+
def persisted?
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'active_model'
|
3
|
+
|
4
|
+
class Genre
|
5
|
+
extend ActiveModel::Naming if defined?(ActiveModel::Naming)
|
6
|
+
include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
|
7
|
+
|
8
|
+
def to_label
|
9
|
+
end
|
10
|
+
|
11
|
+
def persisted?
|
12
|
+
end
|
13
|
+
end
|
data/spec/support/mock_rails.rb
CHANGED
@@ -1,34 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'bundler/setup'
|
2
|
-
require 'active_support'
|
3
|
-
require 'action_pack'
|
4
3
|
require 'action_view'
|
5
4
|
require 'action_controller'
|
6
|
-
require 'action_dispatch'
|
7
5
|
require 'active_model'
|
8
6
|
require 'active_support/core_ext'
|
9
7
|
|
10
8
|
# Thanks to Justin French for formtastic spec
|
11
9
|
module FoundationRailsSpecHelper
|
12
|
-
include ActionPack
|
13
|
-
include ActionView::Context if defined?(ActionView::Context)
|
14
|
-
include ActionView::RecordIdentifier
|
15
10
|
include ActionView::Helpers::FormHelper
|
16
|
-
include ActionView::Helpers::FormTagHelper
|
17
11
|
include ActionView::Helpers::FormOptionsHelper
|
18
|
-
include ActionView::Helpers::UrlHelper
|
19
|
-
include ActionView::Helpers::TagHelper
|
20
|
-
include ActionView::Helpers::TextHelper
|
21
|
-
include ActionView::Helpers::ActiveRecordHelper if defined?(ActionView::Helpers::ActiveRecordHelper)
|
22
|
-
include ActionView::Helpers::ActiveModelHelper if defined?(ActionView::Helpers::ActiveModelHelper)
|
23
12
|
include ActionView::Helpers::DateHelper
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
include
|
28
|
-
include
|
13
|
+
if defined?(ActionController::PolymorphicRoutes)
|
14
|
+
include ActionController::PolymorphicRoutes
|
15
|
+
end
|
16
|
+
include ActionDispatch::Routing::PolymorphicRoutes
|
17
|
+
include AbstractController::UrlFor if defined?(AbstractController::UrlFor)
|
18
|
+
# to use dom_class in Rails 4 tests
|
19
|
+
# in Rails 5, RecordIdentifier is already required by FormHelper module
|
20
|
+
include ActionView::RecordIdentifier
|
29
21
|
|
30
22
|
def active_model_validator(kind, attributes, options = {})
|
31
|
-
validator = mock(
|
23
|
+
validator = mock(
|
24
|
+
"ActiveModel::Validations::#{kind.to_s.titlecase}Validator",
|
25
|
+
attributes: attributes,
|
26
|
+
options: options
|
27
|
+
)
|
32
28
|
allow(validator).to receive(:kind).and_return(kind)
|
33
29
|
validator
|
34
30
|
end
|
@@ -49,112 +45,80 @@ module FoundationRailsSpecHelper
|
|
49
45
|
active_model_validator(:numericality, attributes, options)
|
50
46
|
end
|
51
47
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
def to_label
|
57
|
-
end
|
58
|
-
|
59
|
-
def persisted?
|
60
|
-
end
|
48
|
+
def mock_everything
|
49
|
+
mock_author
|
50
|
+
mock_books
|
51
|
+
mock_genres
|
61
52
|
end
|
62
53
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
def persisted?
|
71
|
-
end
|
54
|
+
# Resource-oriented styles like form_for(@post) will expect a path method
|
55
|
+
# for the object, so we're defining some here.
|
56
|
+
# the argument is required for Rails 4 tests
|
57
|
+
def authors_path(*_args)
|
58
|
+
'/authors'
|
72
59
|
end
|
73
60
|
|
74
|
-
|
75
|
-
|
76
|
-
|
61
|
+
def _routes
|
62
|
+
double('_routes', polymorphic_mappings: {})
|
63
|
+
end
|
77
64
|
|
78
|
-
|
79
|
-
|
65
|
+
def self.included(base)
|
66
|
+
base.class_eval do
|
67
|
+
attr_accessor :output_buffer
|
80
68
|
|
81
|
-
|
69
|
+
def protect_against_forgery?
|
70
|
+
false
|
71
|
+
end
|
82
72
|
end
|
83
73
|
end
|
84
74
|
|
85
|
-
|
86
|
-
# Resource-oriented styles like form_for(@post) will expect a path method for the object,
|
87
|
-
# so we're defining some here.
|
88
|
-
def author_path(*_args)
|
89
|
-
'/authors/1'
|
90
|
-
end
|
91
|
-
|
92
|
-
def authors_path(*_args)
|
93
|
-
'/authors'
|
94
|
-
end
|
75
|
+
private
|
95
76
|
|
96
|
-
|
97
|
-
|
77
|
+
def mock_author
|
78
|
+
@author = ::Author.new
|
79
|
+
{ login: 'fred_smith', email: 'fred@foo.com', url: 'http://example.com',
|
80
|
+
some_number: '42', phone: '317 456 2564', active: true,
|
81
|
+
description: 'bla bla bla', birthdate: DateTime.parse('1969-06-18 20:30'),
|
82
|
+
forty_two: DateTime.parse('1969-06-18 20:30') + 42.years,
|
83
|
+
time_zone: 'Perth', publish_date: Date.new(2000, 1, 1),
|
84
|
+
favorite_color: '#424242', favorite_book: nil }.each do |m, v|
|
85
|
+
allow(@author).to receive(m).and_return(v)
|
98
86
|
end
|
87
|
+
end
|
99
88
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
allow(
|
104
|
-
|
105
|
-
allow(@author).to receive(:url).and_return('http://example.com')
|
106
|
-
allow(@author).to receive(:some_number).and_return('42')
|
107
|
-
allow(@author).to receive(:phone).and_return('317 456 2564')
|
108
|
-
allow(@author).to receive(:password).and_return('secret')
|
109
|
-
allow(@author).to receive(:active).and_return(true)
|
110
|
-
allow(@author).to receive(:description).and_return('bla bla bla')
|
111
|
-
allow(@author).to receive(:avatar).and_return('avatar.png')
|
112
|
-
allow(@author).to receive(:birthdate).and_return(DateTime.parse('1969-06-18 20:30'))
|
113
|
-
allow(@author).to receive(:id).and_return(37)
|
114
|
-
allow(@author).to receive(:new_record?).and_return(false)
|
115
|
-
allow(@author).to receive(:errors).and_return(double('errors', :[] => nil))
|
116
|
-
allow(@author).to receive(:to_key).and_return(nil)
|
117
|
-
allow(@author).to receive(:persisted?).and_return(nil)
|
118
|
-
allow(@author).to receive(:time_zone).and_return('Perth')
|
119
|
-
allow(@author).to receive(:publish_date).and_return(Date.new(2000, 1, 1))
|
120
|
-
allow(@author).to receive(:forty_two).and_return(@author.birthdate + 42.years)
|
121
|
-
allow(@author).to receive(:favorite_color).and_return('#424242')
|
122
|
-
allow(@author).to receive(:favorite_book).and_return(nil)
|
89
|
+
def mock_books
|
90
|
+
mock_book_0
|
91
|
+
mock_book_1
|
92
|
+
allow(::Book).to receive(:all).and_return([@book_0, @book_1])
|
93
|
+
end
|
123
94
|
|
95
|
+
def mock_book_0
|
124
96
|
@book_0 = ::Book.new
|
125
97
|
allow(@book_0).to receive(:id).and_return('78')
|
126
98
|
allow(@book_0).to receive(:title).and_return("Gulliver's Travels")
|
99
|
+
end
|
100
|
+
|
101
|
+
def mock_book_1
|
127
102
|
@book_1 = ::Book.new
|
128
103
|
allow(@book_1).to receive(:id).and_return('133')
|
129
104
|
allow(@book_1).to receive(:title).and_return('Treasure Island')
|
105
|
+
end
|
106
|
+
|
107
|
+
def mock_genres
|
108
|
+
mock_genre_0
|
109
|
+
mock_genre_1
|
110
|
+
allow(::Genre).to receive(:all).and_return([@genre_0, @genre_1])
|
111
|
+
end
|
112
|
+
|
113
|
+
def mock_genre_0
|
130
114
|
@genre_0 = ::Genre.new
|
131
115
|
allow(@genre_0).to receive(:name).and_return('Exploration')
|
132
116
|
allow(@genre_0).to receive(:books).and_return([@book_0])
|
117
|
+
end
|
118
|
+
|
119
|
+
def mock_genre_1
|
133
120
|
@genre_1 = ::Genre.new
|
134
121
|
allow(@genre_1).to receive(:name).and_return('Pirate Exploits')
|
135
122
|
allow(@genre_1).to receive(:books).and_return([@book_1])
|
136
|
-
|
137
|
-
allow(::Author).to receive(:scoped).and_return(::Author)
|
138
|
-
allow(::Author).to receive(:find).and_return([@author])
|
139
|
-
allow(::Author).to receive(:all).and_return([@author])
|
140
|
-
allow(::Author).to receive(:where).and_return([@author])
|
141
|
-
allow(::Author).to receive(:human_attribute_name) { |column_name| column_name.to_s.humanize }
|
142
|
-
allow(::Author).to receive(:human_name).and_return('::Author')
|
143
|
-
allow(::Author).to receive(:content_columns).and_return([double('column', name: 'login'), double('column', name: 'created_at')])
|
144
|
-
allow(::Author).to receive(:to_key).and_return(nil)
|
145
|
-
allow(::Author).to receive(:persisted?).and_return(nil)
|
146
|
-
|
147
|
-
allow(::Book).to receive(:all).and_return([@book_0, @book_1])
|
148
|
-
allow(::Genre).to receive(:all).and_return([@genre_0, @genre_1])
|
149
|
-
end
|
150
|
-
|
151
|
-
def self.included(base)
|
152
|
-
base.class_eval do
|
153
|
-
attr_accessor :output_buffer
|
154
|
-
|
155
|
-
def protect_against_forgery?
|
156
|
-
false
|
157
|
-
end
|
158
|
-
end
|
159
123
|
end
|
160
124
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foundation_rails_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastien Gruhier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.1'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '7.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '4.1'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '7.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: actionpack
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,6 +37,9 @@ dependencies:
|
|
31
37
|
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: '4.1'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '7.0'
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,6 +47,9 @@ dependencies:
|
|
38
47
|
- - ">="
|
39
48
|
- !ruby/object:Gem::Version
|
40
49
|
version: '4.1'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '7.0'
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: activemodel
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,6 +57,9 @@ dependencies:
|
|
45
57
|
- - ">="
|
46
58
|
- !ruby/object:Gem::Version
|
47
59
|
version: '4.1'
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '7.0'
|
48
63
|
type: :runtime
|
49
64
|
prerelease: false
|
50
65
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,6 +67,9 @@ dependencies:
|
|
52
67
|
- - ">="
|
53
68
|
- !ruby/object:Gem::Version
|
54
69
|
version: '4.1'
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '7.0'
|
55
73
|
- !ruby/object:Gem::Dependency
|
56
74
|
name: activesupport
|
57
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,6 +77,9 @@ dependencies:
|
|
59
77
|
- - ">="
|
60
78
|
- !ruby/object:Gem::Version
|
61
79
|
version: '4.1'
|
80
|
+
- - "<"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '7.0'
|
62
83
|
type: :runtime
|
63
84
|
prerelease: false
|
64
85
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -66,38 +87,21 @@ dependencies:
|
|
66
87
|
- - ">="
|
67
88
|
- !ruby/object:Gem::Version
|
68
89
|
version: '4.1'
|
69
|
-
-
|
70
|
-
name: tzinfo
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
90
|
+
- - "<"
|
74
91
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
76
|
-
- - ">="
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: 1.2.2
|
79
|
-
type: :runtime
|
80
|
-
prerelease: false
|
81
|
-
version_requirements: !ruby/object:Gem::Requirement
|
82
|
-
requirements:
|
83
|
-
- - "~>"
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '1.2'
|
86
|
-
- - ">="
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: 1.2.2
|
92
|
+
version: '7.0'
|
89
93
|
- !ruby/object:Gem::Dependency
|
90
94
|
name: rspec-rails
|
91
95
|
requirement: !ruby/object:Gem::Requirement
|
92
96
|
requirements:
|
93
|
-
- - "
|
97
|
+
- - "~>"
|
94
98
|
- !ruby/object:Gem::Version
|
95
99
|
version: '3.1'
|
96
100
|
type: :development
|
97
101
|
prerelease: false
|
98
102
|
version_requirements: !ruby/object:Gem::Requirement
|
99
103
|
requirements:
|
100
|
-
- - "
|
104
|
+
- - "~>"
|
101
105
|
- !ruby/object:Gem::Version
|
102
106
|
version: '3.1'
|
103
107
|
- !ruby/object:Gem::Dependency
|
@@ -132,16 +136,16 @@ dependencies:
|
|
132
136
|
name: rubocop
|
133
137
|
requirement: !ruby/object:Gem::Requirement
|
134
138
|
requirements:
|
135
|
-
- - "
|
139
|
+
- - "~>"
|
136
140
|
- !ruby/object:Gem::Version
|
137
|
-
version:
|
141
|
+
version: 0.44.1
|
138
142
|
type: :development
|
139
143
|
prerelease: false
|
140
144
|
version_requirements: !ruby/object:Gem::Requirement
|
141
145
|
requirements:
|
142
|
-
- - "
|
146
|
+
- - "~>"
|
143
147
|
- !ruby/object:Gem::Version
|
144
|
-
version:
|
148
|
+
version: 0.44.1
|
145
149
|
description: Rails for zurb foundation CSS framework. Form builder, flash message,
|
146
150
|
...
|
147
151
|
email:
|
@@ -167,6 +171,7 @@ files:
|
|
167
171
|
- lib/foundation_rails_helper/configuration.rb
|
168
172
|
- lib/foundation_rails_helper/flash_helper.rb
|
169
173
|
- lib/foundation_rails_helper/form_builder.rb
|
174
|
+
- lib/foundation_rails_helper/size_class_calculator.rb
|
170
175
|
- lib/foundation_rails_helper/version.rb
|
171
176
|
- lib/railtie.rb
|
172
177
|
- spec/.rubocop.yml
|
@@ -175,6 +180,9 @@ files:
|
|
175
180
|
- spec/foundation_rails_helper/form_builder_spec.rb
|
176
181
|
- spec/spec_helper.rb
|
177
182
|
- spec/support/.rubocop.yml
|
183
|
+
- spec/support/classes/author.rb
|
184
|
+
- spec/support/classes/book.rb
|
185
|
+
- spec/support/classes/genre.rb
|
178
186
|
- spec/support/mock_rails.rb
|
179
187
|
homepage: http://github.com/sgruhier/foundation_rails_helper
|
180
188
|
licenses:
|
@@ -195,8 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
203
|
- !ruby/object:Gem::Version
|
196
204
|
version: '0'
|
197
205
|
requirements: []
|
198
|
-
|
199
|
-
rubygems_version: 2.6.4
|
206
|
+
rubygems_version: 3.0.1
|
200
207
|
signing_key:
|
201
208
|
specification_version: 4
|
202
209
|
summary: Rails helpers for zurb foundation CSS framework
|
@@ -206,5 +213,7 @@ test_files:
|
|
206
213
|
- spec/foundation_rails_helper/form_builder_spec.rb
|
207
214
|
- spec/spec_helper.rb
|
208
215
|
- spec/support/.rubocop.yml
|
216
|
+
- spec/support/classes/author.rb
|
217
|
+
- spec/support/classes/book.rb
|
218
|
+
- spec/support/classes/genre.rb
|
209
219
|
- spec/support/mock_rails.rb
|
210
|
-
has_rdoc:
|