spec/unit/burndown_chart_spec.rb in trollolo-0.0.10 vs spec/unit/burndown_chart_spec.rb in trollolo-0.0.11

- old
+ new

@@ -347,16 +347,16 @@ use_given_filesystem(keep_files: true) describe "setup" do it "initializes new chart" do path = given_directory - @chart.setup(path,"53186e8391ef8671265eba9d") + @chart.setup(path, "53186e8391ef8671265eba9d") - expect(File.exist?(File.join(path,"burndown-data-01.yaml"))).to be true + expect(File.exist?(File.join(path, "burndown-data-01.yaml"))).to be true chart = BurndownChart.new(@settings) - chart.read_data(File.join(path,"burndown-data-01.yaml")) + chart.read_data(File.join(path, "burndown-data-01.yaml")) expect(chart.board_id).to eq "53186e8391ef8671265eba9d" end end @@ -400,11 +400,11 @@ ] }) 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")) + expect(@chart.load_last_sprint(path)).to eq(File.join(path, "burndown-data-02.yaml")) end end describe "update" do let(:path) { given_directory_from_data("burndown_dir") } @@ -415,47 +415,67 @@ it "updates chart with latest data" do updated_at = "2015-01-12T13:57:16+01:00" expected_date_time = DateTime.parse(updated_at) allow(DateTime).to receive(:now).and_return(expected_date_time) - before.read_data(File.join(path,'burndown-data-02.yaml')) + before.read_data(File.join(path, 'burndown-data-02.yaml')) @chart.update(options) - after.read_data(File.join(path,'burndown-data-02.yaml')) + after.read_data(File.join(path, 'burndown-data-02.yaml')) expect(after.days.size).to eq before.days.size + 1 expect(after.days.last["date"]).to eq "2015-01-12" expect(after.days.last["updated_at"]).to eq updated_at end it "overwrites data on same date" do - before.read_data(File.join(path,'burndown-data-02.yaml')) + before.read_data(File.join(path, 'burndown-data-02.yaml')) @chart.update(options) @chart.update(options) - after.read_data(File.join(path,'burndown-data-02.yaml')) + after.read_data(File.join(path, 'burndown-data-02.yaml')) expect(after.days.size).to eq before.days.size + 1 end end describe "create_next_sprint" do + let(:path) { given_directory_from_data("burndown_dir") } + let(:chart) { BurndownChart.new(@settings) } + let(:next_sprint_file) { File.join(path, "burndown-data-03.yaml") } + it "create new sprint file" do - path = given_directory_from_data("burndown_dir") - chart = BurndownChart.new(@settings) + expected_file_content = <<EOT +--- +meta: + board_id: 53186e8391ef8671265eba9d + sprint: 3 + total_days: 9 + weekend_lines: + - 3.5 + - 7.5 +days: [] +EOT chart.create_next_sprint(path) - next_sprint_file = File.join(path, "burndown-data-03.yaml") expect(File.exist?(next_sprint_file)).to be true + expect(File.read(next_sprint_file)).to eq expected_file_content + end + it "create new sprint file with params" do expected_file_content = <<EOT --- meta: board_id: 53186e8391ef8671265eba9d sprint: 3 - total_days: 9 + total_days: 17 weekend_lines: - - 3.5 - - 7.5 + - 1.5 + - 6.5 + - 11.5 + - 16.5 days: [] EOT + chart.create_next_sprint(path, { total_days: 17, weekend_lines: [1.5, 6.5, 11.5, 16.5] }) + + expect(File.exist?(next_sprint_file)).to be true expect(File.read(next_sprint_file)).to eq expected_file_content end end end