spec/unit/burndown_chart_spec.rb in trollolo-0.0.5 vs spec/unit/burndown_chart_spec.rb in trollolo-0.0.6
- old
+ new
@@ -1,11 +1,10 @@
require_relative 'spec_helper'
include GivenFilesystemSpecHelpers
describe BurndownChart do
-
before(:each) do
@settings = dummy_settings
@burndown_data = BurndownData.new(@settings)
@chart = BurndownChart.new(@settings)
full_board_mock
@@ -56,98 +55,176 @@
"done" => 3
},
"tasks_extra" =>
{
"done" => 2
+ },
+ "story_points_unplanned" =>
+ {
+ "total" => 3,
+ "open" => 1
+ },
+ "tasks_unplanned" =>
+ {
+ "total" => 2,
+ "open" => 1
}
}
]
end
- it "creates first data entry" do
- @burndown_data.story_points.open = 16
- @burndown_data.story_points.done = 7
- @burndown_data.tasks.open = 10
- @burndown_data.tasks.done = 11
- @burndown_data.date_time = DateTime.parse("2014-05-30")
+ it "returns sprint number" do
+ expect(@chart.sprint).to eq 1
+ end
- @chart.add_data(@burndown_data)
+ describe "#add_data" do
+ it "creates first data entry" do
+ @burndown_data.story_points.open = 16
+ @burndown_data.story_points.done = 7
+ @burndown_data.tasks.open = 10
+ @burndown_data.tasks.done = 11
+ @burndown_data.date_time = DateTime.parse("2014-05-30")
- expect( @chart.data["days"].first["story_points"] ).to eq(
- {
+ @chart.add_data(@burndown_data)
+
+ expect( @chart.data["days"].first["story_points"] ).to eq(
+ {
+ "total" => 23,
+ "open" => 16
+ } )
+ expect( @chart.data["days"].first["tasks"] ).to eq(
+ {
+ "total" => 21,
+ "open" => 10
+ } )
+ end
+
+ it "doesn't overwrite first data entry" do
+ @burndown_data.story_points.open = 16
+ @burndown_data.story_points.done = 7
+ @burndown_data.tasks.open = 10
+ @burndown_data.tasks.done = 11
+ @burndown_data.date_time = DateTime.parse("2014-05-30")
+
+ @chart.add_data(@burndown_data)
+
+ @burndown_data.story_points.open = 15
+ @burndown_data.story_points.done = 8
+ @burndown_data.tasks.open = 9
+ @burndown_data.tasks.done = 12
+ @burndown_data.date_time = DateTime.parse("2014-05-30")
+
+ @chart.add_data(@burndown_data)
+
+ expect( @chart.data["days"].first["story_points"] ).to eq(
+ {
+ "total" => 23,
+ "open" => 16
+ } )
+ expect( @chart.data["days"].first["tasks"] ).to eq(
+ {
+ "total" => 21,
+ "open" => 10
+ } )
+ end
+
+ it "does overwrite data entries after first one" do
+ @burndown_data.story_points.open = 16
+ @burndown_data.story_points.done = 7
+ @burndown_data.tasks.open = 10
+ @burndown_data.tasks.done = 11
+ @burndown_data.date_time = DateTime.parse("2014-05-30")
+
+ @chart.add_data(@burndown_data)
+
+ @burndown_data.story_points.open = 16
+ @burndown_data.story_points.done = 7
+ @burndown_data.tasks.open = 10
+ @burndown_data.tasks.done = 11
+ @burndown_data.date_time = DateTime.parse("2014-05-31")
+
+ @chart.add_data(@burndown_data)
+
+ @burndown_data.story_points.open = 15
+ @burndown_data.story_points.done = 8
+ @burndown_data.tasks.open = 9
+ @burndown_data.tasks.done = 12
+ @burndown_data.date_time = DateTime.parse("2014-05-31")
+
+ @chart.add_data(@burndown_data)
+
+ expect( @chart.data["days"][1]["story_points"] ).to eq(
+ {
+ "total" => 23,
+ "open" => 15
+ } )
+ expect( @chart.data["days"][1]["tasks"] ).to eq(
+ {
+ "total" => 21,
+ "open" => 9
+ } )
+ end
+
+ it "adds data" do
+ @chart.data["days"] = @raw_data
+
+ @burndown_data.story_points.open = 16
+ @burndown_data.story_points.done = 7
+ @burndown_data.tasks.open = 10
+ @burndown_data.tasks.done = 11
+ @burndown_data.extra_story_points.open = 2
+ @burndown_data.extra_story_points.done = 3
+ @burndown_data.extra_tasks.open = 5
+ @burndown_data.extra_tasks.done = 2
+ @burndown_data.date_time = DateTime.parse("2014-05-30")
+
+ @chart.add_data(@burndown_data)
+
+ expect( @chart.data["days"].count ).to eq 3
+ expect( @chart.data["days"].last["date"] ).to eq ( "2014-05-30" )
+ expect( @chart.data["days"].last["story_points"] ).to eq ( {
"total" => 23,
"open" => 16
} )
- expect( @chart.data["days"].first["tasks"] ).to eq(
- {
+ expect( @chart.data["days"].last["tasks"] ).to eq ( {
"total" => 21,
"open" => 10
} )
- end
+ expect( @chart.data["days"].last["story_points_extra"] ).to eq ( {
+ "done" => 3
+ } )
+ expect( @chart.data["days"].last["tasks_extra"] ).to eq ( {
+ "done" => 2
+ } )
+ end
- it "returns sprint number" do
- expect(@chart.sprint).to eq 1
- end
+ it "replaces data of same day" do
+ @chart.data["days"] = @raw_data
- it "adds data" do
- @chart.data["days"] = @raw_data
+ @burndown_data.story_points.open = 16
+ @burndown_data.story_points.done = 7
+ @burndown_data.tasks.open = 10
+ @burndown_data.tasks.done = 11
+ @burndown_data.date_time = DateTime.parse("2014-05-30")
- @burndown_data.story_points.open = 16
- @burndown_data.story_points.done = 7
- @burndown_data.tasks.open = 10
- @burndown_data.tasks.done = 11
- @burndown_data.extra_story_points.open = 2
- @burndown_data.extra_story_points.done = 3
- @burndown_data.extra_tasks.open = 5
- @burndown_data.extra_tasks.done = 2
- @burndown_data.date_time = DateTime.parse("2014-05-30")
+ @chart.add_data(@burndown_data)
- @chart.add_data(@burndown_data)
+ expect( @chart.data["days"].count ).to eq 3
+ expect( @chart.data["days"].last["story_points"] ).to eq ( {
+ "total" => 23,
+ "open" => 16
+ } )
- expect( @chart.data["days"].count ).to eq 3
- expect( @chart.data["days"].last["date"] ).to eq ( "2014-05-30" )
- expect( @chart.data["days"].last["story_points"] ).to eq ( {
- "total" => 23,
- "open" => 16
- } )
- expect( @chart.data["days"].last["tasks"] ).to eq ( {
- "total" => 21,
- "open" => 10
- } )
- expect( @chart.data["days"].last["story_points_extra"] ).to eq ( {
- "done" => 3
- } )
- expect( @chart.data["days"].last["tasks_extra"] ).to eq ( {
- "done" => 2
- } )
- end
+ @burndown_data.story_points.done = 8
+ @chart.add_data(@burndown_data)
- it "replaces data of same day" do
- @chart.data["days"] = @raw_data
-
- @burndown_data.story_points.open = 16
- @burndown_data.story_points.done = 7
- @burndown_data.tasks.open = 10
- @burndown_data.tasks.done = 11
- @burndown_data.date_time = DateTime.parse("2014-05-30")
-
- @chart.add_data(@burndown_data)
-
- expect( @chart.data["days"].count ).to eq 3
- expect( @chart.data["days"].last["story_points"] ).to eq ( {
- "total" => 23,
- "open" => 16
- } )
-
- @burndown_data.story_points.done = 8
- @chart.add_data(@burndown_data)
-
- expect( @chart.data["days"].count ).to eq 3
- expect( @chart.data["days"].last["story_points"] ).to eq ( {
- "total" => 24,
- "open" => 16
- } )
+ expect( @chart.data["days"].count ).to eq 3
+ expect( @chart.data["days"].last["story_points"] ).to eq ( {
+ "total" => 24,
+ "open" => 16
+ } )
+ end
end
describe "#read_data" do
it "reads data" do
@chart.read_data given_file('burndown-data.yaml')
@@ -233,11 +310,10 @@
open: 19
EOT
expect(File.read(write_path)).to eq expected_file_content
end
end
-
end
describe "commands" do
use_given_filesystem(keep_files: true)
@@ -262,18 +338,40 @@
end
end
describe "load_last_sprint" do
let(:path) { given_directory_from_data("burndown_dir") }
- it "loads the burndown form the 2nd sprint into data" do
+
+ it "loads the burndown from the 2nd sprint into data" do
@chart.load_last_sprint(path)
- expect(@chart.data).to eq({"meta"=>
- {"board_id"=>"53186e8391ef8671265eba9d",
- "sprint"=>2,
- "total_days"=>9,
- "weekend_lines"=>[3.5, 7.5]},
- "days"=>[]})
+ expect(@chart.data).to eq(
+ { "meta" =>
+ { "board_id" => "53186e8391ef8671265eba9d",
+ "sprint" => 2,
+ "total_days" => 9,
+ "weekend_lines" => [3.5, 7.5]
+ },
+ "days" => [
+ { "date" => "2015-08-28",
+ "updated_at" => "2015-08-28T11:04:52+02:00",
+ "story_points" =>
+ { "total"=>24.0,
+ "open"=>24.0
+ },
+ "tasks" =>
+ { "total" => 43,
+ "open" => 28
+ },
+ "story_points_extra" =>
+ { "done"=>2.0
+ },
+ "tasks_extra" =>
+ { "done" => 5
+ }
+ }
+ ]
+ })
end
it "returns the path of the last sprint" do
expect(@chart.load_last_sprint(path)).to eq(File.join(path,"burndown-data-02.yaml"))
end
@@ -332,11 +430,10 @@
end
end
end
describe "reads meta data from the board" do
-
use_given_filesystem
it "merges meta data from board if present" do
chart = BurndownChart.new(@settings)
chart.read_data(given_file("burndown-data-10.yaml"))
@@ -352,30 +449,25 @@
expect(chart.data["meta"]["weekend_lines"]).to eq([1.5, 6.5, 11.5, 16.5])
end
end
describe '.plot' do
-
it 'sends joined parsed options to python script' do
allow(described_class).to receive(:process_options).and_return(%w{ --test 1 --no-blah })
allow(described_class).to receive(:plot_helper).and_return('mescript')
expect(described_class).to receive(:system).with('python mescript 42 --test 1 --no-blah')
described_class.plot(42, {foo: 1, bar: 2})
end
-
end
describe '.plot_helper' do
-
it 'expands path to burndown generator' do
expect(described_class.plot_helper).to include('scripts/create_burndown.py')
end
-
end
describe '.process_options' do
-
it 'builds an array of switches for burndown chart based on input hash' do
test_hash = { 'no-tasks' => true }
expect(described_class.send(:process_options, test_hash)).to eq %w{ --no-tasks }
test_hash = { 'with-fast-lane' => true }
expect(described_class.send(:process_options, test_hash)).to eq %w{ --with-fast-lane }
@@ -389,8 +481,7 @@
'output' => 'fanagoro',
'verbose' => true
}
expect(described_class.send(:process_options, test_hash)).to eq ['--no-tasks', '--with-fast-lane', '--output fanagoro', '--verbose']
end
-
end
end