spec/integration/create_burndown_spec.rb in trollolo-0.0.7 vs spec/integration/create_burndown_spec.rb in trollolo-0.0.8

- old
+ new

@@ -1,55 +1,61 @@ require_relative "integration_spec_helper" include GivenFilesystemSpecHelpers include CliTester -HELPER_SCRIPT = File.expand_path("../../../scripts/create_burndown.py", __FILE__) +def run_helper(working_dir, sprint_number, extra_args = []) + helper_dir = File.expand_path("../../../scripts", __FILE__) + args = ["run"] + args += ["-v", "#{helper_dir}:/trollolo/helper"] + args += ["-v", "#{working_dir}:/trollolo/data"] + args += ["-w", "/trollolo/data"] + args += ["matplotlib"] + args += ["/trollolo/helper/create_burndown.py", sprint_number] + args += extra_args + run_command(cmd: "docker", args: args) +end +def compare_images_for_sprint(sprint_number, extra_args = []) + @working_dir = given_directory do + given_file("burndown-data-#{sprint_number}.yaml", from: "create_burndown_helper/burndown-data-#{sprint_number}.yaml") + end + + result = run_helper(@working_dir, sprint_number, extra_args) + expect(result).to exit_with_success("") + expect(File.join(@working_dir, "burndown-#{sprint_number}.png")). + to be_same_image_as("create_burndown_helper/burndown-#{sprint_number}.png") +end + describe "create_burndown.py" do use_given_filesystem(keep_files: true) - it "creates burndown chart for sprint 23" do - @working_dir = given_directory do - given_file("burndown-data-23.yaml", from: "create_burndown_helper/burndown-data-23.yaml") + before(:all) do + if `docker images -q trollolo-matplotlib`.empty? + raise "Required docker image 'trollolo-matplotlib' not found. Build it with 'docker build -t trollolo-matplotlib spec/containers/matplotlib'" end + end - result = run_command(cmd: HELPER_SCRIPT, args: ["23", "--output=#{@working_dir}", "--no-head"]) - expect(result).to exit_with_success("") - expect(File.join(@working_dir, "burndown-23.png")). - to be_same_image_as("create_burndown_helper/burndown-23.png") + it "creates burndown chart with varying number of total story points and tasks" do + compare_images_for_sprint("23") end - it "creates burndown chart for sprint 31" do - @working_dir = given_directory do - given_file("burndown-data-31.yaml", from: "create_burndown_helper/burndown-data-31.yaml") - end + it "creates burndown chart with done tasks at the beginning" do + compare_images_for_sprint("31") + end - result = run_command(cmd: HELPER_SCRIPT, args: ["31", "--output=#{@working_dir}", "--no-head"]) - expect(result).to exit_with_success("") - expect(File.join(@working_dir, "burndown-31.png")). - to be_same_image_as("create_burndown_helper/burndown-31.png") + it "creates burndown chart of unfinished sprint" do + compare_images_for_sprint("35") end - it "creates burndown chart for sprint 35" do - @working_dir = given_directory do - given_file("burndown-data-35.yaml", from: "create_burndown_helper/burndown-data-35.yaml") - end + it "creates burndown chart with fast lane and no tasks" do + compare_images_for_sprint("08", ["--no-tasks", "--with-fast-lane"]) + end - result = run_command(cmd: HELPER_SCRIPT, args: ["35", "--output=#{@working_dir}", "--no-head"]) - expect(result).to exit_with_success("") - expect(File.join(@working_dir, "burndown-35.png")). - to be_same_image_as("create_burndown_helper/burndown-35.png") + it "creates perfect burndown chart" do + compare_images_for_sprint("42") end - it "creates burndown chart for sprint 8" do - @working_dir = given_directory do - given_file("burndown-data-08.yaml", from: "create_burndown_helper/burndown-data-08.yaml") - end - - result = run_command(cmd: HELPER_SCRIPT, - args: ["08", "--output=#{@working_dir}", "--no-tasks", "--with-fast-lane", "--no-head"]) - expect(result).to exit_with_success("") - expect(File.join(@working_dir, "burndown-08.png")). - to be_same_image_as("create_burndown_helper/burndown-08.png") + it "creates burndown chart with unplanned cards" do + compare_images_for_sprint("56") end end