Class: AmiSpec::ServerSpec
- Inherits:
-
Object
- Object
- AmiSpec::ServerSpec
- Defined in:
- lib/ami_spec/server_spec.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ ServerSpec
constructor
A new instance of ServerSpec.
- #run ⇒ Object
Constructor Details
#initialize(options) ⇒ ServerSpec
Returns a new instance of ServerSpec.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ami_spec/server_spec.rb', line 8 def initialize() instance = .fetch(:instance) public_ip = .fetch(:aws_public_ip) @debug = .fetch(:debug) @ip = public_ip ? instance.public_ip_address : instance.private_ip_address @role = instance..find{ |tag| tag.key == 'AmiSpec' }.value @spec = .fetch(:specs) @user = .fetch(:ssh_user) @key_file = .fetch(:key_file) @buildkite = .fetch(:buildkite) end |
Instance Method Details
#run ⇒ Object
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 |
# File 'lib/ami_spec/server_spec.rb', line 21 def run if @buildkite puts "--- Running tests for #{@role}" else puts "Running tests for #{@role}" end $LOAD_PATH.unshift(@spec) unless $LOAD_PATH.include?(@spec) begin require File.join(@spec, 'spec_helper') rescue LoadError puts 'Spec Helper does not exist. Skipping!' end set :backend, :ssh set :host, @ip set :ssh_options, :user => @user, :keys => [@key_file], :verify_host_key => :never RSpec.configuration.fail_fast = true if @debug RSpec::Core::Runner.disable_autorun! result = RSpec::Core::Runner.run(Dir.glob("#{@spec}/#{@role}/*_spec.rb")) # We can't use Rspec.clear_examples here because it also clears the shared_examples. # As shared examples are loaded in via the spec_helper, we cannot reload them. RSpec.world.example_groups.clear Specinfra::Backend::Ssh.clear puts "^^^ +++" if @buildkite && !result.zero? result.zero? end |