rest_my_case 1.10.9 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +5 -13
  2. data/README.md +330 -2
  3. data/lib/rest_my_case/base.rb +46 -21
  4. data/lib/rest_my_case/context/base.rb +11 -0
  5. data/lib/rest_my_case/context/schema_validator/base.rb +27 -0
  6. data/lib/rest_my_case/context/schema_validator/compel.rb +36 -0
  7. data/lib/rest_my_case/context/status.rb +2 -0
  8. data/lib/rest_my_case/defense_attorney/base.rb +1 -1
  9. data/lib/rest_my_case/http_status.rb +5 -8
  10. data/lib/rest_my_case/judge/base.rb +19 -14
  11. data/lib/rest_my_case/status.rb +13 -12
  12. data/lib/rest_my_case/trial/case.rb +3 -3
  13. data/lib/rest_my_case/validator.rb +3 -8
  14. data/lib/rest_my_case/version.rb +1 -1
  15. data/lib/rest_my_case.rb +0 -4
  16. data/rest_my_case.gemspec +1 -1
  17. data/spec/rest_my_case/accusation_attorneys/base_spec.rb +1 -1
  18. data/spec/rest_my_case/accusation_attorneys/each_spec.rb +1 -1
  19. data/spec/rest_my_case/accusation_attorneys/format_spec.rb +2 -2
  20. data/spec/rest_my_case/base/context_accessor_spec.rb +29 -0
  21. data/spec/rest_my_case/base/context_reader_spec.rb +21 -0
  22. data/spec/rest_my_case/base/context_writer_spec.rb +23 -0
  23. data/spec/rest_my_case/base/dependencies_spec.rb +14 -0
  24. data/spec/rest_my_case/base/invoke!_spec.rb +140 -0
  25. data/spec/rest_my_case/base/invoke_spec.rb +29 -0
  26. data/spec/rest_my_case/{base_spec.rb → base/perform_spec.rb} +0 -226
  27. data/spec/rest_my_case/base/required_context_spec.rb +33 -0
  28. data/spec/rest_my_case/context/status_spec.rb +2 -2
  29. data/spec/rest_my_case/status_spec.rb +6 -6
  30. data/spec/support/required_context.rb +49 -0
  31. metadata +42 -24
@@ -8,7 +8,7 @@ describe RestMyCase::Context::Status do
8
8
  it 'raises error' do
9
9
  expect do
10
10
  context.status = 'not_found'
11
- end.to raise_error
11
+ end.to raise_error('status is a reserved keyword which cannot be set')
12
12
  end
13
13
  end
14
14
 
@@ -18,7 +18,7 @@ describe RestMyCase::Context::Status do
18
18
  describe '#method_missing' do
19
19
  context "given that no method was previously called" do
20
20
  it 'calling an unknown_method should raise an error' do
21
- expect { @status.unknown_method }.to raise_error
21
+ expect { @status.unknown_method }.to raise_error NoMethodError
22
22
  end
23
23
 
24
24
  it '#ok? should be true' do
@@ -66,8 +66,8 @@ describe RestMyCase::Status do
66
66
  expect(@context.status.internal_server_error?).to be true
67
67
  end
68
68
 
69
- it "@context.next_line should raise an error" do
70
- expect { context.next_line }.to raise_error
69
+ it "@context.next_line should be nil" do
70
+ expect(@context.next_line).to be nil
71
71
  end
72
72
 
73
73
  it "@context.status.ok? should be false" do
@@ -94,8 +94,8 @@ describe RestMyCase::Status do
94
94
  expect(@context.status.internal_server_error?).to be true
95
95
  end
96
96
 
97
- it "@context.next_line should raise an error" do
98
- expect { context.next_line }.to raise_error
97
+ it "@context.next_line should be nil" do
98
+ expect(@context.next_line).to be nil
99
99
  end
100
100
 
101
101
  it "@context.status.ok? should be false" do
@@ -150,8 +150,8 @@ describe RestMyCase::Status do
150
150
  expect(@context.status.internal_server_error?).to be true
151
151
  end
152
152
 
153
- it "@context.next_line should be true" do
154
- expect { context.next_line }.to raise_error
153
+ it "@context.next_line should be nil" do
154
+ expect(@context.next_line).to be nil
155
155
  end
156
156
 
157
157
  it "@context.status.ok? should be false" do
@@ -0,0 +1,49 @@
1
+ module RequiredContext
2
+
3
+ module Users
4
+ class GetCurrentUser < RestMyCase::Base
5
+ required_context [
6
+ :current_user
7
+ ]
8
+ def setup
9
+ context.current_user = Object.new
10
+ end
11
+ end
12
+ end
13
+
14
+ module Posts
15
+ class FindOne < RestMyCase::Base
16
+ required_context [
17
+ :id
18
+ ]
19
+
20
+ def perform
21
+ context.post = OpenStruct.new id: context.id
22
+ end
23
+ end
24
+
25
+ class AssignAttributes < RestMyCase::Base
26
+ required_context \
27
+ :post,
28
+ :post_attributes
29
+
30
+ def perform
31
+ context.post.assign_attributes context.post_attributes
32
+ end
33
+ end
34
+
35
+ class Save < RestMyCase::Base
36
+ required_context \
37
+ :post
38
+
39
+ def perform
40
+ context.post.save
41
+ end
42
+ end
43
+
44
+ class Update < RestMyCase::Base
45
+ depends FindOne, AssignAttributes, Save
46
+ end
47
+ end
48
+
49
+ end
metadata CHANGED
@@ -1,100 +1,100 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_my_case
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.9
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - goncalvesjoao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-25 00:00:00.000000000 Z
11
+ date: 2016-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.2'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0.30'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.30'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0.9'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.9'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: codeclimate-test-reporter
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0.4'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.4'
97
- description: Very light Ruby gem with everything you need in a "The Clean Architecture"
97
+ description: Light Ruby gem with everything you need in a "The Clean Architecture"
98
98
  use case scenario
99
99
  email:
100
100
  - goncalves.joao@gmail.com
@@ -102,10 +102,10 @@ executables: []
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
- - .gitignore
106
- - .rspec
107
- - .rubocop.yml
108
- - .travis.yml
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".rubocop.yml"
108
+ - ".travis.yml"
109
109
  - Gemfile
110
110
  - LICENSE
111
111
  - README.md
@@ -128,6 +128,8 @@ files:
128
128
  - lib/rest_my_case/context/errors/base.rb
129
129
  - lib/rest_my_case/context/errors/status.rb
130
130
  - lib/rest_my_case/context/http_status.rb
131
+ - lib/rest_my_case/context/schema_validator/base.rb
132
+ - lib/rest_my_case/context/schema_validator/compel.rb
131
133
  - lib/rest_my_case/context/status.rb
132
134
  - lib/rest_my_case/defense_attorney/base.rb
133
135
  - lib/rest_my_case/errors/abort.rb
@@ -147,7 +149,14 @@ files:
147
149
  - spec/rest_my_case/accusation_attorneys/format_spec.rb
148
150
  - spec/rest_my_case/accusation_attorneys/length_spec.rb
149
151
  - spec/rest_my_case/accusation_attorneys/numericality_spec.rb
150
- - spec/rest_my_case/base_spec.rb
152
+ - spec/rest_my_case/base/context_accessor_spec.rb
153
+ - spec/rest_my_case/base/context_reader_spec.rb
154
+ - spec/rest_my_case/base/context_writer_spec.rb
155
+ - spec/rest_my_case/base/dependencies_spec.rb
156
+ - spec/rest_my_case/base/invoke!_spec.rb
157
+ - spec/rest_my_case/base/invoke_spec.rb
158
+ - spec/rest_my_case/base/perform_spec.rb
159
+ - spec/rest_my_case/base/required_context_spec.rb
151
160
  - spec/rest_my_case/context/status_spec.rb
152
161
  - spec/rest_my_case/defense_attorney/base_spec.rb
153
162
  - spec/rest_my_case/http_status_spec.rb
@@ -157,6 +166,7 @@ files:
157
166
  - spec/spec_helper.rb
158
167
  - spec/support/defense_attorney.rb
159
168
  - spec/support/perform.rb
169
+ - spec/support/required_context.rb
160
170
  - spec/support/rest_my_case_base.rb
161
171
  - spec/support/validator/models/ruby_post.rb
162
172
  - spec/support/validator/models/ruby_post_with_comments.rb
@@ -176,17 +186,17 @@ require_paths:
176
186
  - lib
177
187
  required_ruby_version: !ruby/object:Gem::Requirement
178
188
  requirements:
179
- - - ! '>='
189
+ - - ">="
180
190
  - !ruby/object:Gem::Version
181
191
  version: '0'
182
192
  required_rubygems_version: !ruby/object:Gem::Requirement
183
193
  requirements:
184
- - - ! '>='
194
+ - - ">="
185
195
  - !ruby/object:Gem::Version
186
196
  version: '0'
187
197
  requirements: []
188
198
  rubyforge_project:
189
- rubygems_version: 2.4.2
199
+ rubygems_version: 2.4.5
190
200
  signing_key:
191
201
  specification_version: 4
192
202
  summary: Quick and light "The Clean Architecture" use case implementation.
@@ -196,7 +206,14 @@ test_files:
196
206
  - spec/rest_my_case/accusation_attorneys/format_spec.rb
197
207
  - spec/rest_my_case/accusation_attorneys/length_spec.rb
198
208
  - spec/rest_my_case/accusation_attorneys/numericality_spec.rb
199
- - spec/rest_my_case/base_spec.rb
209
+ - spec/rest_my_case/base/context_accessor_spec.rb
210
+ - spec/rest_my_case/base/context_reader_spec.rb
211
+ - spec/rest_my_case/base/context_writer_spec.rb
212
+ - spec/rest_my_case/base/dependencies_spec.rb
213
+ - spec/rest_my_case/base/invoke!_spec.rb
214
+ - spec/rest_my_case/base/invoke_spec.rb
215
+ - spec/rest_my_case/base/perform_spec.rb
216
+ - spec/rest_my_case/base/required_context_spec.rb
200
217
  - spec/rest_my_case/context/status_spec.rb
201
218
  - spec/rest_my_case/defense_attorney/base_spec.rb
202
219
  - spec/rest_my_case/http_status_spec.rb
@@ -206,6 +223,7 @@ test_files:
206
223
  - spec/spec_helper.rb
207
224
  - spec/support/defense_attorney.rb
208
225
  - spec/support/perform.rb
226
+ - spec/support/required_context.rb
209
227
  - spec/support/rest_my_case_base.rb
210
228
  - spec/support/validator/models/ruby_post.rb
211
229
  - spec/support/validator/models/ruby_post_with_comments.rb