duckpond 1.1.2 → 1.1.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: 7b810fdeab5df4f4ec189e29564679ca36a5def0
4
- data.tar.gz: 2155f5a7e386b93b23b528681cf6e42434428372
3
+ metadata.gz: ff44bdc5c03c542af79ff6a7a6c525ad67ca2b81
4
+ data.tar.gz: 8fda27a470b7ef9cd6744fa1a054a2bd96163b85
5
5
  SHA512:
6
- metadata.gz: db69cd0d990921af13bc9f20074ccbe3cad89820b70a7337e32061a10c21adab8da60f5ae9d6d0956040a8f4454b6f71372f128123086314d965dc25a220d3a0
7
- data.tar.gz: 9c388f4d94bb16176f8dcfe33def905b3df7a053bc4a537160130b2aed2c9bb3d26dc1b29d31c2aa06070efcea465295bb4b419a7a34f59cc52c03d0968f9064
6
+ metadata.gz: 338d11de6f3c7439d27c92937a150dcd6b2fb2346d556f874bad94a9609fd6cca31f2a6e08e6c6a1e39f35f11e3b9f41e8543d2dceb61af2ae66efa1b3621760
7
+ data.tar.gz: 5d6c89b8cdc59b2569a2816b422e2ea302ea7c2f70c08ae2229d8817081e44afd74938453a40f0cf26616d3d95da8a68b53b1157c03d9219d76f1c676b2916c0
@@ -7,16 +7,8 @@
7
7
  module DuckPond
8
8
  class MethodClause < Clause
9
9
 
10
- attr_reader :method_name
11
-
12
- #
13
- # initialize
14
- #
15
- # Initialize method clauses with the method name as a symbol.
16
- #
17
- def initialize(method_name, opts = {})
18
- @method_name = method_name
19
- @options = opts
10
+ def method_name
11
+ @options[:method_name]
20
12
  end
21
13
 
22
14
  #
@@ -25,7 +17,7 @@ module DuckPond
25
17
  # A subject satisfies a method clause if it responds to that method.
26
18
  #
27
19
  def satisfied_by?(subject)
28
- subject.respond_to? @method_name
20
+ subject.respond_to? method_name
29
21
  end
30
22
 
31
23
  end
@@ -6,13 +6,13 @@
6
6
  module DuckPond
7
7
  class Clause
8
8
 
9
+ attr_reader :options
10
+
9
11
  #
10
- # options
11
- #
12
- # A hash of options
12
+ # initialize
13
13
  #
14
- def options
15
- @options
14
+ def initialize(opts = {})
15
+ @options = opts
16
16
  end
17
17
 
18
18
  end
@@ -32,13 +32,23 @@ module DuckPond
32
32
  end
33
33
  end
34
34
 
35
+ #
36
+ # has_clause
37
+ #
38
+ # add a clause to the contract's list of clauses
39
+ #
40
+ def has_clause(clause_klass, opts = {})
41
+ clauses << clause_klass.new(opts)
42
+ end
43
+
44
+
35
45
  #
36
46
  # has_method
37
47
  #
38
- # Adds a method expectation to the contract
48
+ # Adds a method clause to the contract
39
49
  #
40
- def has_method(method_name)
41
- clauses << MethodClause.new(method_name)
50
+ def has_method(method_name, opts = {})
51
+ has_clause MethodClause, opts.merge(:method_name => method_name)
42
52
  end
43
53
 
44
54
  #
@@ -1,3 +1,3 @@
1
1
  module DuckPond
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
@@ -9,30 +9,18 @@ module DuckPond
9
9
  end
10
10
 
11
11
  describe 'Constructor' do
12
- context 'when passed a method name' do
13
- it 'constructs a clause with that method name' do
14
- expect(MethodClause.new(:foo).method_name).to eq :foo
15
- end
16
- end
17
- context 'when passed a method name and some options' do
18
- it 'constructs a clause with that method name and those options' do
19
- clause = MethodClause.new(:foo, :my => :options)
12
+ context 'when constructed with a method name option' do
13
+ it 'adds that method name as an attribute' do
14
+ clause = MethodClause.new(:method_name => :foo)
20
15
  expect(clause.method_name).to eq :foo
21
- expect(clause.options[:my]).to eq :options
22
16
  end
23
17
  end
24
18
  end
25
19
 
26
20
  describe 'Instance Methods' do
27
-
28
- describe '#method_name' do
29
- it 'returns the method name the clause was constructed with' do
30
- expect(MethodClause.new(:foo).method_name).to eq :foo
31
- end
32
- end
33
-
21
+
34
22
  describe '#satisfied_by?' do
35
- let(:clause) { MethodClause.new(:length) }
23
+ let(:clause) { MethodClause.new(:method_name => :length) }
36
24
 
37
25
  context 'when the subject responds to the clauses method' do
38
26
  it 'returns true' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duckpond
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikey Hogarth