minitest-naga 0.1.2 → 0.1.3

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: f8fdc37db65f493144f8d740e495179b620c8a83
4
- data.tar.gz: 2bd8b2aa42218780fd40a72435b425691f594ac5
3
+ metadata.gz: 8812dabfffedd37eba2753fef73646067675c3d8
4
+ data.tar.gz: 3f2a8ae3538d955036d13ba3b2cab665f366fca6
5
5
  SHA512:
6
- metadata.gz: ebc7a303f750a3140854dbeb5a41411ca96f92fbf3264b7bfe379dc46fdd98a55ccb818898185a9272290e3ec9f905de86cce9c6ff45302c1c535a051883fa6f
7
- data.tar.gz: 1bfd2b7c9cd11b260f13dd639cb0fd27ce56739b7737595f372c46f181853eadca3613fe12c663b9c2e4a6957ade1ecb437a598e7422c952112516f9c46eb411
6
+ metadata.gz: a2a4f0560d1942fa933c9786c54f86c5bd1de99b991e0578ff49828f1408aa86ffb17cac16bd145a49bcc5a7ee79b8c542fabbdb2667e1bd9cb30ce91cae91b3
7
+ data.tar.gz: ebc04d1444a883da077926a0a03b04767a0db9d0a84f90b3a99668f64a417798c0458d613ffa2907ab610fcd8fb076878e6980406cdca0baa545e18d689c6105
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minitest-naga (0.1.2)
4
+ minitest-naga (0.1.3)
5
5
  colorize
6
6
  highline
7
7
  httparty
@@ -16,6 +16,8 @@ GEM
16
16
  minitest (~> 5.1)
17
17
  thread_safe (~> 0.3, >= 0.3.4)
18
18
  tzinfo (~> 1.1)
19
+ addressable (2.5.2)
20
+ public_suffix (>= 2.0.2, < 4.0)
19
21
  aruba (0.14.3)
20
22
  childprocess (~> 0.8.0)
21
23
  contracts (~> 0.9)
@@ -30,6 +32,8 @@ GEM
30
32
  colorize (0.8.1)
31
33
  concurrent-ruby (1.0.5)
32
34
  contracts (0.16.0)
35
+ crack (0.4.3)
36
+ safe_yaml (~> 1.0.0)
33
37
  cucumber (3.1.0)
34
38
  builder (>= 2.1.2)
35
39
  cucumber-core (~> 3.1.0)
@@ -49,8 +53,9 @@ GEM
49
53
  diff-lcs (1.3)
50
54
  ffi (1.9.21)
51
55
  gherkin (5.0.0)
56
+ hashdiff (0.3.7)
52
57
  highline (1.7.10)
53
- httparty (0.16.0)
58
+ httparty (0.16.2)
54
59
  multi_xml (>= 0.5.2)
55
60
  i18n (0.9.5)
56
61
  concurrent-ruby (~> 1.0)
@@ -58,6 +63,7 @@ GEM
58
63
  multi_json (1.13.1)
59
64
  multi_test (0.1.2)
60
65
  multi_xml (0.6.0)
66
+ public_suffix (3.0.2)
61
67
  rake (10.5.0)
62
68
  rspec (3.7.0)
63
69
  rspec-core (~> 3.7.0)
@@ -72,10 +78,15 @@ GEM
72
78
  diff-lcs (>= 1.2.0, < 2.0)
73
79
  rspec-support (~> 3.7.0)
74
80
  rspec-support (3.7.1)
81
+ safe_yaml (1.0.4)
75
82
  thor (0.20.0)
76
83
  thread_safe (0.3.6)
77
84
  tzinfo (1.2.5)
78
85
  thread_safe (~> 0.1)
86
+ webmock (3.3.0)
87
+ addressable (>= 2.3.6)
88
+ crack (>= 0.3.2)
89
+ hashdiff
79
90
 
80
91
  PLATFORMS
81
92
  ruby
@@ -88,6 +99,7 @@ DEPENDENCIES
88
99
  minitest-naga!
89
100
  rake (~> 10.0)
90
101
  rspec (~> 3.0)
102
+ webmock
91
103
 
92
104
  BUNDLED WITH
93
105
  1.16.1
data/README.md CHANGED
@@ -87,13 +87,17 @@ end
87
87
 
88
88
  To use Naga, just run your test file with the `--naga` flag:
89
89
 
90
- $ ruby a_file_with_lots_of_minitests.rb --naga
90
+ $ ruby -Ilib:test a_file_with_lots_of_minitests.rb --naga
91
+
92
+ Alternatively, if you have a directory of test files e.g. in a Rails app:
93
+
94
+ $ ruby -Ilib:test test/controllers/* --naga
91
95
 
92
96
  For first timers, you'll be asked to enter your email and password. If you've signed in before, it'll continue to run with that account unless you sign out (see below). Once you've successfully done that, you'll be taken on a weird adventure. So I hope you have fun!
93
97
 
94
98
  If you don't want to use Naga when running your test suite, just omit the flag like so:
95
99
 
96
- $ ruby a_file_with_lots_of_minitests.rb
100
+ $ ruby -Ilib:test a_file_with_lots_of_minitests.rb
97
101
 
98
102
  ### To Sign Out
99
103
 
@@ -165,13 +165,13 @@ class Game
165
165
 
166
166
  def completed_beginning?
167
167
  options = { headers: { "Content-Type" => "application/json" } }
168
- url = NagaApi.BASE_URL + "users/beginning?authentication_token=" + @credentials[:authentication_token] + "&email=" + @credentials[:email]
168
+ url = NagaApiClient.BASE_URL + "users/beginning?authentication_token=" + @credentials[:authentication_token] + "&email=" + @credentials[:email]
169
169
  response = HTTParty.get(url, options)
170
170
  response.parsed_response["beginning"]
171
171
  end
172
172
 
173
173
  def completed_beginning
174
- url = NagaApi.BASE_URL + "/users/beginning"
174
+ url = NagaApiClient.BASE_URL + "/users/beginning"
175
175
  options = { headers: { "Content-Type" => "application/x-www-form-urlencoded" } }
176
176
  options[:body] = "email=" + @credentials[:email] + "&authentication_token=" + @credentials[:authentication_token]
177
177
  response = HTTParty.post(url, options)
@@ -182,7 +182,7 @@ class Game
182
182
  end
183
183
 
184
184
  def run
185
- url = NagaApi.BASE_URL + "/users/run"
185
+ url = NagaApiClient.BASE_URL + "/users/run"
186
186
  options = { headers: { "Content-Type" => "application/x-www-form-urlencoded" } }
187
187
  options[:body] = "email=" + @credentials[:email] + "&authentication_token=" + @credentials[:authentication_token]
188
188
  response = HTTParty.post(url, options)
@@ -195,7 +195,7 @@ class Game
195
195
  if response["warning"] == "Runs available"
196
196
  if response["level_up"]
197
197
  puts "You just grew a level!".colorize(:black).colorize( :background => :green )
198
- puts "You are now " + parsed_response["level"]["number"] + " and have " + parsed_response["level"]["xp"] + "."
198
+ puts "You are now " + response["level"]["number"] + " and have " + response["level"]["xp"] + "."
199
199
  end
200
200
  puts "Level #{level["number"]} (#{level["name"]})".colorize(:blue)
201
201
  puts "#{level["xp"]} XP / #{level["total_xp"]} XP".colorize(:green)
@@ -2,7 +2,7 @@ class Inventory
2
2
  # public class methods
3
3
  class << self
4
4
  def add_to_desk(item, credentials)
5
- url = NagaApi.BASE_URL + "inventory/desk/add"
5
+ url = NagaApiClient.BASE_URL + "inventory/desk/add"
6
6
  options = { headers: { "Content-Type" => "application/x-www-form-urlencoded" } }
7
7
  options[:body] = "email=" + credentials[:email] + "&authentication_token=" + credentials[:authentication_token] + "&item_id=" + item.id.to_s
8
8
  response = HTTParty.post(url, options)
@@ -10,7 +10,7 @@ class Inventory
10
10
  end
11
11
 
12
12
  def add(item, credentials)
13
- url = NagaApi.BASE_URL + "inventory/add"
13
+ url = NagaApiClient.BASE_URL + "inventory/add"
14
14
  options = { headers: { "Content-Type" => "application/x-www-form-urlencoded" } }
15
15
  options[:body] = "email=" + credentials[:email] + "&authentication_token=" + credentials[:authentication_token] + "&item_id=" + item.id.to_s
16
16
  response = HTTParty.post(url, options)
@@ -17,7 +17,7 @@ class Item
17
17
  class << self
18
18
  def all(credentials)
19
19
  options = { headers: { "Content-Type" => "application/json" } }
20
- url = NagaApi.BASE_URL + "items?" + "authentication_token=" + credentials[:authentication_token] + "&email=" + credentials[:email]
20
+ url = NagaApiClient.BASE_URL + "items?" + "authentication_token=" + credentials[:authentication_token] + "&email=" + credentials[:email]
21
21
  response = HTTParty.get(url, options)
22
22
  items = {}
23
23
  response.parsed_response["items"].each do |i|
@@ -29,7 +29,7 @@ class Item
29
29
 
30
30
  def get(name, credentials)
31
31
  options = { headers: { "Content-Type" => "application/json" } }
32
- url = NagaApi.BASE_URL + "items/show/" + URI::encode(name) + "?authentication_token=" + credentials[:authentication_token] + "&email=" + credentials[:email]
32
+ url = NagaApiClient.BASE_URL + "items/show/" + URI::encode(name) + "?authentication_token=" + credentials[:authentication_token] + "&email=" + credentials[:email]
33
33
  response = HTTParty.get(url, options)
34
34
  i = response.parsed_response["item"]
35
35
  item = Item.new(i["id"], i["name"], i["description"], i["level"], i["colour"])
@@ -37,7 +37,7 @@ class Item
37
37
 
38
38
  def drop(credentials)
39
39
  options = { headers: { "Content-Type" => "application/json" } }
40
- url = NagaApi.BASE_URL + "items/drop/?authentication_token=" + credentials[:authentication_token] + "&email=" + credentials[:email]
40
+ url = NagaApiClient.BASE_URL + "items/drop/?authentication_token=" + credentials[:authentication_token] + "&email=" + credentials[:email]
41
41
  response = HTTParty.get(url, options)
42
42
  i = response.parsed_response["item"]
43
43
  if i
@@ -49,7 +49,7 @@ class Item
49
49
 
50
50
  def starter(credentials)
51
51
  options = { headers: { "Content-Type" => "application/json" } }
52
- url = NagaApi.BASE_URL + "items/starter?" + "authentication_token=" + credentials[:authentication_token] + "&email=" + credentials[:email]
52
+ url = NagaApiClient.BASE_URL + "items/starter?" + "authentication_token=" + credentials[:authentication_token] + "&email=" + credentials[:email]
53
53
  response = HTTParty.get(url, options)
54
54
  starter_items = {}
55
55
  response.parsed_response["starter_items"].each do |i|
@@ -22,7 +22,7 @@ class Achievement
22
22
  class << self
23
23
  def locked_achievements(credentials)
24
24
  options = { headers: { "Content-Type" => "application/json" } }
25
- url = NagaApi.BASE_URL + "achievements?" + "authentication_token=" + credentials[:authentication_token] + "&email=" + credentials[:email]
25
+ url = NagaApiClient.BASE_URL + "achievements?" + "authentication_token=" + credentials[:authentication_token] + "&email=" + credentials[:email]
26
26
  response = HTTParty.get(url, options)
27
27
  locked_achievements = {}
28
28
  response.parsed_response["locked_achievements"].each do |locked_achievement|
@@ -35,7 +35,7 @@ class Achievement
35
35
 
36
36
  # public instance methods
37
37
  def unlock(credentials)
38
- url = NagaApi.BASE_URL + "achievements/unlock"
38
+ url = NagaApiClient.BASE_URL + "achievements/unlock"
39
39
  options = { headers: { "Content-Type" => "application/x-www-form-urlencoded" } }
40
40
  options[:body] = "email=" + credentials[:email] + "&authentication_token=" + credentials[:authentication_token] + "&achievement_id=" + self.id.to_s
41
41
  response = HTTParty.post(url, options)
@@ -1,19 +1,57 @@
1
1
  require "thor"
2
2
  require "minitest/naga"
3
- require_relative "naga_api"
3
+ require_relative "naga_api_client"
4
4
 
5
5
  module Minitest
6
6
  module Naga
7
7
  class CLI < Thor
8
- desc "about", "A little information about minitest-naga"
8
+ desc "about", "A little information about minitest-naga."
9
9
  def about
10
- puts "minitest-naga is created by Wen Ting Wang."
10
+ puts "minitest-naga is created by Wen Ting Wang as part of their final dissertation."
11
11
  end
12
12
 
13
- desc "signout", "Sign out of Naga"
13
+ desc "wut", "wut"
14
+ def wut
15
+ puts "wut"*10
16
+ end
17
+
18
+ desc "hi", "hi"
19
+ def hi
20
+ puts "hi"*10
21
+ end
22
+
23
+ desc "rand", "Randomize me."
24
+ def rand
25
+ puts [
26
+ "Batman is cool.",
27
+ "When I finish cleaning whilst wearing rubber gloves, I use handwash to clean the gloves.",
28
+ "I was listening to OneRepublic - Good Life, while writing this.",
29
+ "Wobble wobble.",
30
+ "Howdy!",
31
+ "Why are you using this command? Shouldn't you be unit testing?",
32
+ "'The night is darkest just before the dawn. I promise you, dawn is coming.'",
33
+ "Sup?",
34
+ "<ENTER SOMETHING RANDOM AND SILLY>",
35
+ "Unagi!",
36
+ "Salmon skin roll!",
37
+ "I can count to 3. 1, 2, 3!",
38
+ "Why Naga you ask? Well, this creator here watched a TV show called the Legend of Korra. Korra, the main character, has a polar-bear-dog called Naga and well basically I want one. So the system is codenamed Naga. I say codenamed because I'm pretty much waiting for someone to tell me off and say 'Hey missy, you ain't allowed to use the name Naga! I own it!'. So until that day comes, Naga it is.",
39
+ "Everything will be okay."
40
+ ].sample
41
+ end
42
+
43
+ desc "ty", "Thank you."
44
+ def ty
45
+ puts "Thank you so much for using Naga! If it has been even the tiniest bit fun for you, then that makes me really happy. If you actually liked it even a little bit, then that makes me even happier. K, bye. *creator flies away*"
46
+ puts "- Ting"
47
+ end
48
+
49
+ desc "signout", "Sign out of Naga."
14
50
  def signout
15
- File.delete(NagaApi.FILE_PATH)
16
- puts "Signed out."
51
+ if File.file?(NagaApiClient.FILE_PATH)
52
+ File.delete(NagaApiClient.FILE_PATH)
53
+ puts "Signed out."
54
+ end
17
55
  end
18
56
  end
19
57
  end
@@ -1,4 +1,4 @@
1
- class NagaApi
1
+ class NagaApiClient
2
2
  # @@BASE_URL = "http://localhost:3000/api/v1/"
3
3
  @@BASE_URL = "https://naga-unit-testing.herokuapp.com/api/v1/"
4
4
  @@FILE_PATH = File.join(Dir.home, ".minitest_naga")
@@ -3,9 +3,9 @@ module Minitest
3
3
  def report
4
4
  super
5
5
  return unless options[:naga]
6
- puts "=" *80
6
+ puts "\n=" *80
7
7
  puts "Naga"
8
- naga_api = NagaApi.new
8
+ naga_api = NagaApiClient.new
9
9
  detector = Detector.new(naga_api.credentials)
10
10
  puts "=" *80
11
11
  detector.my_first_time
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Naga
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
@@ -3,12 +3,20 @@ require "httparty"
3
3
  require "colorize"
4
4
  require "colorized_string"
5
5
  require "uri"
6
- Dir[File.join(__dir__, 'naga', '*.rb')].each {|file| require_relative file }
7
- Dir[File.join(__dir__, 'game', '*.rb')].each {|file| require_relative file }
6
+ require_relative "naga/achievement"
7
+ require_relative "naga/cli"
8
+ require_relative "naga/detector"
9
+ require_relative "naga/naga_api_client"
10
+ require_relative "naga/naga_reporter"
11
+ require_relative "game/game"
12
+ require_relative "game/inventory"
13
+ require_relative "game/item"
14
+ require_relative "game/location"
15
+ require_relative "game/place"
8
16
 
9
17
  module Minitest
10
18
  def self.plugin_naga_options(opts, options)
11
- opts.on "--naga", "Run tests with Naga" do
19
+ opts.on "--naga", "Run tests with Naga." do
12
20
  options[:naga] = true
13
21
  end
14
22
  end
@@ -10,6 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["wtwang1@sheffield.ac.uk"]
11
11
 
12
12
  spec.summary = %q{A minitest extension which lets you unlock achievements and collect loot when you run your test suite.}
13
+ spec.description = %q{This gem is one half of the gamification system, codenamed "Naga", for unit testing created for my dissertation project. It works in hand with the web application accessible at https://naga-unit-testing.herokuapp.com/.}
13
14
  spec.homepage = "https://github.com/wtwang1/minitest-naga"
14
15
  spec.license = "MIT"
15
16
 
@@ -35,6 +36,7 @@ Gem::Specification.new do |spec|
35
36
  spec.add_development_dependency "activesupport", "~> 4.2.0"
36
37
  spec.add_development_dependency "cucumber"
37
38
  spec.add_development_dependency "aruba"
39
+ spec.add_development_dependency "webmock"
38
40
 
39
41
  spec.add_dependency "thor"
40
42
  spec.add_dependency "minitest"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-naga
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wen Ting Wang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-18 00:00:00.000000000 Z
11
+ date: 2018-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: thor
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -164,7 +178,9 @@ dependencies:
164
178
  - - ">="
165
179
  - !ruby/object:Gem::Version
166
180
  version: '0'
167
- description:
181
+ description: This gem is one half of the gamification system, codenamed "Naga", for
182
+ unit testing created for my dissertation project. It works in hand with the web
183
+ application accessible at https://naga-unit-testing.herokuapp.com/.
168
184
  email:
169
185
  - wtwang1@sheffield.ac.uk
170
186
  executables:
@@ -195,7 +211,7 @@ files:
195
211
  - lib/minitest/naga/achievement.rb
196
212
  - lib/minitest/naga/cli.rb
197
213
  - lib/minitest/naga/detector.rb
198
- - lib/minitest/naga/naga_api.rb
214
+ - lib/minitest/naga/naga_api_client.rb
199
215
  - lib/minitest/naga/naga_reporter.rb
200
216
  - lib/minitest/naga/version.rb
201
217
  - lib/minitest/naga_plugin.rb