trollolo 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +21 -2
  3. data/.rubocop_todo.yml +105 -270
  4. data/CHANGELOG.md +10 -0
  5. data/CONTRIBUTING.md +6 -4
  6. data/Gemfile +1 -1
  7. data/README.md +10 -1
  8. data/Rakefile +4 -4
  9. data/bin/trollolo +2 -2
  10. data/lib/backup.rb +21 -23
  11. data/lib/burndown_chart.rb +46 -49
  12. data/lib/burndown_data.rb +21 -21
  13. data/lib/card.rb +23 -32
  14. data/lib/checklist.rb +13 -1
  15. data/lib/cli.rb +105 -110
  16. data/lib/column.rb +11 -10
  17. data/lib/empty_column.rb +2 -2
  18. data/lib/scrum/backlog_mover.rb +3 -3
  19. data/lib/scrum/card_type_detection.rb +1 -1
  20. data/lib/scrum/creator.rb +7 -7
  21. data/lib/scrum/prioritizer.rb +1 -1
  22. data/lib/scrum/sprint_board.rb +4 -4
  23. data/lib/scrum/sprint_cleaner.rb +3 -3
  24. data/lib/scrum/sprint_planning_board.rb +2 -4
  25. data/lib/scrum_board.rb +3 -3
  26. data/lib/settings.rb +29 -27
  27. data/lib/trello_service.rb +1 -1
  28. data/lib/trello_wrapper.rb +9 -9
  29. data/lib/version.rb +1 -1
  30. data/spec/data/card.json +19 -0
  31. data/spec/data/trollolorc +3 -0
  32. data/spec/integration/command_line_spec.rb +14 -14
  33. data/spec/integration/create_burndown_spec.rb +25 -25
  34. data/spec/integration/integration_spec_helper.rb +1 -1
  35. data/spec/integration/wrapper/credentials_input_wrapper +7 -11
  36. data/spec/integration/wrapper/empty_config_trollolo_wrapper +2 -2
  37. data/spec/integration/wrapper/trollolo_wrapper +2 -2
  38. data/spec/unit/backup_spec.rb +14 -14
  39. data/spec/unit/burndown_chart_spec.rb +176 -184
  40. data/spec/unit/burndown_data_spec.rb +21 -23
  41. data/spec/unit/card_spec.rb +38 -24
  42. data/spec/unit/cli_spec.rb +57 -57
  43. data/spec/unit/empty_column_spec.rb +1 -1
  44. data/spec/unit/retrieve_data_spec.rb +13 -13
  45. data/spec/unit/scrum/backlog_mover_spec.rb +8 -8
  46. data/spec/unit/scrum/card_type_detection_spec.rb +12 -12
  47. data/spec/unit/scrum/creator_spec.rb +8 -8
  48. data/spec/unit/scrum/prioritizer_spec.rb +19 -19
  49. data/spec/unit/scrum/priority_name_spec.rb +16 -16
  50. data/spec/unit/scrum/sprint_board_spec.rb +3 -3
  51. data/spec/unit/scrum/sprint_cleaner_spec.rb +15 -15
  52. data/spec/unit/scrum/sprint_planning_board_spec.rb +2 -2
  53. data/spec/unit/scrum_board_spec.rb +56 -56
  54. data/spec/unit/settings_spec.rb +23 -23
  55. data/spec/unit/spec_helper.rb +3 -3
  56. data/spec/unit/support/test_data_operations.rb +4 -0
  57. data/spec/unit/support/update_webmock_data +9 -11
  58. data/spec/unit/support/vcr.rb +3 -3
  59. data/spec/unit/support/webmocks.rb +21 -12
  60. data/spec/unit/trello_wrapper_spec.rb +40 -29
  61. data/trollolo.gemspec +3 -3
  62. metadata +8 -5
@@ -1,18 +1,18 @@
1
- require_relative "integration_spec_helper"
1
+ require_relative 'integration_spec_helper'
2
2
 
3
3
  include GivenFilesystemSpecHelpers
4
4
  include CliTester
5
5
 
6
6
  def run_helper(working_dir, sprint_number, extra_args = [])
7
- helper_dir = File.expand_path("../../../scripts", __FILE__)
8
- args = ["run"]
9
- args += ["-v", "#{helper_dir}:/trollolo/helper"]
10
- args += ["-v", "#{working_dir}:/trollolo/data"]
11
- args += ["-w", "/trollolo/data"]
12
- args += ["trollolo-matplotlib"]
13
- args += ["/trollolo/helper/create_burndown.py", sprint_number]
7
+ helper_dir = File.expand_path('../../../scripts', __FILE__)
8
+ args = ['run']
9
+ args += ['-v', "#{helper_dir}:/trollolo/helper"]
10
+ args += ['-v', "#{working_dir}:/trollolo/data"]
11
+ args += ['-w', '/trollolo/data']
12
+ args += ['trollolo-matplotlib']
13
+ args += ['/trollolo/helper/create_burndown.py', sprint_number]
14
14
  args += extra_args
15
- run_command(cmd: "docker", args: args)
15
+ run_command(cmd: 'docker', args: args)
16
16
  end
17
17
 
18
18
  def compare_images_for_sprint(sprint_number, extra_args = [])
@@ -21,12 +21,12 @@ def compare_images_for_sprint(sprint_number, extra_args = [])
21
21
  end
22
22
 
23
23
  result = run_helper(@working_dir, sprint_number, extra_args)
24
- expect(result).to exit_with_success("")
24
+ expect(result).to exit_with_success('')
25
25
  expect(File.join(@working_dir, "burndown-#{sprint_number}.png")).
26
26
  to be_same_image_as("create_burndown_helper/burndown-#{sprint_number}.png")
27
27
  end
28
28
 
29
- describe "create_burndown.py" do
29
+ describe 'create_burndown.py' do
30
30
  use_given_filesystem(keep_files: true)
31
31
 
32
32
  before(:all) do
@@ -35,31 +35,31 @@ describe "create_burndown.py" do
35
35
  end
36
36
  end
37
37
 
38
- it "creates burndown chart with varying number of total story points and tasks" do
39
- compare_images_for_sprint("23")
38
+ it 'creates burndown chart with varying number of total story points and tasks' do
39
+ compare_images_for_sprint('23')
40
40
  end
41
41
 
42
- it "creates burndown chart with done tasks at the beginning" do
43
- compare_images_for_sprint("31")
42
+ it 'creates burndown chart with done tasks at the beginning' do
43
+ compare_images_for_sprint('31')
44
44
  end
45
45
 
46
- it "creates burndown chart of unfinished sprint" do
47
- compare_images_for_sprint("35")
46
+ it 'creates burndown chart of unfinished sprint' do
47
+ compare_images_for_sprint('35')
48
48
  end
49
49
 
50
- it "creates burndown chart with fast lane and no tasks" do
51
- compare_images_for_sprint("08", ["--no-tasks", "--with-fast-lane"])
50
+ it 'creates burndown chart with fast lane and no tasks' do
51
+ compare_images_for_sprint('08', ['--no-tasks', '--with-fast-lane'])
52
52
  end
53
53
 
54
- it "creates perfect burndown chart" do
55
- compare_images_for_sprint("42")
54
+ it 'creates perfect burndown chart' do
55
+ compare_images_for_sprint('42')
56
56
  end
57
57
 
58
- it "creates burndown chart with unplanned cards" do
59
- compare_images_for_sprint("56")
58
+ it 'creates burndown chart with unplanned cards' do
59
+ compare_images_for_sprint('56')
60
60
  end
61
61
 
62
- it "creates burndown chart with unplanned tasks on day one" do
63
- compare_images_for_sprint("01")
62
+ it 'creates burndown chart with unplanned tasks on day one' do
63
+ compare_images_for_sprint('01')
64
64
  end
65
65
  end
@@ -2,7 +2,7 @@ require_relative '../../lib/trollolo'
2
2
  require 'given_filesystem/spec_helpers'
3
3
  require 'cli_tester'
4
4
 
5
- bin_path = File.expand_path( "../../../bin/", __FILE__ )
5
+ bin_path = File.expand_path( '../../../bin/', __FILE__ )
6
6
 
7
7
  if ENV['PATH'] !~ /#{bin_path}/
8
8
  ENV['PATH'] = bin_path + File::PATH_SEPARATOR + ENV['PATH']
@@ -1,19 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "expect"
4
- require "pty"
3
+ require 'expect'
4
+ require 'pty'
5
5
 
6
6
  config_path = "/tmp/test-trollolorc-#{rand(100000)}"
7
7
  bin_path = File.expand_path('../../../../bin/trollolo', __FILE__)
8
8
 
9
- ENV["TROLLOLO_CONFIG_PATH"] = config_path
9
+ ENV['TROLLOLO_CONFIG_PATH'] = config_path
10
10
 
11
- PTY.spawn("#{bin_path} #{ARGV.join(" ")}") do |trollolo_out, trollolo_in, pid|
12
- if !trollolo_out.expect("key:", 2)
13
- exit 1
14
- end
15
- trollolo_in.puts("xxx")
16
- if !trollolo_out.expect("token:", 2)
17
- exit 1
18
- end
11
+ PTY.spawn("#{bin_path} #{ARGV.join(' ')}") do |trollolo_out, trollolo_in, pid|
12
+ exit 1 unless trollolo_out.expect('key:', 2)
13
+ trollolo_in.puts('xxx')
14
+ exit 1 unless trollolo_out.expect('token:', 2)
19
15
  end
@@ -3,8 +3,8 @@
3
3
  config_path = "/tmp/test-trollolorc-#{rand(100000)}"
4
4
  bin_path = File.expand_path('../../../../bin/trollolo', __FILE__)
5
5
 
6
- ENV["TROLLOLO_CONFIG_PATH"] = config_path
6
+ ENV['TROLLOLO_CONFIG_PATH'] = config_path
7
7
 
8
- cmd = "#{bin_path} #{ARGV.join(" ")}"
8
+ cmd = "#{bin_path} #{ARGV.join(' ')}"
9
9
 
10
10
  exec(cmd)
@@ -3,8 +3,8 @@
3
3
  test_config_path = File.expand_path('../../../data/trollolorc', __FILE__)
4
4
  bin_path = File.expand_path('../../../../bin/trollolo', __FILE__)
5
5
 
6
- ENV["TROLLOLO_CONFIG_PATH"] = test_config_path
6
+ ENV['TROLLOLO_CONFIG_PATH'] = test_config_path
7
7
 
8
- cmd = "#{bin_path} #{ARGV.join(" ")}"
8
+ cmd = "#{bin_path} #{ARGV.join(' ')}"
9
9
 
10
10
  exec(cmd)
@@ -1,14 +1,14 @@
1
- require_relative "spec_helper"
1
+ require_relative 'spec_helper'
2
2
 
3
3
  include GivenFilesystemSpecHelpers
4
4
 
5
5
  describe Backup do
6
- it "sets backup directory" do
6
+ it 'sets backup directory' do
7
7
  backup = Backup.new(dummy_settings)
8
- expect(backup.directory).to match File.expand_path("~/.trollolo/backup")
8
+ expect(backup.directory).to match File.expand_path('~/.trollolo/backup')
9
9
  end
10
10
 
11
- context "custom backup directory" do
11
+ context 'custom backup directory' do
12
12
  use_given_filesystem(keep_files: true)
13
13
 
14
14
  before(:each) do
@@ -18,22 +18,22 @@ describe Backup do
18
18
  @backup.directory = @directory
19
19
  end
20
20
 
21
- it "backups board" do
22
- @backup.backup("53186e8391ef8671265eba9d")
23
- backup_file = File.join(@directory, "53186e8391ef8671265eba9d", "board.json")
21
+ it 'backups board' do
22
+ @backup.backup('53186e8391ef8671265eba9d')
23
+ backup_file = File.join(@directory, '53186e8391ef8671265eba9d', 'board.json')
24
24
  expect(File.exist?(backup_file)).to be true
25
- expect(File.read(backup_file)).to eq load_test_file("full-board.json").chomp
25
+ expect(File.read(backup_file)).to eq load_test_file('full-board.json').chomp
26
26
  end
27
27
 
28
- it "lists backups" do
29
- @backup.backup("53186e8391ef8671265eba9d")
30
- expect(@backup.list).to eq ["53186e8391ef8671265eba9d"]
28
+ it 'lists backups' do
29
+ @backup.backup('53186e8391ef8671265eba9d')
30
+ expect(@backup.list).to eq ['53186e8391ef8671265eba9d']
31
31
  end
32
32
 
33
- it "shows backup" do
33
+ it 'shows backup' do
34
34
  output_capturer = StringIO.new
35
- @backup.backup("53186e8391ef8671265eba9d")
36
- @backup.show("53186e8391ef8671265eba9d", output: output_capturer )
35
+ @backup.backup('53186e8391ef8671265eba9d')
36
+ @backup.show('53186e8391ef8671265eba9d', output: output_capturer )
37
37
  expect(output_capturer.string).to eq(<<EOT
38
38
  Trollolo Testing Board
39
39
  Sprint Backlog
@@ -24,92 +24,88 @@ describe BurndownChart do
24
24
  full_board_mock
25
25
  end
26
26
 
27
- describe "initializer" do
28
- it "sets initial meta data" do
29
- expect(@chart.data["meta"]["sprint"]).to eq 1
30
- expect(@chart.data["meta"]["total_days"]).to eq 10
31
- expect(@chart.data["meta"]["weekend_lines"]).to eq [3.5, 8.5]
27
+ describe 'initializer' do
28
+ it 'sets initial meta data' do
29
+ expect(@chart.data['meta']['sprint']).to eq 1
30
+ expect(@chart.data['meta']['total_days']).to eq 10
31
+ expect(@chart.data['meta']['weekend_lines']).to eq [3.5, 8.5]
32
32
  end
33
33
  end
34
34
 
35
- describe "data" do
35
+ describe 'data' do
36
36
  use_given_filesystem
37
37
 
38
38
  before(:each) do
39
39
  @raw_data = [
40
40
  {
41
- "date" => '2014-04-23',
42
- "updated_at" => '2014-04-23T10:00:00+01:00',
43
- "story_points" =>
41
+ 'date' => '2014-04-23',
42
+ 'updated_at' => '2014-04-23T10:00:00+01:00',
43
+ 'story_points' =>
44
44
  {
45
- "total" => 30,
46
- "open" => 23
45
+ 'total' => 30,
46
+ 'open' => 23
47
47
  },
48
- "tasks" =>
48
+ 'tasks' =>
49
49
  {
50
- "total" => 25,
51
- "open" => 21
50
+ 'total' => 25,
51
+ 'open' => 21
52
52
  }
53
53
  },
54
54
  {
55
- "date" => '2014-04-24',
56
- "updated_at" => '2014-04-24T19:00:00+01:00',
57
- "story_points" =>
55
+ 'date' => '2014-04-24',
56
+ 'updated_at' => '2014-04-24T19:00:00+01:00',
57
+ 'story_points' =>
58
58
  {
59
- "total" => 30,
60
- "open" => 21
59
+ 'total' => 30,
60
+ 'open' => 21
61
61
  },
62
- "tasks" =>
62
+ 'tasks' =>
63
63
  {
64
- "total" => 26,
65
- "open" => 19
64
+ 'total' => 26,
65
+ 'open' => 19
66
66
  },
67
- "story_points_extra" =>
67
+ 'story_points_extra' =>
68
68
  {
69
- "done" => 3
69
+ 'done' => 3
70
70
  },
71
- "tasks_extra" =>
71
+ 'tasks_extra' =>
72
72
  {
73
- "done" => 2
73
+ 'done' => 2
74
74
  },
75
- "story_points_unplanned" =>
75
+ 'story_points_unplanned' =>
76
76
  {
77
- "total" => 3,
78
- "open" => 1
77
+ 'total' => 3,
78
+ 'open' => 1
79
79
  },
80
- "tasks_unplanned" =>
80
+ 'tasks_unplanned' =>
81
81
  {
82
- "total" => 2,
83
- "open" => 1
82
+ 'total' => 2,
83
+ 'open' => 1
84
84
  }
85
85
  }
86
86
  ]
87
87
  end
88
88
 
89
- it "returns sprint number" do
89
+ it 'returns sprint number' do
90
90
  expect(@chart.sprint).to eq 1
91
91
  end
92
92
 
93
- describe "#add_data" do
94
- it "creates first data entry" do
93
+ describe '#add_data' do
94
+ it 'creates first data entry' do
95
95
  @burndown_data.story_points.open = 16
96
96
  @burndown_data.story_points.done = 7
97
97
  @burndown_data.tasks.open = 10
98
98
  @burndown_data.tasks.done = 11
99
- @burndown_data.date_time = DateTime.parse("2014-05-30")
99
+ @burndown_data.date_time = DateTime.parse('2014-05-30')
100
100
 
101
101
  @chart.add_data(@burndown_data)
102
102
 
103
- expect( @chart.data["days"].first["story_points"] ).to eq(
104
- {
105
- "total" => 23,
106
- "open" => 16
107
- } )
108
- expect( @chart.data["days"].first["tasks"] ).to eq(
109
- {
110
- "total" => 21,
111
- "open" => 10
112
- } )
103
+ expect( @chart.data['days'].first['story_points'] ).to eq(
104
+ 'total' => 23,
105
+ 'open' => 16 )
106
+ expect( @chart.data['days'].first['tasks'] ).to eq(
107
+ 'total' => 21,
108
+ 'open' => 10 )
113
109
  end
114
110
 
115
111
  it "doesn't overwrite first data entry" do
@@ -117,7 +113,7 @@ describe BurndownChart do
117
113
  @burndown_data.story_points.done = 7
118
114
  @burndown_data.tasks.open = 10
119
115
  @burndown_data.tasks.done = 11
120
- @burndown_data.date_time = DateTime.parse("2014-05-30")
116
+ @burndown_data.date_time = DateTime.parse('2014-05-30')
121
117
 
122
118
  @chart.add_data(@burndown_data)
123
119
 
@@ -125,28 +121,24 @@ describe BurndownChart do
125
121
  @burndown_data.story_points.done = 8
126
122
  @burndown_data.tasks.open = 9
127
123
  @burndown_data.tasks.done = 12
128
- @burndown_data.date_time = DateTime.parse("2014-05-30")
124
+ @burndown_data.date_time = DateTime.parse('2014-05-30')
129
125
 
130
126
  @chart.add_data(@burndown_data)
131
127
 
132
- expect( @chart.data["days"].first["story_points"] ).to eq(
133
- {
134
- "total" => 23,
135
- "open" => 16
136
- } )
137
- expect( @chart.data["days"].first["tasks"] ).to eq(
138
- {
139
- "total" => 21,
140
- "open" => 10
141
- } )
128
+ expect( @chart.data['days'].first['story_points'] ).to eq(
129
+ 'total' => 23,
130
+ 'open' => 16 )
131
+ expect( @chart.data['days'].first['tasks'] ).to eq(
132
+ 'total' => 21,
133
+ 'open' => 10 )
142
134
  end
143
135
 
144
- it "does overwrite data entries after first one" do
136
+ it 'does overwrite data entries after first one' do
145
137
  @burndown_data.story_points.open = 16
146
138
  @burndown_data.story_points.done = 7
147
139
  @burndown_data.tasks.open = 10
148
140
  @burndown_data.tasks.done = 11
149
- @burndown_data.date_time = DateTime.parse("2014-05-30")
141
+ @burndown_data.date_time = DateTime.parse('2014-05-30')
150
142
 
151
143
  @chart.add_data(@burndown_data)
152
144
 
@@ -154,7 +146,7 @@ describe BurndownChart do
154
146
  @burndown_data.story_points.done = 7
155
147
  @burndown_data.tasks.open = 10
156
148
  @burndown_data.tasks.done = 11
157
- @burndown_data.date_time = DateTime.parse("2014-05-31")
149
+ @burndown_data.date_time = DateTime.parse('2014-05-31')
158
150
 
159
151
  @chart.add_data(@burndown_data)
160
152
 
@@ -162,24 +154,20 @@ describe BurndownChart do
162
154
  @burndown_data.story_points.done = 8
163
155
  @burndown_data.tasks.open = 9
164
156
  @burndown_data.tasks.done = 12
165
- @burndown_data.date_time = DateTime.parse("2014-05-31")
157
+ @burndown_data.date_time = DateTime.parse('2014-05-31')
166
158
 
167
159
  @chart.add_data(@burndown_data)
168
160
 
169
- expect( @chart.data["days"][1]["story_points"] ).to eq(
170
- {
171
- "total" => 23,
172
- "open" => 15
173
- } )
174
- expect( @chart.data["days"][1]["tasks"] ).to eq(
175
- {
176
- "total" => 21,
177
- "open" => 9
178
- } )
161
+ expect( @chart.data['days'][1]['story_points'] ).to eq(
162
+ 'total' => 23,
163
+ 'open' => 15 )
164
+ expect( @chart.data['days'][1]['tasks'] ).to eq(
165
+ 'total' => 21,
166
+ 'open' => 9 )
179
167
  end
180
168
 
181
- it "adds data" do
182
- @chart.data["days"] = @raw_data
169
+ it 'adds data' do
170
+ @chart.data['days'] = @raw_data
183
171
 
184
172
  @burndown_data.story_points.open = 16
185
173
  @burndown_data.story_points.done = 7
@@ -189,83 +177,83 @@ describe BurndownChart do
189
177
  @burndown_data.extra_story_points.done = 3
190
178
  @burndown_data.extra_tasks.open = 5
191
179
  @burndown_data.extra_tasks.done = 2
192
- @burndown_data.date_time = DateTime.parse("2014-05-30")
180
+ @burndown_data.date_time = DateTime.parse('2014-05-30')
193
181
 
194
182
  @chart.add_data(@burndown_data)
195
183
 
196
- expect( @chart.data["days"].count ).to eq 3
197
- expect( @chart.data["days"].last["date"] ).to eq ( "2014-05-30" )
198
- expect( @chart.data["days"].last["story_points"] ).to eq ( {
199
- "total" => 23,
200
- "open" => 16
184
+ expect( @chart.data['days'].count ).to eq 3
185
+ expect( @chart.data['days'].last['date'] ).to eq '2014-05-30'
186
+ expect( @chart.data['days'].last['story_points'] ).to eq ( {
187
+ 'total' => 23,
188
+ 'open' => 16
201
189
  } )
202
- expect( @chart.data["days"].last["tasks"] ).to eq ( {
203
- "total" => 21,
204
- "open" => 10
190
+ expect( @chart.data['days'].last['tasks'] ).to eq ( {
191
+ 'total' => 21,
192
+ 'open' => 10
205
193
  } )
206
- expect( @chart.data["days"].last["story_points_extra"] ).to eq ( {
207
- "done" => 3
194
+ expect( @chart.data['days'].last['story_points_extra'] ).to eq ( {
195
+ 'done' => 3
208
196
  } )
209
- expect( @chart.data["days"].last["tasks_extra"] ).to eq ( {
210
- "done" => 2
197
+ expect( @chart.data['days'].last['tasks_extra'] ).to eq ( {
198
+ 'done' => 2
211
199
  } )
212
200
  end
213
201
 
214
- it "replaces data of same day" do
215
- @chart.data["days"] = @raw_data
202
+ it 'replaces data of same day' do
203
+ @chart.data['days'] = @raw_data
216
204
 
217
205
  @burndown_data.story_points.open = 16
218
206
  @burndown_data.story_points.done = 7
219
207
  @burndown_data.tasks.open = 10
220
208
  @burndown_data.tasks.done = 11
221
- @burndown_data.date_time = DateTime.parse("2014-05-30")
209
+ @burndown_data.date_time = DateTime.parse('2014-05-30')
222
210
 
223
211
  @chart.add_data(@burndown_data)
224
212
 
225
- expect( @chart.data["days"].count ).to eq 3
226
- expect( @chart.data["days"].last["story_points"] ).to eq ( {
227
- "total" => 23,
228
- "open" => 16
213
+ expect( @chart.data['days'].count ).to eq 3
214
+ expect( @chart.data['days'].last['story_points'] ).to eq ( {
215
+ 'total' => 23,
216
+ 'open' => 16
229
217
  } )
230
218
 
231
219
  @burndown_data.story_points.done = 8
232
220
  @chart.add_data(@burndown_data)
233
221
 
234
- expect( @chart.data["days"].count ).to eq 3
235
- expect( @chart.data["days"].last["story_points"] ).to eq ( {
236
- "total" => 24,
237
- "open" => 16
222
+ expect( @chart.data['days'].count ).to eq 3
223
+ expect( @chart.data['days'].last['story_points'] ).to eq ( {
224
+ 'total' => 24,
225
+ 'open' => 16
238
226
  } )
239
227
  end
240
228
  end
241
229
 
242
- describe "#read_data" do
243
- it "reads data" do
230
+ describe '#read_data' do
231
+ it 'reads data' do
244
232
  @chart.read_data given_file('burndown-data.yaml')
245
233
 
246
- expect(@chart.data["days"]).to eq @raw_data
234
+ expect(@chart.data['days']).to eq @raw_data
247
235
  end
248
236
 
249
- it "reads not done columns" do
237
+ it 'reads not done columns' do
250
238
  @chart.read_data given_file('burndown-data.yaml', from: 'burndown-data-with-config.yaml')
251
- expect(@settings.not_done_columns).to eq ["Sprint Backlog", "Doing", "QA"]
239
+ expect(@settings.not_done_columns).to eq ['Sprint Backlog', 'Doing', 'QA']
252
240
  end
253
241
  end
254
242
 
255
- describe "#write_data" do
256
- it "writes object to disk" do
243
+ describe '#write_data' do
244
+ it 'writes object to disk' do
257
245
  @chart.sprint = 2
258
- @chart.data["meta"]["total_days"] = 9
259
- @chart.data["meta"]["weekend_lines"] = [3.5, 7.5]
260
- @chart.data["meta"]["board_id"] = "myboardid"
261
- @chart.data["days"] = @raw_data
246
+ @chart.data['meta']['total_days'] = 9
247
+ @chart.data['meta']['weekend_lines'] = [3.5, 7.5]
248
+ @chart.data['meta']['board_id'] = 'myboardid'
249
+ @chart.data['days'] = @raw_data
262
250
 
263
251
  write_path = given_dummy_file
264
252
  @chart.write_data(write_path)
265
253
  expect(File.read(write_path)). to eq load_test_file('burndown-data.yaml')
266
254
  end
267
255
 
268
- it "writes all data which was read" do
256
+ it 'writes all data which was read' do
269
257
  read_path = given_file('burndown-data.yaml')
270
258
  @chart.read_data(read_path)
271
259
 
@@ -278,29 +266,29 @@ describe BurndownChart do
278
266
  it "doesn't write extra entries with 0 values" do
279
267
  raw_data = [
280
268
  {
281
- "date" => '2014-04-24',
282
- "story_points" =>
269
+ 'date' => '2014-04-24',
270
+ 'story_points' =>
283
271
  {
284
- "total" => 30,
285
- "open" => 21
272
+ 'total' => 30,
273
+ 'open' => 21
286
274
  },
287
- "tasks" =>
275
+ 'tasks' =>
288
276
  {
289
- "total" => 26,
290
- "open" => 19
277
+ 'total' => 26,
278
+ 'open' => 19
291
279
  },
292
- "story_points_extra" =>
280
+ 'story_points_extra' =>
293
281
  {
294
- "done" => 0
282
+ 'done' => 0
295
283
  },
296
- "tasks_extra" =>
284
+ 'tasks_extra' =>
297
285
  {
298
- "done" => 0
286
+ 'done' => 0
299
287
  }
300
288
  }
301
289
  ]
302
- @chart.data["days"] = raw_data
303
- @chart.data["meta"]["board_id"] = "1234"
290
+ @chart.data['days'] = raw_data
291
+ @chart.data['meta']['board_id'] = '1234'
304
292
 
305
293
  write_path = given_dummy_file
306
294
  @chart.write_data(write_path)
@@ -343,77 +331,76 @@ EOT
343
331
  end
344
332
  end
345
333
 
346
- describe "commands" do
334
+ describe 'commands' do
347
335
  use_given_filesystem(keep_files: true)
348
336
 
349
- describe "setup" do
350
- it "initializes new chart" do
337
+ describe 'setup' do
338
+ it 'initializes new chart' do
351
339
  path = given_directory
352
- @chart.setup(path, "53186e8391ef8671265eba9d")
340
+ @chart.setup(path, '53186e8391ef8671265eba9d')
353
341
 
354
- expect(File.exist?(File.join(path, "burndown-data-01.yaml"))).to be true
342
+ expect(File.exist?(File.join(path, 'burndown-data-01.yaml'))).to be true
355
343
 
356
344
  chart = BurndownChart.new(@settings)
357
- chart.read_data(File.join(path, "burndown-data-01.yaml"))
345
+ chart.read_data(File.join(path, 'burndown-data-01.yaml'))
358
346
 
359
- expect(chart.board_id).to eq "53186e8391ef8671265eba9d"
347
+ expect(chart.board_id).to eq '53186e8391ef8671265eba9d'
360
348
  end
361
349
  end
362
350
 
363
- describe "last_sprint" do
364
- it "gets the last sprint based on the burndown files" do
365
- path = given_directory_from_data("burndown_dir")
351
+ describe 'last_sprint' do
352
+ it 'gets the last sprint based on the burndown files' do
353
+ path = given_directory_from_data('burndown_dir')
366
354
  expect(@chart.last_sprint(path)).to eq(2)
367
355
  end
368
356
  end
369
357
 
370
- describe "load_sprint" do
371
- let(:path) { given_directory_from_data("burndown_dir") }
358
+ describe 'load_sprint' do
359
+ let(:path) { given_directory_from_data('burndown_dir') }
372
360
 
373
- it "loads the burndown from the 2nd sprint into data" do
361
+ it 'loads the burndown from the 2nd sprint into data' do
374
362
  @chart.load_sprint(path)
375
363
  expect(@chart.data).to eq(
376
- { "meta" =>
377
- { "board_id" => "53186e8391ef8671265eba9d",
378
- "sprint" => 2,
379
- "total_days" => 9,
380
- "weekend_lines" => [3.5, 7.5]
364
+ 'meta' =>
365
+ { 'board_id' => '53186e8391ef8671265eba9d',
366
+ 'sprint' => 2,
367
+ 'total_days' => 9,
368
+ 'weekend_lines' => [3.5, 7.5]
381
369
  },
382
- "days" => [
383
- { "date" => "2015-08-28",
384
- "updated_at" => "2015-08-28T11:04:52+02:00",
385
- "story_points" =>
386
- { "total" => 24.0,
387
- "open" => 24.0
388
- },
389
- "tasks" =>
390
- { "total" => 43,
391
- "open" => 28
392
- },
393
- "story_points_extra" =>
394
- { "done" => 2.0
395
- },
396
- "tasks_extra" =>
397
- { "done" => 5
398
- }
399
- }
400
- ]
401
- })
370
+ 'days' => [
371
+ { 'date' => '2015-08-28',
372
+ 'updated_at' => '2015-08-28T11:04:52+02:00',
373
+ 'story_points' =>
374
+ { 'total' => 24.0,
375
+ 'open' => 24.0
376
+ },
377
+ 'tasks' =>
378
+ { 'total' => 43,
379
+ 'open' => 28
380
+ },
381
+ 'story_points_extra' =>
382
+ { 'done' => 2.0
383
+ },
384
+ 'tasks_extra' =>
385
+ { 'done' => 5
386
+ }
387
+ }
388
+ ])
402
389
  end
403
390
 
404
- it "returns the path of the last sprint" do
405
- expect(@chart.load_sprint(path)).to eq(File.join(path, "burndown-data-02.yaml"))
391
+ it 'returns the path of the last sprint' do
392
+ expect(@chart.load_sprint(path)).to eq(File.join(path, 'burndown-data-02.yaml'))
406
393
  end
407
394
  end
408
395
 
409
- describe "update" do
410
- let(:path) { given_directory_from_data("burndown_dir") }
411
- let(:options) { {'output' => path} }
396
+ describe 'update' do
397
+ let(:path) { given_directory_from_data('burndown_dir') }
398
+ let(:options) { {'output' => path, 'board-id' => '7Zar7bNm'} }
412
399
  let(:before) { BurndownChart.new(@settings) }
413
400
  let(:after) { BurndownChart.new(@settings) }
414
401
 
415
- it "updates chart with latest data" do
416
- updated_at = "2015-01-12T13:57:16+01:00"
402
+ it 'updates chart with latest data' do
403
+ updated_at = '2015-01-12T13:57:16+01:00'
417
404
  expected_date_time = DateTime.parse(updated_at)
418
405
  allow(DateTime).to receive(:now).and_return(expected_date_time)
419
406
 
@@ -422,25 +409,30 @@ EOT
422
409
  after.read_data(File.join(path, 'burndown-data-02.yaml'))
423
410
  expect(after.days.size).to eq before.days.size + 1
424
411
 
425
- expect(after.days.last["date"]).to eq "2015-01-12"
426
- expect(after.days.last["updated_at"]).to eq updated_at
412
+ expect(after.days.last['date']).to eq '2015-01-12'
413
+ expect(after.days.last['updated_at']).to eq updated_at
427
414
  end
428
415
 
429
- it "overwrites data on same date" do
416
+ it 'overwrites data on same date' do
430
417
  before.read_data(File.join(path, 'burndown-data-02.yaml'))
431
418
  @chart.update(options)
432
419
  @chart.update(options)
433
420
  after.read_data(File.join(path, 'burndown-data-02.yaml'))
434
421
  expect(after.days.size).to eq before.days.size + 1
435
422
  end
423
+
424
+ it 'uses provided board-id' do
425
+ @chart.update(options)
426
+ expect(@chart.board_id).to eq '7Zar7bNm'
427
+ end
436
428
  end
437
429
 
438
- describe "create_next_sprint" do
439
- let(:path) { given_directory_from_data("burndown_dir") }
430
+ describe 'create_next_sprint' do
431
+ let(:path) { given_directory_from_data('burndown_dir') }
440
432
  let(:chart) { BurndownChart.new(@settings) }
441
- let(:next_sprint_file) { File.join(path, "burndown-data-03.yaml") }
433
+ let(:next_sprint_file) { File.join(path, 'burndown-data-03.yaml') }
442
434
 
443
- it "create new sprint file" do
435
+ it 'create new sprint file' do
444
436
  expected_file_content = <<EOT
445
437
  ---
446
438
  meta:
@@ -458,7 +450,7 @@ EOT
458
450
  expect(File.read(next_sprint_file)).to eq expected_file_content
459
451
  end
460
452
 
461
- it "create new sprint file with params" do
453
+ it 'create new sprint file with params' do
462
454
  expected_file_content = <<EOT
463
455
  ---
464
456
  meta:
@@ -472,7 +464,7 @@ meta:
472
464
  - 16.5
473
465
  days: []
474
466
  EOT
475
- chart.create_next_sprint(path, { total_days: 17, weekend_lines: [1.5, 6.5, 11.5, 16.5] })
467
+ chart.create_next_sprint(path, total_days: 17, weekend_lines: [1.5, 6.5, 11.5, 16.5])
476
468
 
477
469
  expect(File.exist?(next_sprint_file)).to be true
478
470
  expect(File.read(next_sprint_file)).to eq expected_file_content
@@ -480,22 +472,22 @@ EOT
480
472
  end
481
473
  end
482
474
 
483
- describe "reads meta data from the board" do
475
+ describe 'reads meta data from the board' do
484
476
  use_given_filesystem
485
477
 
486
- it "merges meta data from board if present" do
478
+ it 'merges meta data from board if present' do
487
479
  chart = BurndownChart.new(@settings)
488
- chart.read_data(given_file("burndown-data-10.yaml"))
480
+ chart.read_data(given_file('burndown-data-10.yaml'))
489
481
 
490
- expect(chart.data["meta"]["weekend_lines"]).to eq([3.5, 8.5])
482
+ expect(chart.data['meta']['weekend_lines']).to eq([3.5, 8.5])
491
483
 
492
484
  burndown = BurndownData.new(@settings)
493
- burndown.board_id = "53186e8391ef8671265eba9d"
485
+ burndown.board_id = '53186e8391ef8671265eba9d'
494
486
  burndown.fetch
495
487
 
496
488
  chart.merge_meta_data_from_board(burndown)
497
489
 
498
- expect(chart.data["meta"]["weekend_lines"]).to eq([1.5, 6.5, 11.5, 16.5])
490
+ expect(chart.data['meta']['weekend_lines']).to eq([1.5, 6.5, 11.5, 16.5])
499
491
  end
500
492
  end
501
493
 
@@ -504,7 +496,7 @@ EOT
504
496
  allow(described_class).to receive(:process_options).and_return(%w{ --test 1 --no-blah })
505
497
  allow(described_class).to receive(:plot_helper).and_return('mescript')
506
498
  expect(described_class).to receive(:system).with('python mescript 42 --test 1 --no-blah')
507
- described_class.plot(42, {foo: 1, bar: 2})
499
+ described_class.plot(42, foo: 1, bar: 2)
508
500
  end
509
501
  end
510
502