composable_operations 0.10.0 → 0.10.1

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: 16bacd4b97dcd28f11356d7a01dbc3957487b5a9
4
- data.tar.gz: f622ff84700dccf7ed5fc89d99907706b124e0b5
3
+ metadata.gz: 1625a77cc6ddbf6e011cb4e2a967d5ab491e8689
4
+ data.tar.gz: 5f1c9270151db8f4b52efc01366d00d12e3975b8
5
5
  SHA512:
6
- metadata.gz: 4a2bf743f4f0f86f5ab3f0c8265c68feedf626dbf76cf00c860184ae81e37dd4635a324adf46c9c4f0b7c90af675863ada47bcb0d12f732d4d47180e9683be57
7
- data.tar.gz: 13dd02a2bdd146fab5bc27a265cf24a5180087303981c89b2aa23d89076a7fab70687be56971a6a63f6d8d78727267bb833b5080ec432776bed055963110eba7
6
+ metadata.gz: e014a75115eb0939b2b3616138c7c8c70fea8d93bbc5d07d5e0a54d211a22ea14a69bf999bfdfb8d47009a852f130a6cafdee1de7d0a9857a2181ba60c30e790
7
+ data.tar.gz: 451f1c59b1eb0a8163d8e7a63fc4fca418ec35483d0e79fcee76063120c5cef8489e3bba398eda83ccb6b5a92164ace4b6724f71189966dea5373b921c64612d
@@ -4,10 +4,8 @@ module ComposableOperations
4
4
  include SmartProperties
5
5
 
6
6
  class << self
7
- attr_writer :arguments
8
-
9
7
  def arguments
10
- @arguments ||= []
8
+ []
11
9
  end
12
10
 
13
11
  def arity
@@ -64,10 +62,8 @@ module ComposableOperations
64
62
  when 0
65
63
  raise ArgumentError, "#{self}.#{__callee__} expects at least one argument"
66
64
  else
67
- names.each_with_index do |name, index|
68
- property(name, required: true) unless properties.key?(name)
69
- arguments << name
70
- end
65
+ names.each { |name| property(name, required: true) unless properties.key?(name) }
66
+ define_singleton_method(:arguments) { names }
71
67
  end
72
68
  end
73
69
 
@@ -1,3 +1,3 @@
1
1
  module ComposableOperations
2
- VERSION = "0.10.0"
2
+ VERSION = "0.10.1"
3
3
  end
@@ -126,5 +126,66 @@ describe ComposableOperations::Operation do
126
126
 
127
127
  it { is_expected.to succeed_to_perform.when_initialized_with("-", 3).and_return("---") }
128
128
  end
129
+
130
+ context "inheritance" do
131
+ let(:base_operation) do
132
+ Class.new(described_class) do
133
+ processes :text
134
+ end
135
+ end
136
+
137
+ let(:sub_operation) do
138
+ Class.new(base_operation) do
139
+ def execute
140
+ text.upcase
141
+ end
142
+ end
143
+ end
144
+
145
+ let(:sub_operation_with_different_input) do
146
+ Class.new(base_operation) do
147
+ processes :text, :multiplier
148
+ def execute
149
+ text * multiplier
150
+ end
151
+ end
152
+ end
153
+
154
+ context "the base operation" do
155
+ subject! { base_operation }
156
+
157
+ it "should take one argument" do
158
+ expect(base_operation.arity).to eq(1)
159
+ expect(base_operation.arguments).to eq([:text])
160
+ end
161
+ end
162
+
163
+ context "the sub operation" do
164
+ subject! { sub_operation }
165
+
166
+ it "should take one argument" do
167
+ expect(base_operation.arity).to eq(1)
168
+ expect(base_operation.arguments).to eq([:text])
169
+ end
170
+
171
+ it { is_expected.to succeed_to_perform.when_initialized_with("lorem ipsum").and_return("LOREM IPSUM") }
172
+ end
173
+
174
+ context "the sub operation with different input" do
175
+ subject! { sub_operation_with_different_input }
176
+
177
+ it "should take two arguments" do
178
+ expect(sub_operation_with_different_input.arity).to eq(2)
179
+ expect(sub_operation_with_different_input.arguments).to eq([:text, :multiplier])
180
+ end
181
+
182
+ it "should not influence the arguments of base operation" do
183
+ expect(base_operation.arity).to eq(1)
184
+ expect(base_operation.arguments).to eq([:text])
185
+ end
186
+
187
+ it { is_expected.to succeed_to_perform.when_initialized_with("-", 3).and_return("---") }
188
+ end
189
+ end
129
190
  end
130
191
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: composable_operations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Tennhard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-20 00:00:00.000000000 Z
11
+ date: 2015-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smart_properties