Class: Onceover::Runner
- Inherits:
-
Object
- Object
- Onceover::Runner
- Defined in:
- lib/onceover/runner.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Instance Method Summary collapse
-
#initialize(repo, config, mode = [:spec, :acceptance]) ⇒ Runner
constructor
A new instance of Runner.
- #prepare! ⇒ Object
- #run_acceptance! ⇒ Object
- #run_spec! ⇒ Object
Constructor Details
#initialize(repo, config, mode = [:spec, :acceptance]) ⇒ Runner
Returns a new instance of Runner.
6 7 8 9 10 11 |
# File 'lib/onceover/runner.rb', line 6 def initialize(repo, config, mode = [:spec, :acceptance]) @repo = repo @config = config @mode = [mode].flatten @command_prefix = ENV['BUNDLE_GEMFILE'] ? 'bundle exec ' : '' end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/onceover/runner.rb', line 4 def config @config end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
3 4 5 |
# File 'lib/onceover/runner.rb', line 3 def repo @repo end |
Instance Method Details
#prepare! ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/onceover/runner.rb', line 13 def prepare! unless @config.skip_r10k # Deploy the puppetfile @config.r10k_deploy_local(@repo) end # Remove the entire spec directory to make sure we have # all the latest tests FileUtils.rm_rf("#{@repo.tempdir}/spec") # Create the other directories we need FileUtils.mkdir_p("#{@repo.tempdir}/spec/classes") FileUtils.mkdir_p("#{@repo.tempdir}/spec/acceptance/nodesets") # Copy our entire spec directory over FileUtils.cp_r("#{@repo.spec_dir}","#{@repo.tempdir}") # Create the Rakefile so that we can take advantage of the existing tasks @config.write_rakefile(@repo.tempdir, "spec/classes/**/*_spec.rb") # Create spec_helper.rb @config.write_spec_helper("#{@repo.tempdir}/spec",@repo) # Create spec_helper_accpetance.rb @config.write_spec_helper_acceptance("#{@repo.tempdir}/spec",@repo) # TODO: Remove all tests that do not match set tags if @mode.include?(:spec) # Verify all of the spec tests @config.spec_tests.each { |test| @config.verify_spec_test(@repo,test) } # Deduplicate and write the tests (Spec and Acceptance) @config.run_filters(Onceover::Test.deduplicate(@config.spec_tests)).each do |test| @config.write_spec_test("#{@repo.tempdir}/spec/classes",test) end end if @mode.include?(:acceptance) # Verify all of the acceptance tests @config.acceptance_tests.each { |test| @config.verify_acceptance_test(@repo,test) } # Write them out @config.write_acceptance_tests("#{@repo.tempdir}/spec/acceptance",@config.run_filters(Onceover::Test.deduplicate(@config.acceptance_tests))) end # Parse the current hiera config, modify, and write it to the temp dir unless @repo.hiera_config ==nil hiera_config = @repo.hiera_config hiera_config.each do |setting,value| if value.is_a?(Hash) if value.has_key?(:datadir) hiera_config[setting][:datadir] = "#{@repo.tempdir}/#{@repo.environmentpath}/production/#{value[:datadir]}" end end end File.write("#{@repo.tempdir}/#{@repo.environmentpath}/production/hiera.yaml",hiera_config.to_yaml) end @config.create_fixtures_symlinks(@repo) end |
#run_acceptance! ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/onceover/runner.rb', line 84 def run_acceptance! Dir.chdir(@repo.tempdir) do #`bundle install --binstubs` #`bin/rake spec_standalone` logger.debug "Running #{@command_prefix}rake acceptance from #{@repo.tempdir}" exec("#{@command_prefix}rake acceptance") end end |
#run_spec! ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/onceover/runner.rb', line 75 def run_spec! Dir.chdir(@repo.tempdir) do #`bundle install --binstubs` #`bin/rake spec_standalone` logger.debug "Running #{@command_prefix}rake spec_standalone from #{@repo.tempdir}" exec("#{@command_prefix}rake spec_standalone") end end |