Class: Wire::SpecTemplates

Inherits:
Object
  • Object
show all
Defined in:
lib/wire/commands/spec_templates.rb

Overview

stateless erb template methods used by spec_command.rb

Class Method Summary collapse

Class Method Details

.template_rakefileObject

generate template part returns

  • erb template for Rakefile



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
# File 'lib/wire/commands/spec_templates.rb', line 25

def self.template_rakefile
  <<ERB
require 'rake'
require 'rspec/core/rake_task'

task :spec    => 'spec:all'
task :default => :spec

namespace :spec do
  targets = []
  Dir.glob('./spec/*').each do |dir|
next unless File.directory?(dir)
targets << File.basename(dir)
  end

  task :all     => targets
  task :default => :all

  targets.each do |target|
desc "Run serverspec tests to \#{target}"
RSpec::Core::RakeTask.new(target.to_sym) do |t|
  ENV['TARGET_HOST'] = target
  t.pattern = "spec/\#{target}/*_spec.rb"
  t.rspec_opts = '--format documentation --color'
end
  end
end
ERB
end

.template_spec_helperObject

generate template part returns

  • erb template for spec_helper.rb file



14
15
16
17
18
19
20
# File 'lib/wire/commands/spec_templates.rb', line 14

def self.template_spec_helper
  <<ERB
require 'serverspec'

set :backend, :exec
ERB
end