|
4 | 4 | include_context "cucumber runner" |
5 | 5 |
|
6 | 6 | let(:allure_cli) { Allure::Util.allure_cli } |
| 7 | + let(:results_dir) { Allure::CucumberConfig.results_directory } |
7 | 8 |
|
8 | | - before(:all) do |
9 | | - if File.exist?(Allure::CucumberConfig.results_directory) |
10 | | - FileUtils.remove_dir(Allure::CucumberConfig.results_directory) |
| 9 | + before(:each) do |
| 10 | + FileUtils.remove_dir(results_dir) if File.exist?(results_dir) |
| 11 | + end |
| 12 | + |
| 13 | + it "Generates allure json results files", integration: true do |
| 14 | + run_cucumber_cli("features/features/simple.feature") |
| 15 | + |
| 16 | + container = File.new(Dir["#{results_dir}/*container.json"].first) |
| 17 | + result = File.new(Dir["#{results_dir}/*result.json"].first) |
| 18 | + |
| 19 | + aggregate_failures "Results files should exist" do |
| 20 | + expect(File.exist?(container)).to be_truthy |
| 21 | + expect(File.exist?(result)).to be_truthy |
| 22 | + end |
| 23 | + |
| 24 | + container_json = JSON.parse(File.read(container), symbolize_names: true) |
| 25 | + result_json = JSON.parse(File.read(result), symbolize_names: true) |
| 26 | + aggregate_failures "Json results should contain valid data" do |
| 27 | + expect(container_json[:name]).to eq("Add a to b") |
| 28 | + expect(result_json[:description]).to eq("Simple scenario description") |
| 29 | + expect(result_json[:steps].size).to eq(4) |
11 | 30 | end |
12 | 31 | end |
13 | 32 |
|
14 | | - it "Allure commandline generates report", integration: true do |
| 33 | + it "Allure commandline generates report", reporter: true do |
15 | 34 | run_cucumber_cli("features/features") |
16 | 35 |
|
17 | | - expect(`#{allure_cli} generate -c #{Allure::CucumberConfig.results_directory} -o reports/allure-report`.chomp).to( |
| 36 | + expect(`#{allure_cli} generate -c #{results_dir} -o reports/allure-report`.chomp).to( |
18 | 37 | eq("Report successfully generated to reports/allure-report"), |
19 | 38 | ) |
20 | 39 | end |
|
0 commit comments