lita-estimate 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d04887b4c71293d42db3b4977754346b8a425ce
4
- data.tar.gz: 8b667c0dccdf5bd40bd9dabb3fd432c95c82ed8e
3
+ metadata.gz: ad344b1cdb4aa633161c6a85c6a23f4bb43bb6db
4
+ data.tar.gz: f3d41d7944d1a0cc24fc588f8305d4b1b52cff89
5
5
  SHA512:
6
- metadata.gz: a86fafa98a6cf0757adad7c27ea0dfc6eb033f9e27cad766ec83ef5894f2de78988de0e324d94df98e3290a2ade34677e0da102ab92d0e342b95c400ad983d6a
7
- data.tar.gz: 150157f64e780ce2d507106828951095adba5170115142700b9305c415926eecb9b48b2e08fcd8881dc09e93dc4267035da112143c08dc86fb7772c0eca167cb
6
+ metadata.gz: 0faf63327375d93f7feb54af5f3960e7495c76f3d1d4418c1d6109cad5abd9dfab916579c4d110ce250062b26eb4d1e4fee76fbcc23769c6d3413dca87d11028
7
+ data.tar.gz: b99c5d4444ec437e42730c7bccea4ca009fa6e22cde754ce2074c403ba319aecf51a01685a0e4d81210ce7f85710ce1165b00001e9928e9037ef3626e90eacae
@@ -19,19 +19,27 @@ module Lita
19
19
 
20
20
  def show_estimates(response)
21
21
  story = response.matches.flatten.first
22
- estimates = []
23
- redis.hgetall(key(story)).each do |estimator, estimate|
24
- response.reply("#{estimator}: #{estimate}")
25
- estimates << estimate.to_i
22
+ estimates = redis.hgetall(key(story))
23
+ if estimates.empty?
24
+ response.reply("No estimates yet for #{story}")
25
+ else
26
+ lines = []
27
+ estimates.keys.sort.each do |estimator|
28
+ lines << "#{estimator}: #{estimates[estimator]}"
29
+ end
30
+ average = estimates.values.inject(0){ |sum, e| sum + e.to_i }.to_f / estimates.size
31
+ lines << "Average: #{average}"
32
+ response.reply(lines.join("\n"))
26
33
  end
27
- average = estimates.inject{ |sum, e| sum + e }.to_f / estimates.size
28
- response.reply("Average: #{average}")
29
34
  end
30
35
 
31
36
  def show_estimators(response)
32
37
  story = response.matches.flatten.first
33
- redis.hgetall(key(story)).each do |estimator, estimate|
34
- response.reply(estimator)
38
+ estimates = redis.hgetall(key(story))
39
+ if estimates.empty?
40
+ response.reply("No estimators yet for #{story}")
41
+ else
42
+ response.reply(estimates.keys.sort.join("\n"))
35
43
  end
36
44
  end
37
45
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-estimate"
3
- spec.version = "0.1.4"
3
+ spec.version = "0.1.5"
4
4
  spec.authors = ["Ingo Weiss"]
5
5
  spec.email = ["ingo@ingoweiss.com"]
6
6
  spec.description = "Just a silly little Lita plugin for estimation"
@@ -38,47 +38,48 @@ describe Lita::Handlers::Estimate, lita_handler: true do
38
38
 
39
39
  describe "show estimates" do
40
40
 
41
- before(:each) do
41
+ it "should list estimates" do
42
42
  subject.redis.hset('estimate:US123', 'Peter', '5')
43
43
  subject.redis.hset('estimate:US123', 'Paula', '3')
44
- end
45
-
46
- it "should list estimates" do
47
44
  send_command('US123 estimates')
48
- expect(replies.to_set).to eq(Set[
45
+ expect(lines(replies.last)).to eq([
49
46
  "Paula: 3",
50
47
  "Peter: 5",
51
48
  "Average: 4.0"
52
49
  ])
53
50
  end
54
51
 
52
+ it "should show a message if no estimates are found" do
53
+ send_command('US456 estimates')
54
+ expect(replies.last).to eq('No estimates yet for US456')
55
+ end
56
+
55
57
  end
56
58
 
57
59
  describe "show estimators" do
58
60
 
59
- before(:each) do
60
- subject.redis.hset('estimate:US123', 'Peter', '5')
61
- subject.redis.hset('estimate:US123', 'Paula', '3')
62
- end
63
-
64
61
  it "should list estimates" do
62
+ subject.redis.hset('estimate:US123', 'Paula', '3')
63
+ subject.redis.hset('estimate:US123', 'Peter', '5')
65
64
  send_command('US123 estimators')
66
- expect(replies.to_set).to eq(Set[
65
+ expect(lines(replies.last)).to eq([
67
66
  "Paula",
68
67
  "Peter"
69
68
  ])
70
69
  end
71
70
 
71
+ it "should show a message if no estimates are found" do
72
+ send_command('US456 estimators')
73
+ expect(replies.last).to eq('No estimators yet for US456')
74
+ end
75
+
72
76
  end
73
77
 
74
78
  describe "reset estimates" do
75
79
 
76
- before(:each) do
80
+ it "should reset estimates" do
77
81
  subject.redis.hset('estimate:US123', 'Peter', '5')
78
82
  subject.redis.hset('estimate:US123', 'Paula', '3')
79
- end
80
-
81
- it "should reset estimates" do
82
83
  send_command('US123 estimates reset')
83
84
  expect(subject.redis.hgetall('estimate:US123')).to eq({})
84
85
  end
data/spec/spec_helper.rb CHANGED
@@ -13,3 +13,7 @@ require "lita/rspec"
13
13
  # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
14
14
  # was generated with Lita 4, the compatibility mode should be left disabled.
15
15
  Lita.version_3_compatibility_mode = false
16
+
17
+ def lines(multi_line_response)
18
+ multi_line_response.split("\n")
19
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-estimate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ingo Weiss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-28 00:00:00.000000000 Z
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita