From dcf1d76bada8ae450d19927e71928da17f1460b8 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Mon, 18 Jan 2021 12:10:32 -0800 Subject: [PATCH] Use the standard Rakefile and spec helper Signed-off-by: Tim Smith --- .rspec | 3 +++ Rakefile | 17 ++++++++++------- spec/spec_helper.rb | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 .rspec diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..43ae203 --- /dev/null +++ b/.rspec @@ -0,0 +1,3 @@ +--color +--require spec_helper +--format documentation diff --git a/Rakefile b/Rakefile index ea7ffeb..2dc6a2f 100644 --- a/Rakefile +++ b/Rakefile @@ -1,12 +1,15 @@ require "bundler/gem_tasks" require "rspec/core/rake_task" +RSpec::Core::RakeTask.new(:test) -RSpec::Core::RakeTask.new(:spec) - -require "chefstyle" -require "rubocop/rake_task" -RuboCop::RakeTask.new(:style) do |task| - task.options << "--display-cop-names" +begin + require "chefstyle" + require "rubocop/rake_task" + RuboCop::RakeTask.new(:style) do |task| + task.options += ["--display-cop-names", "--no-color"] + end +rescue LoadError + puts "chefstyle is not available. (sudo) gem install chefstyle to do style checking." end -task default: %i{spec style} +task default: %i{test style} diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8c7065c..7823b26 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,3 +18,17 @@ require "rspec" require_relative "../lib/kitchen/driver/gce" + +RSpec.configure do |config| + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +end \ No newline at end of file