peppers-ghost 0.0.1.alpha.1 → 0.0.1.alpha.2

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: fb4767e7fefac57d01e5c9e1bbde36cf7fb59870
4
- data.tar.gz: badd39258d23e417c1f1a133d4056287b4f383e3
3
+ metadata.gz: 94a0487465e84b597109a5bd3e600d09b9a02074
4
+ data.tar.gz: 14e78905b03618a3a8570c8d355fc6703734e708
5
5
  SHA512:
6
- metadata.gz: ee1667f92c9415f36181d25b8a6f1cc46ce9e472a51be55699e205f38caa1f0d241db565681facf3c27baea4fe0e5370a3610fb386a4cdf75f58c1cd340db99e
7
- data.tar.gz: 2a61937f5bb389aa2a3ddc43cd5316c673834bcd6a36bff1f11ae447ab2019995ffd91af236a3567e45c7f0534027b166834b3166301f27f9088b28ad12435e4
6
+ metadata.gz: 371331a815dbf3df8004981b5146ba3570813f99e8e95cf3366f361b2d33c17bd68170c3484d5426bec8a65dd253d0ad34f4f57bd032c81c6907b12cb8d96f74
7
+ data.tar.gz: daef6fad9568b0da290599042eab3dc32c6fe3721baed4f271e9698c8d308869d5d00e72b083bad1669544b3ecdfc40e86ab5cb5eba0f4be4bcf40b144c55288
data/lib/peppers-ghost.rb CHANGED
@@ -8,6 +8,7 @@ end
8
8
 
9
9
  require_relative 'peppers-ghost/ghost_factory'
10
10
  require_relative 'peppers-ghost/matchers'
11
+ require_relative 'peppers-ghost/frogger'
11
12
 
12
13
  RSpec.configure do |config|
13
14
  config.include PeppersGhost::Matchers, :json => true
@@ -0,0 +1,52 @@
1
+ class Frogger
2
+ class << self
3
+ def log_resource(resource, exists)
4
+ resource = resource.to_s.singularize.to_sym
5
+
6
+ frog[resource] ||= 0
7
+ frog[resource] += 1 if exists
8
+ end
9
+
10
+ def frog
11
+ @frog ||= {}
12
+ end
13
+
14
+ def eat_the_fly!
15
+ untested, tested = frog.partition do |key, value|
16
+ value == 0
17
+ end
18
+
19
+ tested = tested.sort_by(&:last).reverse
20
+
21
+ if untested.any?
22
+ puts formatted_message(tested, untested)
23
+ burp untested
24
+ end
25
+ end
26
+
27
+ def burp(untested)
28
+ pluralized_resource = 'resource'.pluralize(untested.count)
29
+ untested_list = untested.map(&:first).join(', ')
30
+
31
+ raise "Untested nested #{pluralized_resource}: #{untested_list}."
32
+ end
33
+
34
+ def formatted_message(tested, untested)
35
+ "\n\nTested: %s\nUntested: %s" % [
36
+ formatted_resources(tested),
37
+ formatted_resources(untested),
38
+ ]
39
+ end
40
+
41
+ def formatted_resources(resources)
42
+ mask = '%s (%d)'
43
+ resources.map { |resource| mask % resource }.join(', ')
44
+ end
45
+ end
46
+ end
47
+
48
+ RSpec.configure do |config|
49
+ config.after(:suite) do
50
+ Frogger.eat_the_fly!
51
+ end
52
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'peppers-ghost'
3
- s.version = '0.0.1.alpha.1'
3
+ s.version = '0.0.1.alpha.2'
4
4
 
5
5
  s.summary = 'Adds some helpers for testing api resources'
6
6
  s.description = %Q{
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peppers-ghost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha.1
4
+ version: 0.0.1.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Herrick
@@ -50,6 +50,7 @@ files:
50
50
  - lib/peppers-ghost.rb
51
51
  - lib/peppers-ghost/ghost_factory.rb
52
52
  - lib/peppers-ghost/matchers.rb
53
+ - lib/peppers-ghost/frogger.rb
53
54
  homepage: http://www.bitbucket.org/ToadJamb/gems-peppers-ghost
54
55
  licenses:
55
56
  - LGPLv3