reform 2.2.0 → 2.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 +4 -4
- data/CHANGES.md +4 -0
- data/lib/reform/contract.rb +1 -1
- data/lib/reform/version.rb +1 -1
- data/test/contract_test.rb +27 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 680817cba6358a6d4d0137a83f0ffb44c19b2af5
|
4
|
+
data.tar.gz: d4644a6a3a3b649c8bd4947ccd2170ee6ac6f571
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac84655f78735243502f6f5766e7c29afa2cbb02c5581aeec2b5b8416a13b9ceee08dc78e7912f63409b061eb9c4d2fb0f97e5f61ca8960ea5a8578f414e7e56
|
7
|
+
data.tar.gz: 15fcd74cada0345010c306d91b1ece413f5979ccc4d167fbb63d385bfb9cb1e60b65e8034163c0ba88916a7587e4eb24db9b11156aff4e608fc159cb1beae909
|
data/CHANGES.md
CHANGED
data/lib/reform/contract.rb
CHANGED
data/lib/reform/version.rb
CHANGED
data/test/contract_test.rb
CHANGED
@@ -2,7 +2,7 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class ContractTest < MiniTest::Spec
|
4
4
|
Song = Struct.new(:title, :album, :composer)
|
5
|
-
Album = Struct.new(:name, :songs, :artist)
|
5
|
+
Album = Struct.new(:name, :duration, :songs, :artist)
|
6
6
|
Artist = Struct.new(:name)
|
7
7
|
|
8
8
|
class ArtistForm < Reform::Form
|
@@ -11,6 +11,10 @@ class ContractTest < MiniTest::Spec
|
|
11
11
|
|
12
12
|
class AlbumForm < Reform::Contract
|
13
13
|
property :name
|
14
|
+
|
15
|
+
properties :duration
|
16
|
+
properties :year, :style, readable: false
|
17
|
+
|
14
18
|
validation do
|
15
19
|
key(:name).required
|
16
20
|
end
|
@@ -36,7 +40,7 @@ class ContractTest < MiniTest::Spec
|
|
36
40
|
let (:song_with_composer) { Song.new("Resist Stance", nil, composer) }
|
37
41
|
let (:composer) { Artist.new("Greg Graffin") }
|
38
42
|
let (:artist) { Artist.new("Bad Religion") }
|
39
|
-
let (:album) { Album.new("The Dissent Of Man", [song, song_with_composer], artist) }
|
43
|
+
let (:album) { Album.new("The Dissent Of Man", 123, [song, song_with_composer], artist) }
|
40
44
|
|
41
45
|
let (:form) { AlbumForm.new(album) }
|
42
46
|
|
@@ -45,6 +49,27 @@ class ContractTest < MiniTest::Spec
|
|
45
49
|
form.artist.must_be_instance_of ArtistForm
|
46
50
|
end
|
47
51
|
|
52
|
+
describe ".properties" do
|
53
|
+
it "defines a property when called with one argument" do
|
54
|
+
form.must_respond_to :duration
|
55
|
+
end
|
56
|
+
|
57
|
+
it "defines several properties when called with multiple arguments" do
|
58
|
+
form.must_respond_to :year
|
59
|
+
form.must_respond_to :style
|
60
|
+
end
|
61
|
+
|
62
|
+
it "passes options to each property when options are provided" do
|
63
|
+
readable = AlbumForm.new(album).options_for(:style)[:readable]
|
64
|
+
readable.must_equal false
|
65
|
+
end
|
66
|
+
|
67
|
+
it "returns the list of defined properties" do
|
68
|
+
returned_value = AlbumForm.properties(:hello, :world, virtual: true)
|
69
|
+
returned_value.must_equal [:hello, :world]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
48
73
|
describe "#options_for" do
|
49
74
|
it { AlbumForm.options_for(:name).extend(Declarative::Inspect).inspect.must_equal "#<Disposable::Twin::Definition: @options={:private_name=>:name, :name=>\"name\"}>" }
|
50
75
|
it { AlbumForm.new(album).options_for(:name).extend(Declarative::Inspect).inspect.must_equal "#<Disposable::Twin::Definition: @options={:private_name=>:name, :name=>\"name\"}>" }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-06-
|
12
|
+
date: 2016-06-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: disposable
|