cm_quiz 0.0.2 → 0.0.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 +4 -4
- data/Gemfile.lock +4 -4
- data/README.md +22 -5
- data/lib/cm_quiz/cli.rb +2 -0
- data/lib/cm_quiz/factory/idea.rb +2 -0
- data/lib/cm_quiz/factory/user.rb +2 -0
- data/lib/cm_quiz/review/base_review.rb +5 -0
- data/lib/cm_quiz/review/create_idea.rb +2 -2
- data/lib/cm_quiz/review/delete_idea.rb +3 -2
- data/lib/cm_quiz/review/get_ideas.rb +2 -12
- data/lib/cm_quiz/review/get_user_info.rb +2 -2
- data/lib/cm_quiz/review/login_user.rb +2 -0
- data/lib/cm_quiz/review/sign_up_user.rb +2 -2
- data/lib/cm_quiz/review/update_idea.rb +3 -12
- data/lib/cm_quiz/review_helper.rb +0 -4
- data/lib/cm_quiz/review_quiz.rb +9 -3
- data/lib/cm_quiz/version.rb +1 -1
- data/spec/lib/cm_quiz/review/create_idea_spec.rb +1 -14
- data/spec/lib/cm_quiz/review/delete_idea_spec.rb +1 -8
- data/spec/lib/cm_quiz/review/get_ideas_spec.rb +1 -11
- data/spec/lib/cm_quiz/review/get_user_info_spec.rb +1 -8
- data/spec/lib/cm_quiz/review/login_user_spec.rb +1 -1
- data/spec/lib/cm_quiz/review/sign_up_user_spec.rb +1 -1
- data/spec/lib/cm_quiz/review/update_idea_spec.rb +1 -14
- data/spec/spec_helper.rb +7 -1
- data/spec/support/assert_test_case.rb +12 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05e2c72f987b0c04158a61993591da384cd1f0e5
|
4
|
+
data.tar.gz: 847897a6eab4c72fc4f84f12a4af4a80187b281e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6e1caeeb432906d67a89bb1d4a8a493e1de93d854d89923e74014602e825de3ec86aa8352f88f9b1bdcce7dfbf42492fea95df20e90c1439467c4249132d60c
|
7
|
+
data.tar.gz: 087e45d145073f562af0f6be931ee5b1ecee092c9bc31417521da847292614f398f2318532aa4b436833c7cf61681901f276923317735492ab25371dc1732cb4
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cm_quiz (0.0.
|
5
|
-
httparty
|
6
|
-
rspec
|
4
|
+
cm_quiz (0.0.2)
|
5
|
+
httparty (~> 0.15.6)
|
6
|
+
rspec (~> 3.6)
|
7
7
|
thor (~> 0.19.4)
|
8
8
|
|
9
9
|
GEM
|
@@ -52,7 +52,7 @@ PLATFORMS
|
|
52
52
|
DEPENDENCIES
|
53
53
|
cm_quiz!
|
54
54
|
pry
|
55
|
-
webmock
|
55
|
+
webmock (~> 3.0)
|
56
56
|
|
57
57
|
BUNDLED WITH
|
58
58
|
1.15.0
|
data/README.md
CHANGED
@@ -1,15 +1,32 @@
|
|
1
1
|
# cm-quiz
|
2
|
+
> A CLI tool to review your CodementorX project
|
2
3
|
|
3
|
-
##
|
4
|
+
## Installation💻
|
5
|
+
Make sure you have a working Ruby environment (2.3 or later is required).
|
4
6
|
|
7
|
+
### Install Ruby using [RVM](https://rvm.io/) (for those with older versions of Ruby)
|
5
8
|
```sh
|
6
9
|
$ ruby -v
|
7
|
-
# Make sure your
|
10
|
+
# Make sure your Ruby version is at least 2.3.0, below will demo how to install required Ruby version
|
8
11
|
|
12
|
+
$ curl -sSL https://get.rvm.io | bash -s stable
|
13
|
+
|
14
|
+
# restart your terminal
|
15
|
+
|
16
|
+
$ rvm install 2.3.0
|
17
|
+
$ rvm use 2.3.0
|
18
|
+
```
|
19
|
+
|
20
|
+
|
21
|
+
### Install `cm-quiz`
|
22
|
+
```sh
|
9
23
|
$ gem install cm_quiz
|
10
24
|
```
|
11
25
|
|
12
|
-
|
26
|
+
|
27
|
+
## Start review your quiz🕵️
|
13
28
|
```sh
|
14
|
-
$ cm-quiz test --endpoint=your-test-endpoint.com
|
15
|
-
```
|
29
|
+
$ cm-quiz test --endpoint=https://your-test-endpoint.com
|
30
|
+
```
|
31
|
+
|
32
|
+
|
data/lib/cm_quiz/cli.rb
CHANGED
data/lib/cm_quiz/factory/idea.rb
CHANGED
data/lib/cm_quiz/factory/user.rb
CHANGED
@@ -3,6 +3,7 @@ require 'cm_quiz/review_helper'
|
|
3
3
|
module CmQuiz
|
4
4
|
module Review
|
5
5
|
class BaseReview
|
6
|
+
attr_reader :verb, :path, :options
|
6
7
|
include ReviewHelper
|
7
8
|
|
8
9
|
def perform
|
@@ -18,6 +19,10 @@ module CmQuiz
|
|
18
19
|
raise "Method `run` should be implemented on class #{self.class}"
|
19
20
|
end
|
20
21
|
|
22
|
+
def build_test_result(test_case, passed = true, message = nil)
|
23
|
+
[test_case, passed, message]
|
24
|
+
end
|
25
|
+
|
21
26
|
def test_request
|
22
27
|
{
|
23
28
|
verb: @verb,
|
@@ -30,7 +30,7 @@ module CmQuiz
|
|
30
30
|
private
|
31
31
|
|
32
32
|
def send_create_idea_request(jwt:, content:, impact:, ease:, confidence:)
|
33
|
-
options = {
|
33
|
+
@options = {
|
34
34
|
headers: {
|
35
35
|
'x-access-token' => jwt
|
36
36
|
},
|
@@ -42,7 +42,7 @@ module CmQuiz
|
|
42
42
|
}
|
43
43
|
}
|
44
44
|
|
45
|
-
@project_api.request(@verb, @path, options)
|
45
|
+
@project_api.request(@verb, @path, @options)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -27,13 +27,14 @@ module CmQuiz
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def send_delete_idea_request(jwt:, idea_id:)
|
30
|
-
options = {
|
30
|
+
@options = {
|
31
31
|
headers: {
|
32
32
|
'x-access-token' => jwt
|
33
33
|
}
|
34
34
|
}
|
35
35
|
|
36
|
-
@
|
36
|
+
@path = "/ideas/#{idea_id}"
|
37
|
+
@project_api.request(:delete, @path, @options)
|
37
38
|
end
|
38
39
|
|
39
40
|
def send_get_ideas_request(jwt:)
|
@@ -46,18 +46,8 @@ module CmQuiz
|
|
46
46
|
|
47
47
|
private
|
48
48
|
|
49
|
-
def send_delete_idea_request(jwt:, idea_id:)
|
50
|
-
options = {
|
51
|
-
headers: {
|
52
|
-
'x-access-token' => jwt
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
@project_api.request(:delete, "/ideas/#{idea_id}", options)
|
57
|
-
end
|
58
|
-
|
59
49
|
def send_get_ideas_request(jwt:, page: 1)
|
60
|
-
options = {
|
50
|
+
@options = {
|
61
51
|
headers: {
|
62
52
|
'x-access-token' => jwt
|
63
53
|
},
|
@@ -66,7 +56,7 @@ module CmQuiz
|
|
66
56
|
}
|
67
57
|
}
|
68
58
|
|
69
|
-
@project_api.request(@verb, @path, options)
|
59
|
+
@project_api.request(@verb, @path, @options)
|
70
60
|
end
|
71
61
|
end
|
72
62
|
end
|
@@ -30,13 +30,13 @@ module CmQuiz
|
|
30
30
|
private
|
31
31
|
|
32
32
|
def send_get_user_info_request(jwt:)
|
33
|
-
options = {
|
33
|
+
@options = {
|
34
34
|
headers: {
|
35
35
|
'x-access-token' => jwt
|
36
36
|
}
|
37
37
|
}
|
38
38
|
|
39
|
-
@project_api.request(@verb, @path, options)
|
39
|
+
@project_api.request(@verb, @path, @options)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -26,6 +26,8 @@ module CmQuiz
|
|
26
26
|
|
27
27
|
expect(payload['jwt'].class).to eq(String), '`jwt` should be string'
|
28
28
|
expect(payload['refresh_token'].class).to eq(String), '`refresh_token` should be string'
|
29
|
+
rescue => e
|
30
|
+
build_test_result(self.class, false, e.message)
|
29
31
|
end
|
30
32
|
|
31
33
|
private
|
@@ -28,7 +28,7 @@ module CmQuiz
|
|
28
28
|
private
|
29
29
|
|
30
30
|
def send_sign_up_user_request(email:, name:, password:)
|
31
|
-
options = {
|
31
|
+
@options = {
|
32
32
|
body: {
|
33
33
|
email: email,
|
34
34
|
name: name,
|
@@ -36,7 +36,7 @@ module CmQuiz
|
|
36
36
|
}
|
37
37
|
}
|
38
38
|
|
39
|
-
@project_api.request(@verb, @path, options)
|
39
|
+
@project_api.request(@verb, @path, @options)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -36,20 +36,10 @@ module CmQuiz
|
|
36
36
|
|
37
37
|
private
|
38
38
|
|
39
|
-
def send_delete_idea_request(jwt:, idea_id:)
|
40
|
-
options = {
|
41
|
-
headers: {
|
42
|
-
'x-access-token' => jwt
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
@project_api.request(:delete, "/ideas/#{idea_id}", options)
|
47
|
-
end
|
48
|
-
|
49
39
|
def send_update_idea_request(jwt:, idea_id:, content: nil, impact: nil,
|
50
40
|
ease: nil, confidence: nil)
|
51
41
|
|
52
|
-
options = {
|
42
|
+
@options = {
|
53
43
|
headers: {
|
54
44
|
'x-access-token' => jwt
|
55
45
|
},
|
@@ -60,8 +50,9 @@ module CmQuiz
|
|
60
50
|
confidence: confidence
|
61
51
|
}
|
62
52
|
}
|
53
|
+
@path = "/ideas/#{idea_id}"
|
63
54
|
|
64
|
-
@project_api.request(:put,
|
55
|
+
@project_api.request(:put, @path, @options)
|
65
56
|
end
|
66
57
|
|
67
58
|
end
|
data/lib/cm_quiz/review_quiz.rb
CHANGED
@@ -29,11 +29,17 @@ module CmQuiz
|
|
29
29
|
def build_message(test_results, endpoint)
|
30
30
|
score, failed_results = arrange_results(test_results)
|
31
31
|
example_messages = failed_results.map do |result|
|
32
|
-
# m = (result[0].to_s + ": " + result[2].to_s)
|
33
32
|
verb = result[0][:verb].upcase
|
34
33
|
path = result[0][:path]
|
35
34
|
options = result[0][:options]
|
36
|
-
|
35
|
+
passed = result[1]
|
36
|
+
messages = ["===#{verb} #{@endpoint}#{path}==="]
|
37
|
+
messages << ""
|
38
|
+
messages << "HTTP method:"
|
39
|
+
messages << verb
|
40
|
+
messages << ""
|
41
|
+
messages << "Url:"
|
42
|
+
messages << "#{@endpoint}#{path}"
|
37
43
|
messages << ""
|
38
44
|
messages << "Request options:"
|
39
45
|
messages << ""
|
@@ -43,7 +49,7 @@ module CmQuiz
|
|
43
49
|
messages << ""
|
44
50
|
error_message = result[2].to_s
|
45
51
|
error_message = error_message.truncate(500) + '...' if error_message.size > 500
|
46
|
-
messages << error_message
|
52
|
+
messages << error_message + "\n"
|
47
53
|
|
48
54
|
messages.join("\n")
|
49
55
|
end
|
data/lib/cm_quiz/version.rb
CHANGED
@@ -31,20 +31,7 @@ RSpec.describe CmQuiz::Review::CreateIdea do
|
|
31
31
|
it "should pass test" do
|
32
32
|
test_result = service.perform
|
33
33
|
|
34
|
-
|
35
|
-
options = {
|
36
|
-
headers: {
|
37
|
-
'x-access-token' => 'jwt'
|
38
|
-
},
|
39
|
-
body: {
|
40
|
-
content: mock_idea[:content],
|
41
|
-
impact: mock_idea[:impact],
|
42
|
-
ease: mock_idea[:ease],
|
43
|
-
confidence: mock_idea[:confidence]
|
44
|
-
}
|
45
|
-
}
|
46
|
-
args = [:post, '/ideas', options]
|
47
|
-
expect(project_api).to have_received(:request).with(*args)
|
34
|
+
assert_test_case(service, test_result)
|
48
35
|
end
|
49
36
|
end
|
50
37
|
end
|
@@ -34,14 +34,7 @@ RSpec.describe CmQuiz::Review::DeleteIdea do
|
|
34
34
|
it "should pass test" do
|
35
35
|
test_result = service.perform
|
36
36
|
|
37
|
-
|
38
|
-
options = {
|
39
|
-
headers: {
|
40
|
-
'x-access-token' => 'jwt'
|
41
|
-
}
|
42
|
-
}
|
43
|
-
args = [:delete, "/ideas/#{idea_id}", options]
|
44
|
-
expect(project_api).to have_received(:request).with(*args)
|
37
|
+
assert_test_case(service, test_result)
|
45
38
|
end
|
46
39
|
end
|
47
40
|
end
|
@@ -49,17 +49,7 @@ RSpec.describe CmQuiz::Review::GetIdeas do
|
|
49
49
|
it "should pass test" do
|
50
50
|
test_result = service.perform
|
51
51
|
|
52
|
-
|
53
|
-
options = {
|
54
|
-
headers: {
|
55
|
-
'x-access-token' => 'jwt'
|
56
|
-
},
|
57
|
-
query: {
|
58
|
-
page: 1
|
59
|
-
}
|
60
|
-
}
|
61
|
-
args = [:get, "/ideas", options]
|
62
|
-
expect(project_api).to have_received(:request).with(*args)
|
52
|
+
assert_test_case(service, test_result)
|
63
53
|
end
|
64
54
|
end
|
65
55
|
end
|
@@ -26,14 +26,7 @@ RSpec.describe CmQuiz::Review::GetUserInfo do
|
|
26
26
|
it "should pass test" do
|
27
27
|
test_result = service.perform
|
28
28
|
|
29
|
-
|
30
|
-
options = {
|
31
|
-
headers: {
|
32
|
-
'x-access-token' => 'jwt'
|
33
|
-
}
|
34
|
-
}
|
35
|
-
args = [:get, '/me', options]
|
36
|
-
expect(project_api).to have_received(:request).with(*args)
|
29
|
+
assert_test_case(service, test_result)
|
37
30
|
end
|
38
31
|
end
|
39
32
|
end
|
@@ -39,20 +39,7 @@ RSpec.describe CmQuiz::Review::UpdateIdea do
|
|
39
39
|
it "should pass test" do
|
40
40
|
test_result = service.perform
|
41
41
|
|
42
|
-
|
43
|
-
options = {
|
44
|
-
headers: {
|
45
|
-
'x-access-token' => 'jwt'
|
46
|
-
},
|
47
|
-
body: {
|
48
|
-
content: mock_idea[:content],
|
49
|
-
impact: mock_idea[:impact],
|
50
|
-
ease: mock_idea[:ease],
|
51
|
-
confidence: mock_idea[:confidence]
|
52
|
-
}
|
53
|
-
}
|
54
|
-
args = [:put, "/ideas/#{idea_id}", options]
|
55
|
-
expect(project_api).to have_received(:request).with(*args)
|
42
|
+
assert_test_case(service, test_result)
|
56
43
|
end
|
57
44
|
end
|
58
45
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift File.expand_path('../support', __FILE__)
|
4
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
3
5
|
|
4
6
|
require 'rubygems'
|
5
7
|
require 'webmock/rspec'
|
6
8
|
require 'cm_quiz'
|
7
|
-
require 'pry'
|
9
|
+
require 'pry'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.include AssertTestCase
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module AssertTestCase
|
2
|
+
def assert_test_case(service, test_result)
|
3
|
+
test_case = {
|
4
|
+
verb: service.verb,
|
5
|
+
path: service.path,
|
6
|
+
options: service.options
|
7
|
+
}
|
8
|
+
expect(test_result).to eq([test_case, true, nil])
|
9
|
+
args = [service.verb, service.path, service.options]
|
10
|
+
expect(project_api).to have_received(:request).with(*args)
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cm_quiz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ben
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- spec/lib/cm_quiz/review/sign_up_user_spec.rb
|
109
109
|
- spec/lib/cm_quiz/review/update_idea_spec.rb
|
110
110
|
- spec/spec_helper.rb
|
111
|
+
- spec/support/assert_test_case.rb
|
111
112
|
homepage: https://github.com/codementordev/cm_quiz
|
112
113
|
licenses:
|
113
114
|
- MIT
|