Class: Cucumber::Chef::TestRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/chef/test_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(features_path, stdout = STDOUT, stderr = STDERR, stdin = STDIN) ⇒ TestRunner

Returns a new instance of TestRunner.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cucumber/chef/test_runner.rb', line 31

def initialize(features_path, stdout=STDOUT, stderr=STDERR, stdin=STDIN)
  @features_path = features_path
  @stdout, @stderr, @stdin = stdout, stderr, stdin
  @stdout.sync = true if @stdout.respond_to?(:sync=)

  @test_lab = Cucumber::Chef::TestLab.new(@stdout, @stderr, @stdin)

  @ssh = Cucumber::Chef::SSH.new(@stdout, @stderr, @stdin)
  @ssh.config[:host] = @test_lab.labs_running.first.public_ip_address
  @ssh.config[:ssh_user] = "ubuntu"
  @ssh.config[:identity_file] = Cucumber::Chef.locate(:file, ".cucumber-chef", "id_rsa-#{@ssh.config[:ssh_user]}")

  @stdout.puts("Cucumber-Chef Test Runner Initalized!")
end

Instance Method Details

#run(destroy, *args) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/cucumber/chef/test_runner.rb', line 48

def run(destroy, *args)
  reset_project
  upload_project

  @stdout.puts("Executing Cucumber-Chef Test Runner")
  remote_path = File.join("/", "home", "ubuntu", "features")
  cucumber_options = args.flatten.compact.join(" ")
  env = ( destroy ? "DESTROY=1" : nil )
  command = [ "cd #{remote_path}", "&&", "sudo", env, "cucumber", cucumber_options, "--exclude support/cookbooks", "--exclude support/roles", "--exclude support/data_bags", "--exclude support/keys", "." ].flatten.compact.join(" ")

  @ssh.exec(command)
end