lawyer 0.0.6 → 0.0.7

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: d46dcfc42895a568a49c87cc284cd28155384312
4
- data.tar.gz: c8897c7a23c524bee14c27da46d061973b6dd656
3
+ metadata.gz: 68b5a4c4e55ef1cf00ad9bfdbdf03f369f6365ae
4
+ data.tar.gz: 32c4b7675c0e0182b154a527b5918daef0d3a866
5
5
  SHA512:
6
- metadata.gz: f5031ab5c0b50384d3defe55b153c56e49dec570e67e45048f8213870b9f769a33754d3c1d01931e8ddda568e3bcb9e6e6cdac59ebd65bed14de70715bdb785b
7
- data.tar.gz: f6e02cf3be5cb1af0550f9676eb21caab6ab10b388b65f1a6bcf2797358d3ae8df1af27723bc831439308d61dd23c435afdf5294e8f3bcc91986d73bb22ad133
6
+ metadata.gz: 731191cb5a2171bd315304dc12f4f94ca87c27a5f29d2aec6c36e3940922c6ee27171a79d444d6dde8b0c97c174a94c1cd62eefdf9302bca32a4983881e248f7
7
+ data.tar.gz: ea6b72a04a77d4b8fd2f3c7f49648a5afb7f233a335985c4db7c18290f5c8deedbe9861bdcc70a0c12db5e0146b6df8e0fae1b10c59f291a61215e74ed876c03
data/lib/lawyer/clause.rb CHANGED
@@ -38,7 +38,7 @@ module Lawyer
38
38
  end
39
39
 
40
40
  def missing_method?(subject)
41
- !subject.instance_methods.include?(@name)
41
+ (@name != :initialize) && !subject.instance_methods.include?(@name)
42
42
  end
43
43
 
44
44
  def wrong_arity?(subject)
@@ -1,3 +1,3 @@
1
1
  module Lawyer
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -4,6 +4,32 @@ class TestContract < Lawyer::Contract
4
4
  confirm :pung => [:name, :size]
5
5
  end
6
6
 
7
+ class TestInitialize < Lawyer::Contract
8
+ confirm :initialize => [:arg]
9
+ end
10
+
11
+ describe TestInitialize do
12
+ before :each do
13
+ Object.send(:remove_const, :TestObjectNew) if Object.const_defined?(:TestObjectNew)
14
+ end
15
+
16
+ it "does not raise an exception is the contact is satisified" do
17
+ class TestObjectNew
18
+ def initialize(arg:)
19
+ end
20
+ end
21
+
22
+ expect { TestInitialize.check!(TestObjectNew) }.not_to raise_error
23
+ end
24
+
25
+ it "raises an exception if the signature is wrong" do
26
+ class TestObjectNew; end
27
+
28
+ expect { TestInitialize.check!(TestObjectNew) }.to raise_error(Lawyer::BrokenContract)
29
+ end
30
+ end
31
+
32
+
7
33
  describe TestContract do
8
34
  before :each do
9
35
  # Stop modifications to the TestObject from leaking into other specs.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lawyer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Cinnamond
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-20 00:00:00.000000000 Z
11
+ date: 2014-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler