funky_form 0.1.0 → 0.2.1
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 +7 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -1
- data/LICENSE +19 -0
- data/funky_form.gemspec +3 -2
- data/lib/funky_form.rb +1 -1
- data/lib/funky_form/class_methods.rb +1 -1
- data/lib/funky_form/version.rb +1 -1
- data/test/{integration → acceptance}/posts_test.rb +2 -2
- data/test/{integration_test_helper.rb → acceptance_test_helper.rb} +3 -5
- data/test/funky_form_test.rb +39 -1
- data/test/test_helper.rb +1 -1
- metadata +24 -35
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 056514e20bfae06f635ac1cbc1cbb62bc801b2acd1beb4b238c5ecfd0412a0f2
|
4
|
+
data.tar.gz: 1a65919513cd99a768e64792b51de4d4d670bb8615b56e2a9fb9ccd7ee18a515
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 592eb8128ca9d493046ef5904a3ff7b5208230747ddfae5d9f5ae8c6e8a85d663f15ad8f16e5e73fd33127a14554e0d63df8788fc959f6a43e5058b79d2b487c
|
7
|
+
data.tar.gz: 67f1d8d1221b4a8869f1766c56ad6e1bcfc63a4d011de4b830afa833492518c00367618e0a86fb029652b31321845539387370a834bf485d5a88dcf8cbb4d566
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2013-2020 Indrek Juhkam
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the “Software”), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
+
so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/funky_form.gemspec
CHANGED
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = ""
|
11
11
|
s.summary = %q{Simple form objects in ruby}
|
12
12
|
s.description = %q{}
|
13
|
+
s.license = "MIT"
|
13
14
|
|
14
15
|
s.rubyforge_project = "funky_form"
|
15
16
|
|
@@ -18,6 +19,6 @@ Gem::Specification.new do |s|
|
|
18
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
20
|
s.require_paths = ["lib"]
|
20
21
|
|
21
|
-
s.add_dependency "virtus", "~> 0
|
22
|
-
s.add_dependency "activemodel", "
|
22
|
+
s.add_dependency "virtus", "~> 1.0"
|
23
|
+
s.add_dependency "activemodel", ">= 3.2.0"
|
23
24
|
end
|
data/lib/funky_form.rb
CHANGED
@@ -7,7 +7,7 @@ module FunkyForm
|
|
7
7
|
# @param [Class] descendant
|
8
8
|
def self.included(descendant)
|
9
9
|
super
|
10
|
-
descendant.send(:include, Virtus)
|
10
|
+
descendant.send(:include, Virtus.model)
|
11
11
|
descendant.send(:include, ActiveModel::Validations)
|
12
12
|
descendant.send(:include, ActiveModel::Conversion)
|
13
13
|
descendant.send(:include, InstanceMethods)
|
data/lib/funky_form/version.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
|
1
|
+
require "test_helper"
|
2
|
+
require "minitest-capybara"
|
2
3
|
|
3
4
|
# Configure Rails Envinronment
|
4
5
|
ENV["RAILS_ENV"] = "test"
|
5
|
-
|
6
6
|
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
7
|
-
require "rails/test_help"
|
8
|
-
|
9
7
|
Rails.backtrace_cleaner.remove_silencers!
|
10
8
|
|
11
9
|
# Configure capybara for integration testing
|
@@ -13,7 +11,7 @@ require "capybara/rails"
|
|
13
11
|
Capybara.default_driver = :rack_test
|
14
12
|
Capybara.default_selector = :css
|
15
13
|
|
16
|
-
class
|
14
|
+
class AcceptanceTest < MiniTest::Test
|
17
15
|
include Capybara::DSL
|
18
16
|
include Rails.application.routes.url_helpers
|
19
17
|
end
|
data/test/funky_form_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative "test_helper"
|
2
2
|
|
3
|
-
class FunkyFormTest < MiniTest::
|
3
|
+
class FunkyFormTest < MiniTest::Test
|
4
4
|
parallelize_me!
|
5
5
|
|
6
6
|
def test_values_from_existing_instance
|
@@ -81,6 +81,29 @@ class FunkyFormTest < MiniTest::Unit::TestCase
|
|
81
81
|
assert_equal "Order", form_class.model_name.to_s
|
82
82
|
end
|
83
83
|
|
84
|
+
def test_model_inheritance
|
85
|
+
base_class = new_funky_form do
|
86
|
+
model "Order"
|
87
|
+
end
|
88
|
+
|
89
|
+
form_class = Class.new(base_class)
|
90
|
+
|
91
|
+
assert_equal "Order", form_class.model_name.to_s
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_model_inheritance_with_different_model_name
|
95
|
+
base_class = new_funky_form do
|
96
|
+
model "Order"
|
97
|
+
end
|
98
|
+
|
99
|
+
form_class = Class.new(base_class) do
|
100
|
+
model "ConcreteOrder"
|
101
|
+
end
|
102
|
+
|
103
|
+
assert_equal "Order", base_class.model_name.to_s
|
104
|
+
assert_equal "ConcreteOrder", form_class.model_name.to_s
|
105
|
+
end
|
106
|
+
|
84
107
|
def test_validations
|
85
108
|
form = new_funky_form do
|
86
109
|
attribute :title, String
|
@@ -92,4 +115,19 @@ class FunkyFormTest < MiniTest::Unit::TestCase
|
|
92
115
|
assert !form.new(:title => "").valid?, "should be invalid when empty"
|
93
116
|
assert !form.new.valid?, "should be invalid when not specified"
|
94
117
|
end
|
118
|
+
|
119
|
+
def test_validations_with_model_inheritance
|
120
|
+
base_class = new_funky_form do
|
121
|
+
end
|
122
|
+
|
123
|
+
form = Class.new(base_class) do
|
124
|
+
model "Order"
|
125
|
+
|
126
|
+
attribute :title, String
|
127
|
+
validates :title, :presence => true
|
128
|
+
end
|
129
|
+
|
130
|
+
assert form.new(:title => "a title").valid?
|
131
|
+
assert !form.new(:title => nil).valid?, "should be invalid when nil"
|
132
|
+
end
|
95
133
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,48 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: funky_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Indrek Juhkam
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2020-11-04 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
name: virtus
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0
|
20
|
-
none: false
|
19
|
+
version: '1.0'
|
21
20
|
type: :runtime
|
22
|
-
|
21
|
+
prerelease: false
|
23
22
|
version_requirements: !ruby/object:Gem::Requirement
|
24
23
|
requirements:
|
25
|
-
- - ~>
|
24
|
+
- - "~>"
|
26
25
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0
|
28
|
-
none: false
|
29
|
-
prerelease: false
|
26
|
+
version: '1.0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
28
|
+
name: activemodel
|
31
29
|
requirement: !ruby/object:Gem::Requirement
|
32
30
|
requirements:
|
33
|
-
- -
|
31
|
+
- - ">="
|
34
32
|
- !ruby/object:Gem::Version
|
35
33
|
version: 3.2.0
|
36
|
-
none: false
|
37
34
|
type: :runtime
|
38
|
-
|
35
|
+
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
|
-
- -
|
38
|
+
- - ">="
|
42
39
|
- !ruby/object:Gem::Version
|
43
40
|
version: 3.2.0
|
44
|
-
none: false
|
45
|
-
prerelease: false
|
46
41
|
description: ''
|
47
42
|
email:
|
48
43
|
- indrek@urgas.eu
|
@@ -50,8 +45,10 @@ executables: []
|
|
50
45
|
extensions: []
|
51
46
|
extra_rdoc_files: []
|
52
47
|
files:
|
53
|
-
- .gitignore
|
48
|
+
- ".gitignore"
|
49
|
+
- ".travis.yml"
|
54
50
|
- Gemfile
|
51
|
+
- LICENSE
|
55
52
|
- README.rdoc
|
56
53
|
- Rakefile
|
57
54
|
- funky_form.gemspec
|
@@ -59,6 +56,8 @@ files:
|
|
59
56
|
- lib/funky_form/class_methods.rb
|
60
57
|
- lib/funky_form/instance_methods.rb
|
61
58
|
- lib/funky_form/version.rb
|
59
|
+
- test/acceptance/posts_test.rb
|
60
|
+
- test/acceptance_test_helper.rb
|
62
61
|
- test/dummy/Rakefile
|
63
62
|
- test/dummy/app/controllers/application_controller.rb
|
64
63
|
- test/dummy/app/controllers/posts_controller.rb
|
@@ -86,7 +85,6 @@ files:
|
|
86
85
|
- test/dummy/config/initializers/session_store.rb
|
87
86
|
- test/dummy/config/locales/en.yml
|
88
87
|
- test/dummy/config/routes.rb
|
89
|
-
- test/dummy/db/development.sqlite3
|
90
88
|
- test/dummy/db/migrate/20120306162814_create_posts.rb
|
91
89
|
- test/dummy/db/schema.rb
|
92
90
|
- test/dummy/public/404.html
|
@@ -96,37 +94,28 @@ files:
|
|
96
94
|
- test/dummy/public/stylesheets/.gitkeep
|
97
95
|
- test/dummy/script/rails
|
98
96
|
- test/funky_form_test.rb
|
99
|
-
- test/integration/posts_test.rb
|
100
|
-
- test/integration_test_helper.rb
|
101
97
|
- test/test_helper.rb
|
102
98
|
homepage: ''
|
103
|
-
licenses:
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata: {}
|
104
102
|
post_install_message:
|
105
103
|
rdoc_options: []
|
106
104
|
require_paths:
|
107
105
|
- lib
|
108
106
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
107
|
requirements:
|
110
|
-
- -
|
108
|
+
- - ">="
|
111
109
|
- !ruby/object:Gem::Version
|
112
|
-
hash: -865947392686571946
|
113
110
|
version: '0'
|
114
|
-
segments:
|
115
|
-
- 0
|
116
|
-
none: false
|
117
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
112
|
requirements:
|
119
|
-
- -
|
113
|
+
- - ">="
|
120
114
|
- !ruby/object:Gem::Version
|
121
|
-
hash: -865947392686571946
|
122
115
|
version: '0'
|
123
|
-
segments:
|
124
|
-
- 0
|
125
|
-
none: false
|
126
116
|
requirements: []
|
127
|
-
|
128
|
-
rubygems_version: 1.8.24
|
117
|
+
rubygems_version: 3.0.3
|
129
118
|
signing_key:
|
130
|
-
specification_version:
|
119
|
+
specification_version: 4
|
131
120
|
summary: Simple form objects in ruby
|
132
121
|
test_files: []
|