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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1daff9bd1feb2e5837a1818a792593760425064f
4
- data.tar.gz: aa9c43f132c21fcd97d33e52afdc7d33522e8edc
3
+ metadata.gz: 680817cba6358a6d4d0137a83f0ffb44c19b2af5
4
+ data.tar.gz: d4644a6a3a3b649c8bd4947ccd2170ee6ac6f571
5
5
  SHA512:
6
- metadata.gz: daf9c4562f38f981a028cbdec983b4db381c7df75ca71389a7242a8623eec61f07092c1515305377ec5417cd943ac67fc1c93584b6454d4de6362b0262aaa775
7
- data.tar.gz: bcdfd8f9e12074ae4dc8f207c7c9be2af51860cb75f1621ffe537a516f7e496e16130ed723168374f89254b884d212e710e8f69cb90c735f1a4df32f6b6e1556
6
+ metadata.gz: ac84655f78735243502f6f5766e7c29afa2cbb02c5581aeec2b5b8416a13b9ceee08dc78e7912f63409b061eb9c4d2fb0f97e5f61ca8960ea5a8578f414e7e56
7
+ data.tar.gz: 15fcd74cada0345010c306d91b1ece413f5979ccc4d167fbb63d385bfb9cb1e60b65e8034163c0ba88916a7587e4eb24db9b11156aff4e608fc159cb1beae909
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.2.1
2
+
3
+ * Fix `Contract::Properties`. Thanks @simonc. <3
4
+
1
5
  ## 2.2.0
2
6
 
3
7
  * Remove `reform/rails`. This is now handled via the `reform-rails` gem which you have to bundle.
@@ -29,7 +29,7 @@ module Reform
29
29
 
30
30
  # FIXME: test me.
31
31
  def self.properties(*args)
32
- options = args.pop if args.last.is_a?(Hash)
32
+ options = args.last.is_a?(Hash) ? args.pop : {}
33
33
  args.each { |name| property(name, options.dup) }
34
34
  end
35
35
 
@@ -1,3 +1,3 @@
1
1
  module Reform
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.1"
3
3
  end
@@ -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.0
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-20 00:00:00.000000000 Z
12
+ date: 2016-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: disposable