Skip to content

Commit

Permalink
Increase min coverage acceptance
Browse files Browse the repository at this point in the history
  • Loading branch information
shiroyasha committed Mar 19, 2017
1 parent 3aa4f42 commit f3075bd
Show file tree
Hide file tree
Showing 15 changed files with 384 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
/vendor
/coverage
config/cucumber.yml
/feature
/features
15 changes: 1 addition & 14 deletions config/cucumber.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
default: --format pretty --profile semaphoreci --profile semaphoreci --profile semaphoreci --profile semaphoreci --profile semaphoreci --profile semaphoreci --profile semaphoreci --profile semaphoreci --profile semaphoreci --profile semaphoreci --profile semaphoreci --profile semaphoreci --profile semaphoreci --profile semaphoreci --profile semaphoreci --profile semaphoreci
semaphoreci: --format json --out=../cucumber_report.json
semaphoreci: --format json --out=../cucumber_report.json
semaphoreci: --format json --out=../cucumber_report.json
semaphoreci: --format json --out=../cucumber_report.json
semaphoreci: --format json --out=../cucumber_report.json
semaphoreci: --format json --out=../cucumber_report.json
semaphoreci: --format json --out=../cucumber_report.json
semaphoreci: --format json --out=../cucumber_report.json
semaphoreci: --format json --out=../cucumber_report.json
semaphoreci: --format json --out=../cucumber_report.json
semaphoreci: --format json --out=../cucumber_report.json
semaphoreci: --format json --out=../cucumber_report.json
semaphoreci: --format json --out=../cucumber_report.json
default: --format pretty --profile semaphoreci --profile semaphoreci --profile semaphoreci
semaphoreci: --format json --out=../cucumber_report.json
semaphoreci: --format json --out=../cucumber_report.json
semaphoreci: --format json --out=../cucumber_report.json
2 changes: 0 additions & 2 deletions exe/cucumber_booster
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

require "test_boosters"

TestBoosters.run_cucumber_config

cli_options = TestBoosters::CliParser.parse
thread_index = cli_options[:index] - 1
cucumber_booster = TestBoosters::Cucumber::Booster.new(thread_index)
Expand Down
8 changes: 0 additions & 8 deletions features/hello_cucumber.feature

This file was deleted.

7 changes: 0 additions & 7 deletions features/step_definitions/hello_steps.rb

This file was deleted.

Empty file removed features/support/env.rb
Empty file.
4 changes: 2 additions & 2 deletions lib/test_boosters/cucumber/thread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def display_thread_info

def run_cucumber_config
TestBoosters::Shell.display_title("Injecting Cucumber Config")
CucumberBoosterConfig::CLI.start ["inject", "."]
CucumberBoosterConfig::CLI.start ["inject", Dir.pwd]
end

def run_cucumber
Expand All @@ -62,7 +62,7 @@ def cucumber_command
end

def report_path
@report_path ||= ENV["REPORT_PATH"] || "#{ENV["HOME"]}/cucumber_report.json"
@report_path ||= ENV["REPORT_PATH"] || "cucumber_report.json"
end

end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
require "spec_helper"

describe "Cucumber Booster behaviour when split configuration is empty" do

let(:specs_path) { "features" }
let(:split_configuration_path) { "/tmp/cucumber_split_configuration.json" }
let(:cucumber_report_path) { "cucumber_report.json" }

before do
# Set up environment variables
ENV["SPEC_PATH"] = specs_path
ENV["CUCUMBER_SPLIT_CONFIGURATION_PATH"] = split_configuration_path
ENV["REPORT_PATH"] = cucumber_report_path

# Set up test dir structure
FileUtils.rm_rf(specs_path)
FileUtils.mkdir_p(specs_path)
FileUtils.rm_f(cucumber_report_path)

# Create spec files
Support::CucumberFilesFactory.create(:name => "A", :path => "#{specs_path}/a.feature")
Support::CucumberFilesFactory.create(:name => "B", :path => "#{specs_path}/b.feature")
Support::CucumberFilesFactory.create(:name => "C", :path => "#{specs_path}/admin/c.feature")

# Construct empty split configuration
File.write(split_configuration_path, [{ :files => [] }, { :files => [] }, { :files => [] }].to_json)

# make sure that everything is set up as it should be
expect(File.exist?(cucumber_report_path)).to eq(false)

expect(File.exist?(split_configuration_path)).to eq(true)

expect(Dir["#{specs_path}/**/*"].sort).to eq([
"#{specs_path}/a.feature",
"#{specs_path}/admin",
"#{specs_path}/admin/c.feature",
"#{specs_path}/b.feature",
"#{specs_path}/step_definitions",
"#{specs_path}/step_definitions/a_step.rb",
"#{specs_path}/step_definitions/b_step.rb",
"#{specs_path}/step_definitions/c_step.rb"
])
end

specify "first thread's behaviour" do
output = `cucumber_booster --thread 1`

puts output

expect(output).to include("1 scenario (1 passed)")
expect($?.exitstatus).to eq(0)

expect(File.exist?(cucumber_report_path)).to eq(true)
end

specify "second thread's behaviour" do
output = `cucumber_booster --thread 2`

expect(output).to include("1 example, 1 failure")
expect($?.exitstatus).to eq(1)

expect(File.exist?(rspec_report_path)).to eq(true)
end

specify "third thread's behaviour" do
output = `cucumber_booster --thread 3`

expect(output).to include("1 example, 0 failure")
expect($?.exitstatus).to eq(0)

expect(File.exist?(rspec_report_path)).to eq(true)
end

end
77 changes: 77 additions & 0 deletions spec/integration/cucumber_booster/failing_specs_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
require "spec_helper"

describe "RSpec Booster behvaviour when the tests fail" do

let(:project_path) { "/tmp/project_path-#{SecureRandom.uuid}" }
let(:specs_path) { "#{project_path}/spec" }
let(:split_configuration_path) { "/tmp/rspec_split_configuration.json" }
let(:rspec_report_path) { "/tmp/rspec_report.json" }

before do
# Set up environment variables
ENV["SPEC_PATH"] = specs_path
ENV["RSPEC_SPLIT_CONFIGURATION_PATH"] = split_configuration_path
ENV["REPORT_PATH"] = rspec_report_path

# Set up test dir structure
FileUtils.rm_rf(specs_path)
FileUtils.mkdir_p(specs_path)
FileUtils.rm_f(rspec_report_path)

# Create spec files
Support::RspecFilesFactory.create(:path => "#{specs_path}/a_spec.rb", :result => :failing)
Support::RspecFilesFactory.create(:path => "#{specs_path}/b_spec.rb", :result => :failing)
Support::RspecFilesFactory.create(:path => "#{specs_path}/lib/c_spec.rb", :result => :passing)

# Construct spec helper file
File.write("#{specs_path}/spec_helper.rb", "")

# Construct a split configuration
File.write(split_configuration_path, [
{ :files => ["#{specs_path}/a_spec.rb"] },
{ :files => ["#{specs_path}/b_spec.rb"] },
{ :files => [] }
].to_json)

# make sure that everything is set up as it should be
expect(File.exist?(rspec_report_path)).to eq(false)

expect(File.exist?(split_configuration_path)).to eq(true)

expect(Dir["#{specs_path}/**/*"].sort).to eq([
"#{specs_path}/a_spec.rb",
"#{specs_path}/b_spec.rb",
"#{specs_path}/lib",
"#{specs_path}/lib/c_spec.rb",
"#{specs_path}/spec_helper.rb"
])
end

specify "first thread's behaviour" do
output = `cd #{project_path} && rspec_booster --thread 1`

expect(output).to include("2 examples, 1 failure")
expect($?.exitstatus).to eq(1)

expect(File.exist?(rspec_report_path)).to eq(true)
end

specify "second thread's behaviour" do
output = `cd #{project_path} && rspec_booster --thread 2`

expect(output).to include("1 example, 1 failure")
expect($?.exitstatus).to eq(1)

expect(File.exist?(rspec_report_path)).to eq(true)
end

specify "third thread's behaviour" do
output = `cd #{project_path} && rspec_booster --thread 3`

expect(output).to include("No files to run in this thread!")
expect($?.exitstatus).to eq(0)

expect(File.exist?(rspec_report_path)).to eq(false)
end

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
require "spec_helper"

describe "RSpec Booster behvaviour when split configuration is malformed" do

let(:project_path) { "/tmp/project_path-#{SecureRandom.uuid}" }
let(:specs_path) { "#{project_path}/spec" }
let(:split_configuration_path) { "/tmp/rspec_split_configuration.json" }
let(:rspec_report_path) { "/tmp/rspec_report.json" }

before do
# Set up environment variables
ENV["SPEC_PATH"] = specs_path
ENV["RSPEC_SPLIT_CONFIGURATION_PATH"] = split_configuration_path
ENV["REPORT_PATH"] = rspec_report_path

# Set up test dir structure
FileUtils.rm_rf(specs_path)
FileUtils.mkdir_p(specs_path)
FileUtils.rm_f(rspec_report_path)

# Create spec files
Support::RspecFilesFactory.create(:path => "#{specs_path}/a_spec.rb", :result => :passing)
Support::RspecFilesFactory.create(:path => "#{specs_path}/b_spec.rb", :result => :passing)
Support::RspecFilesFactory.create(:path => "#{specs_path}/lib/c_spec.rb", :result => :passing)

# Construct spec helper file
File.write("#{specs_path}/spec_helper.rb", "")

# Construct a broken split configuration
File.write(split_configuration_path, { :lol => "Batman is stronger than Superman" }.to_json)

# make sure that everything is set up as it should be
expect(File.exist?(rspec_report_path)).to eq(false)

expect(File.exist?(split_configuration_path)).to eq(true)

expect(Dir["#{specs_path}/**/*"].sort).to eq([
"#{specs_path}/a_spec.rb",
"#{specs_path}/b_spec.rb",
"#{specs_path}/lib",
"#{specs_path}/lib/c_spec.rb",
"#{specs_path}/spec_helper.rb"
])
end

specify "first thread's behaviour" do
output = `cd #{project_path} && rspec_booster --thread 1`

expect(output).to include("[ERROR] The split configuration file is malformed!")
expect($?.exitstatus).to eq(1)

expect(File.exist?(rspec_report_path)).to eq(false)
end

specify "second thread's behaviour" do
output = `cd #{project_path} && rspec_booster --thread 2`

expect(output).to include("[ERROR] The split configuration file is malformed!")
expect($?.exitstatus).to eq(1)

expect(File.exist?(rspec_report_path)).to eq(false)
end

specify "third thread's behaviour" do
output = `cd #{project_path} && rspec_booster --thread 3`

expect(output).to include("[ERROR] The split configuration file is malformed!")
expect($?.exitstatus).to eq(1)

expect(File.exist?(rspec_report_path)).to eq(false)
end

end
63 changes: 63 additions & 0 deletions spec/integration/cucumber_booster/no_spec_files_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
require "spec_helper"

describe "RSpec Booster behvaviour there are no spec files" do

let(:project_path) { "/tmp/project_path-#{SecureRandom.uuid}" }
let(:specs_path) { "#{project_path}/spec" }
let(:split_configuration_path) { "/tmp/rspec_split_configuration.json" }
let(:rspec_report_path) { "/tmp/rspec_report.json" }

before do
# Set up environment variables
ENV["SPEC_PATH"] = specs_path
ENV["RSPEC_SPLIT_CONFIGURATION_PATH"] = split_configuration_path
ENV["REPORT_PATH"] = rspec_report_path

# Set up test dir structure
FileUtils.rm_rf(specs_path)
FileUtils.mkdir_p(specs_path)
FileUtils.rm_f(rspec_report_path)

# Construct a split configuration
File.write(split_configuration_path, [
{ :files => ["#{specs_path}/a_spec.rb"] },
{ :files => ["#{specs_path}/b_spec.rb"] },
{ :files => [] }
].to_json)

# make sure that everything is set up as it should be
expect(File.exist?(rspec_report_path)).to eq(false)

expect(File.exist?(split_configuration_path)).to eq(true)

expect(Dir["#{specs_path}/**/*"].sort).to eq([])
end

specify "first thread's behaviour" do
output = `cd #{project_path} && rspec_booster --thread 1`

expect($?.exitstatus).to eq(0)
expect(output).to include("No files to run in this thread!")

expect(File.exist?(rspec_report_path)).to eq(false)
end

specify "second thread's behaviour" do
output = `cd #{project_path} && rspec_booster --thread 2`

expect($?.exitstatus).to eq(0)
expect(output).to include("No files to run in this thread!")

expect(File.exist?(rspec_report_path)).to eq(false)
end

specify "third thread's behaviour" do
output = `cd #{project_path} && rspec_booster --thread 3`

expect($?.exitstatus).to eq(0)
expect(output).to include("No files to run in this thread!")

expect(File.exist?(rspec_report_path)).to eq(false)
end

end
12 changes: 12 additions & 0 deletions spec/integration/cucumber_booster/no_split_configuration_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require "spec_helper"

describe "RSpec Booster behvaviour when there is no split configuration" do

before do
ENV["SPEC_PATH"] = "fixtures/green_rspec_project/spec"
end

it "runs specs based on leftover files colculation" do
end

end
Loading

0 comments on commit f3075bd

Please sign in to comment.