Class: PoiseRuby::SpecHelper::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/poise_ruby/spec_helper/helper.rb

Overview

Not using Halite::HelperBase to avoid the dependency.

Class Method Summary collapse

Class Method Details

.installObject



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
74
75
76
77
78
79
80
81
82
# File 'lib/poise_ruby/spec_helper/helper.rb', line 27

def self.install
  # Load and configure Serverspec.
  require 'serverspec'
  set :backend, :exec

  # Set up the shared example for ruby_runtime_test.
  RSpec.shared_examples 'a ruby_runtime_test' do |ruby_name, version=nil|
    let(:ruby_name) { ruby_name }
    let(:ruby_path) { File.join('', 'root', "ruby_test_#{ruby_name}") }
    # Helper for all the file checks.
    def self.assert_file(rel_path, should_exist=true, &block)
      describe rel_path do
        subject { file(File.join(ruby_path, rel_path)) }
        # Do nothing for nil.
        if should_exist == true
          it { is_expected.to be_a_file }
        elsif should_exist == false
          it { is_expected.to_not exist }
        end
        instance_eval(&block) if block
      end
    end

    describe 'ruby_runtime' do
      assert_file('version') do
        its(:content) { is_expected.to start_with version } if version
      end
    end

    describe 'ruby_gem' do
      assert_file('require_thor_before', false)
      assert_file('require_thor_mid')
      assert_file('require_thor_after', false)
      assert_file('sentinel_thor')
      assert_file('sentinel_thor2', false)

      assert_file('sentinel_bundler', false)
    end

    describe 'bundle_install' do
      assert_file('require_hashie') do
        its(:content) { is_expected.to_not eq '' }
      end
      assert_file('require_tomlrb') do
        its(:content) { is_expected.to eq '1.1.0' }
      end
      assert_file('sentinel_thor_bundle', false)
    end

    describe 'bundler + ruby_execute' do
      assert_file('unicorn_version') do
        its(:content) { is_expected.to eq "unicorn v4.9.0\n" }
      end
    end
  end # /shared_examples a ruby_runtime_test
end