light-service 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/light-service/organizer.rb +3 -1
- data/lib/light-service/version.rb +1 -1
- data/spec/organizer_spec.rb +46 -0
- metadata +3 -1
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LightService::Organizer do
|
4
|
+
class AnAction; end
|
5
|
+
|
6
|
+
class AnOrganizer
|
7
|
+
extend LightService::Organizer
|
8
|
+
|
9
|
+
def self.some_method(user)
|
10
|
+
with(user: user).reduce [AnAction]
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.some_method_with(user)
|
14
|
+
context = LightService::Context.new(user: user)
|
15
|
+
with(context).reduce [AnAction]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:context) { ::LightService::Context.make(user: user) }
|
20
|
+
let(:user) { double(:user) }
|
21
|
+
|
22
|
+
context "when #with is called with hash" do
|
23
|
+
before do
|
24
|
+
AnAction.should_receive(:execute) \
|
25
|
+
.with(context) \
|
26
|
+
.and_return context
|
27
|
+
end
|
28
|
+
it "creates a Context" do
|
29
|
+
LightService::Context.should_receive(:make).and_return context
|
30
|
+
|
31
|
+
AnOrganizer.some_method(user)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when #with is called with Context" do
|
36
|
+
it "does not create a context" do
|
37
|
+
LightService::Context.stub(:new).and_return context
|
38
|
+
|
39
|
+
AnAction.should_receive(:execute) \
|
40
|
+
.with(context) \
|
41
|
+
.and_return context
|
42
|
+
AnOrganizer.some_method_with(context)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: light-service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- spec/acceptance/add_numbers_spec.rb
|
68
68
|
- spec/action_base_spec.rb
|
69
69
|
- spec/context_spec.rb
|
70
|
+
- spec/organizer_spec.rb
|
70
71
|
- spec/sample/calculates_order_tax_action_spec.rb
|
71
72
|
- spec/sample/calculates_tax_spec.rb
|
72
73
|
- spec/sample/looks_up_tax_percentage_action.rb
|
@@ -104,6 +105,7 @@ test_files:
|
|
104
105
|
- spec/acceptance/add_numbers_spec.rb
|
105
106
|
- spec/action_base_spec.rb
|
106
107
|
- spec/context_spec.rb
|
108
|
+
- spec/organizer_spec.rb
|
107
109
|
- spec/sample/calculates_order_tax_action_spec.rb
|
108
110
|
- spec/sample/calculates_tax_spec.rb
|
109
111
|
- spec/sample/looks_up_tax_percentage_action.rb
|