pr 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55484a6b05a98ec13a14b2fd4379d5f4929d9c81
4
- data.tar.gz: 042c0a68883e6c1806719b8b96feabdbad4028f1
3
+ metadata.gz: dabd9d8c21b3c850b57cde93687b312cba5e9946
4
+ data.tar.gz: 5e58afda498dd0c2c8f64d44800ebf6ef6610884
5
5
  SHA512:
6
- metadata.gz: dc15a38ecd36986d79e554857e00873441faee6a18bb1001839895cdd2de46e77da8359df747e4b1675737e18ea1b2a60f592ebb0d34904f4ed974cf1eaebbe9
7
- data.tar.gz: 030d6e9830aa1d40a8ef2f08be50b83a0d76bbedd89ff978cba16f37989007f890e86385c27fd96da46f43b6d77a253708cb524c5500b5ac490e64907f3062b9
6
+ metadata.gz: ac666293f13a93bf37b9c89f0fb582567d9a707633040384ada6fbc872ca6e2e981a9b706326a31424bed48f20c49a548c07a7ae0b3aeea1425e163938531728
7
+ data.tar.gz: fe28ee1ca371b167ebcec05173608ea68e0193d7b7538cb5a9e9235ce5ac7bc956ec4224c6bde457c6a0f9858a432878b05aee322abd90e3c7340dd65deb7c90
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -55,3 +55,34 @@ Feature: Building a form from a hash
55
55
  """
56
56
  Then my form should have a event_name of "Mien Event"
57
57
  Then my form should have a start_date of "31/03/2013"
58
+
59
+ @form @macro @hash @args
60
+ Scenario: Basic Form built using macro with arguments
61
+ Given I have a form defined as:
62
+ """Ruby
63
+ class MyForm
64
+ include PR::Form
65
+
66
+ def initialize argument
67
+ @my_argument = argument
68
+ end
69
+ attr_reader :my_argument
70
+
71
+ field :event_name, :string
72
+ field :start_date, :date
73
+
74
+ end
75
+ """
76
+ And I have a hash:
77
+ """Ruby
78
+ {
79
+ "event_name" => "Mien Event",
80
+ "start_date" => "31/03/2013"
81
+ }
82
+ """
83
+ When I build my form using the macro:
84
+ """Ruby
85
+ @form = MyForm.from_hash @hash, "An argument"
86
+ """
87
+ Then my form should have a my_argument of "An argument"
88
+
@@ -1,19 +1,17 @@
1
- module DSL
2
-
3
- class World
4
- require 'pr'
5
-
6
- def run code
7
- eval code
8
- end
9
- end
1
+ require 'pr'
10
2
 
3
+ module DSL
11
4
 
12
5
  def run_test code
13
6
  world.run code
14
7
  end
15
- alias define_field run_test
16
- alias define_form run_test
8
+
9
+ def setup_test code
10
+ world.load code
11
+ end
12
+
13
+ alias define_field setup_test
14
+ alias define_form setup_test
17
15
  alias define_model run_test
18
16
 
19
17
  def define_hash code
@@ -29,7 +27,19 @@ module DSL
29
27
  end
30
28
 
31
29
  def world
32
- @world ||= Class.new(World).new
30
+ @world ||= world_klass.new
31
+ end
32
+
33
+ def world_klass
34
+ Class.new do
35
+ def load code
36
+ self.class.class_eval code
37
+ end
38
+
39
+ def run code
40
+ self.instance_eval code
41
+ end
42
+ end
33
43
  end
34
44
 
35
45
  def set thing, attribute, value
@@ -10,8 +10,8 @@ module PR
10
10
  def field name, type, options = {}
11
11
  PR::DefineAndRegister[ self, name, type, options ]
12
12
  end
13
- def from_hash hash
14
- form = new
13
+ def from_hash hash, *args
14
+ form = new *args
15
15
  PR::BuildFromHash[ form, hash ]
16
16
  form
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module PR
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Rowe
@@ -29,7 +29,7 @@ cert_chain:
29
29
  2feWfO4gCNmvfFjULOAYHq9JHEjN5SLSXvj5HdSnDcCyIfJKn5Ya3JahWQaWIsXf
30
30
  /NPE/mB57TOwj+d7XUa2NC4HUadF8R51IYEcIB0PpIEzJlKtfXFcOZxO
31
31
  -----END CERTIFICATE-----
32
- date: 2013-04-10 00:00:00.000000000 Z
32
+ date: 2013-04-15 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rake
metadata.gz.sig CHANGED
Binary file