pr 0.0.2 → 0.0.3

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: d1967110cefbe5a002dd832abb9e60df5257bd16
4
- data.tar.gz: 66f1fc2292f655b8203599056b0e43fe737d19d5
3
+ metadata.gz: 55484a6b05a98ec13a14b2fd4379d5f4929d9c81
4
+ data.tar.gz: 042c0a68883e6c1806719b8b96feabdbad4028f1
5
5
  SHA512:
6
- metadata.gz: 58681a9064ea976b0edb67b0077e2e72411cc5b83aca8936a4dc99d47b3f0869803550881bd4ae3de235bc2c2c11e417c4472acf706499552cca1c953561e962
7
- data.tar.gz: b0ac34db4e729c275a082fee6e3f4706edf23fa6581d3c00a085f836826330c541c45674cfc4f33ee3b2e6dd4b955983fd6aff5544acefcd7f9b8ac1c776b4a7
6
+ metadata.gz: dc15a38ecd36986d79e554857e00873441faee6a18bb1001839895cdd2de46e77da8359df747e4b1675737e18ea1b2a60f592ebb0d34904f4ed974cf1eaebbe9
7
+ data.tar.gz: 030d6e9830aa1d40a8ef2f08be50b83a0d76bbedd89ff978cba16f37989007f890e86385c27fd96da46f43b6d77a253708cb524c5500b5ac490e64907f3062b9
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -0,0 +1,42 @@
1
+ Feature: Defining custom fields
2
+ In order to extend the gem with customised fields
3
+ As a developer
4
+ I wish to define and register custom fields
5
+
6
+ @custom @fields
7
+ Scenario: Defining and using a custom field
8
+ Given I have a field defined as:
9
+ """Ruby
10
+ class MyCustomField
11
+
12
+ def initialize value = nil, options = {}
13
+ @value, @options = value, options
14
+ end
15
+ attr_reader :options
16
+
17
+ def raw
18
+ @value
19
+ end
20
+
21
+ def populate value
22
+ @value = value
23
+ end
24
+
25
+ def convert
26
+ @value
27
+ end
28
+
29
+ end
30
+ """
31
+ When I register the field:
32
+ """Ruby
33
+ PR::Fields[:custom] = MyCustomField
34
+ """
35
+ Then I should be able define a form as:
36
+ """Ruby
37
+ class MyCustomFieldForm
38
+ include PR::Form
39
+ field :example, :custom
40
+ end
41
+ """
42
+ And my form should have a `MyCustomField` example field
@@ -0,0 +1,7 @@
1
+ Given "I have a field defined as:" do |code|
2
+ define_field code
3
+ end
4
+
5
+ When "I register the field:" do |code|
6
+ run_test code
7
+ end
@@ -21,3 +21,12 @@ end
21
21
  Then /^my form should have a date input "(\w+)"$/ do |name|
22
22
  set @form, name, "31/03/2013"
23
23
  end
24
+
25
+ Then "I should be able define a form as:" do |code|
26
+ define_form code
27
+ end
28
+
29
+ Then /^my form should have a `(\w+)` (\w+) field$/ do |klass,field|
30
+ @form ||= fetch("MyCustomFieldForm").new
31
+ expect( @form.send("__#{field}") ).to be_a fetch(klass)
32
+ end
@@ -12,6 +12,7 @@ module DSL
12
12
  def run_test code
13
13
  world.run code
14
14
  end
15
+ alias define_field run_test
15
16
  alias define_form run_test
16
17
  alias define_model run_test
17
18
 
@@ -1,3 +1,3 @@
1
1
  module PR
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Rowe
@@ -115,11 +115,13 @@ files:
115
115
  - README.md
116
116
  - Rakefile
117
117
  - features/active_model_compatibility.feature
118
+ - features/adding_custom_fields.feature
118
119
  - features/building_forms_from_hashes.feature
119
120
  - features/building_forms_from_models.feature
120
121
  - features/building_models_from_form.feature
121
122
  - features/defining_a_form.feature
122
123
  - features/step_definitions/active_model_steps.rb
124
+ - features/step_definitions/field_steps.rb
123
125
  - features/step_definitions/form_steps.rb
124
126
  - features/step_definitions/hash_steps.rb
125
127
  - features/step_definitions/model_steps.rb
@@ -183,11 +185,13 @@ specification_version: 4
183
185
  summary: Public Relations tools for Rails
184
186
  test_files:
185
187
  - features/active_model_compatibility.feature
188
+ - features/adding_custom_fields.feature
186
189
  - features/building_forms_from_hashes.feature
187
190
  - features/building_forms_from_models.feature
188
191
  - features/building_models_from_form.feature
189
192
  - features/defining_a_form.feature
190
193
  - features/step_definitions/active_model_steps.rb
194
+ - features/step_definitions/field_steps.rb
191
195
  - features/step_definitions/form_steps.rb
192
196
  - features/step_definitions/hash_steps.rb
193
197
  - features/step_definitions/model_steps.rb
metadata.gz.sig CHANGED
Binary file