Class: Jacuzzi

Inherits:
Object
  • Object
show all
Defined in:
lib/jacuzzi.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeJacuzzi

Returns a new instance of Jacuzzi.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/jacuzzi.rb', line 8

def initialize
  puts "Welcome to the jacuzzi -- who knows what bugs you'll catch?"
  @test_paths = []

  puts "Building temporary directories ..."
  %x[mkdir ./.jacuzzi]
  %x[mkdir ./.jacuzzi/spec]
  %x[mkdir ./.jacuzzi/tmp]

  puts "Generating spec helper ..."
  spec_helper_content = <<HEREDOC
RSpec.configure do |config|
config.include Capybara::DSL
end
HEREDOC
  File.open('./.jacuzzi/spec/spec_helper.rb', 'w') {|file|
    file.write(spec_helper_content)
  }
end

Instance Attribute Details

#app_hostObject

Returns the value of attribute app_host.



6
7
8
# File 'lib/jacuzzi.rb', line 6

def app_host
  @app_host
end

#test_pathsObject

Returns the value of attribute test_paths.



6
7
8
# File 'lib/jacuzzi.rb', line 6

def test_paths
  @test_paths
end

#test_sourceObject

Returns the value of attribute test_source.



6
7
8
# File 'lib/jacuzzi.rb', line 6

def test_source
  @test_source
end

Instance Method Details

#coolObject



63
64
65
66
# File 'lib/jacuzzi.rb', line 63

def cool
  puts "Shut this mutha down (removing temporary files) ..."
  %x[rm -rf ./.jacuzzi]
end

#heatObject



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
# File 'lib/jacuzzi.rb', line 28

def heat
  puts "Cranking up the heat (retrieving tests) ..."
  %x[git clone #{@test_source} ./.jacuzzi/tmp/tests]

  Find.find('./.jacuzzi/tmp/tests/') do |path|
    @test_paths << path if File.extname(path) == '.rb'
  end

  puts "Tests retrieved:"
  @test_paths.each do |path|
    %x[cp #{path} ./.jacuzzi/spec/#{File.basename(path)}]
  end
  p @test_paths

  puts "Generating Capybara config settings ..."
  capybara_spec_content = <<HEREDOC
require 'rspec'
require 'capybara'
require 'capybara/dsl'
require './.jacuzzi/spec/spec_helper.rb'

Capybara.default_driver = :selenium
Capybara.app_host       = "#{@app_host}"
HEREDOC
  File.open('./.jacuzzi/spec/capybara_spec.rb', 'w') {|file|
    file.write(capybara_spec_content)
  }
end

#whirlObject



57
58
59
60
61
# File 'lib/jacuzzi.rb', line 57

def whirl
  puts "Start up the whirlpool, baybay (running the tests):"
  %x[rspec ./.jacuzzi/spec -c -f documentation]
  puts "Ahhhh ... How relaxing, to sit in the jacuzzi."
end