Rakefile in how_is-11.0.0 vs Rakefile in how_is-12.0.0
- old
+ new
@@ -1,30 +1,62 @@
-require "bundler/gem_tasks"
-require "rspec/core/rake_task"
+require 'bundler/gem_tasks'
+require 'rspec/core/rake_task'
+require 'timecop'
+#require 'vcr'
+require './spec/vcr_helper.rb'
+require 'how_is'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
-namespace :test do
- task :units => :spec
+class HelperFunctions
+ def self.freeze_time(&block)
+ date = DateTime.parse('2016-11-01').new_offset(0)
+ Timecop.freeze(date) do
+ yield
+ end
+ end
- desc 'Run integration tests tag'
- RSpec::Core::RakeTask.new('integration') do |task|
- task.pattern = './spec/**/*_spec.rb'
- task.rspec_opts = '--tag integration'
+ def self.generate_report(repository, format)
+ freeze_time do
+ report = nil
+
+ options = {
+ repository: repository,
+ format: format,
+ }
+
+ cassette = repository.gsub('/', '-')
+ VCR.use_cassette(cassette) do
+ report = HowIs.generate_report(**options)
+ end
+
+ filename = "#{cassette}-report.#{format}"
+ path = File.expand_path("spec/data/#{filename}", __dir__)
+ File.open(path, 'w') do |f|
+ f.puts report
+ # HACK: Trailing newline is missing, otherwise.
+ f.puts if format == 'html'
+ end
+ end
end
+end
- desc 'Run slow tests tag'
- RSpec::Core::RakeTask.new('integration') do |task|
- task.pattern = './spec/**/*_spec.rb'
- task.rspec_opts = '--tag slow'
+namespace :generate_reports do
+ desc 'Generate example HTML reports.'
+ task :html do
+ %w[
+ how-is/example-repository
+ how-is/example-empty-repository
+ ].each do |repo|
+ HelperFunctions.generate_report(repo, 'html')
+ end
end
-
- desc 'Run all tests regardless of tags'
- RSpec::Core::RakeTask.new('all') do |task|
- task.pattern = './spec/**/*_spec.rb'
- # Load the tagless options file
- task.rspec_opts = '-O .rspec-ignore-tags'
+ desc 'Generate example JSON reports.'
+ task :json do
+ HelperFunctions.generate_report('how-is/example-repository', 'json')
end
+
+ task :all => [:html, :json]
end