vagrant-hypconfigmgmt 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rspec +1 -0
- data/Makefile +3 -1
- data/README.md +2 -3
- data/lib/vagrant-hypconfigmgmt/.command.rb.swo +0 -0
- data/lib/vagrant-hypconfigmgmt/command.rb +224 -183
- data/lib/vagrant-hypconfigmgmt/version.rb +1 -1
- data/pkg/vagrant-hypconfigmgmt-0.0.2.gem +0 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/unit/command/call_spec.rb +93 -0
- data/spec/unit/command/configure_magento_spec.rb +35 -0
- data/spec/unit/command/configure_php_spec.rb +35 -0
- data/spec/unit/command/configure_synced_folders_spec.rb +35 -0
- data/spec/unit/command/configure_vagrant_spec.rb +33 -0
- data/spec/unit/command/configure_varnish_spec.rb +35 -0
- data/spec/unit/command/ensure_attribute_configured_spec.rb +100 -0
- data/spec/unit/command/ensure_magento_mounts_configured_spec.rb +268 -0
- data/spec/unit/command/ensure_required_plugins_are_installed_spec.rb +78 -0
- data/spec/unit/command/ensure_setting_exists_spec.rb +50 -0
- data/spec/unit/command/ensure_settings_are_configured_spec.rb +71 -0
- data/spec/unit/command/ensure_vagrant_box_type_configured_spec.rb +78 -0
- data/spec/unit/command/get_magento_version_spec.rb +57 -0
- data/spec/unit/command/get_options_string_spec.rb +48 -0
- data/spec/unit/command/get_php_version_spec.rb +56 -0
- data/spec/unit/command/get_setting_spec.rb +55 -0
- data/spec/unit/command/get_varnish_state_spec.rb +56 -0
- data/spec/unit/command/inform_if_gatling_not_installed_spec.rb +67 -0
- data/spec/unit/command/retrieve_settings_spec.rb +39 -0
- data/spec/unit/command/update_settings_spec.rb +30 -0
- data/spec/unit/command/use_default_input_if_input_empty_spec.rb +30 -0
- data/spec/unit/command/validate_magento2_root_spec.rb +101 -0
- data/vagrant-hypconfigmgmt.gemspec +3 -0
- metadata +70 -3
- data/pkg/vagrant-hypconfigmgmt-0.0.1.gem +0 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
describe VagrantHypconfigmgmt::Command do
|
8
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
9
|
+
let(:app) { }
|
10
|
+
let(:env) { { :ui => ui } }
|
11
|
+
|
12
|
+
# pretend env contains the Vagrant ui element
|
13
|
+
let(:ui) do
|
14
|
+
double('ui').tap do |ui|
|
15
|
+
allow(ui).to receive(:info) { nil }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Call the method under test after every 'it'. Similar to setUp in Python TestCase
|
20
|
+
after do
|
21
|
+
subject.ensure_required_plugins_are_installed(env)
|
22
|
+
end
|
23
|
+
|
24
|
+
# instantiate class of which a method is to be tested
|
25
|
+
subject { described_class.new(app, env) }
|
26
|
+
|
27
|
+
# the method that we are going to test
|
28
|
+
describe "#ensure_required_plugins_are_installed" do
|
29
|
+
|
30
|
+
context "when no plugins are installed" do
|
31
|
+
it "installs the plugins" do
|
32
|
+
# test if the vagrant-hostmanager plugin is checked for being installed on the system and pretend it isn't
|
33
|
+
expect(Vagrant).to receive(:has_plugin?).once.with("vagrant-hostmanager").and_return(false)
|
34
|
+
# test if the vagrant-vbguest plugin is checked for being installed on the system it isn't
|
35
|
+
expect(Vagrant).to receive(:has_plugin?).once.with("vagrant-vbguest").and_return(false)
|
36
|
+
# check if a message about installing the vagrant-hostmanager plugin is printed
|
37
|
+
expect(ui).to receive(:info).once.with("Installing the vagrant-hostmanager plugin.")
|
38
|
+
# check if a message about installing the vagrant-vbguest plugin is printed
|
39
|
+
expect(ui).to receive(:info).once.with("Installing the vagrant-vbguest plugin.")
|
40
|
+
# check if a system call is done to install the vagrant-hostmanager plugin in a different process
|
41
|
+
expect(subject).to receive(:system).once.with("vagrant plugin install vagrant-hostmanager")
|
42
|
+
# check if a system call is done to install the vagrant-vbguest plugin in a different process
|
43
|
+
expect(subject).to receive(:system).once.with("vagrant plugin install vagrant-vbguest")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "when plugins are already installed" do
|
48
|
+
it "does not install the plugins" do
|
49
|
+
# test if the vagrant-hostmanager plugin is checked for being installed on the system and pretend it is
|
50
|
+
expect(Vagrant).to receive(:has_plugin?).once.with("vagrant-hostmanager").and_return(true)
|
51
|
+
# test if the vagrant-vbguest plugin is checked for being installed on the system it is
|
52
|
+
expect(Vagrant).to receive(:has_plugin?).once.with("vagrant-vbguest").and_return(true)
|
53
|
+
# check if no message is printed about installing a plugin
|
54
|
+
expect(ui).to receive(:info).never
|
55
|
+
# check if no system call is done to install a plugin
|
56
|
+
expect(subject).to receive(:system).never
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "when not all plugins are installed intall the missing ones" do
|
61
|
+
it "does not install the plugins" do
|
62
|
+
# test if the vagrant-hostmanager plugin is checked for being installed on the system and pretend it is
|
63
|
+
expect(Vagrant).to receive(:has_plugin?).once.with("vagrant-hostmanager").and_return(true)
|
64
|
+
# test if the vagrant-vbguest plugin is checked for being installed on the system it isn't
|
65
|
+
expect(Vagrant).to receive(:has_plugin?).once.with("vagrant-vbguest").and_return(false)
|
66
|
+
# check if no message is printed about installing the already installed plugin
|
67
|
+
expect(ui).to receive(:info).never.with("Installing the vagrant-hostmanager plugin.")
|
68
|
+
# check if no system call is done to install the already installed plugin
|
69
|
+
expect(subject).to receive(:system).never.with("vagrant plugin install vagrant-hostmanager")
|
70
|
+
# check if a message about installing the not yet installed plugin is printed
|
71
|
+
expect(ui).to receive(:info).once.with("Installing the vagrant-vbguest plugin.")
|
72
|
+
# check if a system call is done to install the not yet installed plugin in a different process
|
73
|
+
expect(subject).to receive(:system).once.with("vagrant plugin install vagrant-vbguest")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
|
8
|
+
describe VagrantHypconfigmgmt::Command do
|
9
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
10
|
+
let(:app) { }
|
11
|
+
let(:env) { { :ui => ui } }
|
12
|
+
let(:setting_name) { get_random_string() }
|
13
|
+
|
14
|
+
# pretend env contains the Vagrant ui element
|
15
|
+
let(:ui) { }
|
16
|
+
|
17
|
+
# Call the method under test after every 'it'. Similar to setUp in Python TestCase
|
18
|
+
after do
|
19
|
+
subject.ensure_setting_exists(setting_name)
|
20
|
+
end
|
21
|
+
|
22
|
+
# instantiate class of which a method is to be tested
|
23
|
+
subject { described_class.new(app, env) }
|
24
|
+
|
25
|
+
# the method that we are going to test
|
26
|
+
describe "#ensure_setting_exists" do
|
27
|
+
|
28
|
+
context "when the passed setting does not exist" do
|
29
|
+
let(:retrieved_settings) { { } }
|
30
|
+
let(:expected_settings) { { setting_name => { } } }
|
31
|
+
it "creates an empty hash for the setting and saves it back to disk" do
|
32
|
+
# pretend we retrieve the settings and they don't contain a magento block
|
33
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
34
|
+
# check if we update the settings with an empty magento block
|
35
|
+
expect(subject).to receive(:update_settings).once.with(expected_settings)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "when the passed setting already exists" do
|
40
|
+
let(:retrieved_settings) { { setting_name => { } } }
|
41
|
+
it "no settings are changed" do
|
42
|
+
# pretend we retrieve the settings and they already contain a magento block
|
43
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
44
|
+
# check if we don't change the retrieved settings because the setting already existed
|
45
|
+
expect(subject).to receive(:update_settings).once.with(retrieved_settings)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
describe VagrantHypconfigmgmt::Command do
|
8
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
9
|
+
let(:app) { }
|
10
|
+
let(:env) { }
|
11
|
+
|
12
|
+
# pretend we retrieve the original settings config from the filesystem
|
13
|
+
let(:retrieve_settings_before) do
|
14
|
+
double('retrieve_settings_before').tap do |retrieve_settings_before|
|
15
|
+
allow(retrieve_settings_before).to receive(:to_yaml).with(no_args).and_return('before_settings')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# pretend we retrieve the updated settings config from the filesystem
|
20
|
+
let(:retrieve_settings_after) do
|
21
|
+
double('retrieve_settings_after').tap do |retrieve_settings_after|
|
22
|
+
allow(retrieve_settings_after).to receive(:to_yaml).with(no_args).and_return('after_settings')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# instantiate class of which a method is to be tested
|
27
|
+
subject { described_class.new(app, env) }
|
28
|
+
|
29
|
+
# the method that we are going to test
|
30
|
+
describe "#ensure_settings_configured" do
|
31
|
+
|
32
|
+
context "when settings are updated" do
|
33
|
+
it "configures all the settings and returns true" do
|
34
|
+
# check retrieve_settings is called twice
|
35
|
+
expect(subject).to receive(:retrieve_settings).twice.with(no_args).and_return(retrieve_settings_before, retrieve_settings_after)
|
36
|
+
# check the magento settings are configured
|
37
|
+
expect(subject).to receive(:configure_magento).with(env)
|
38
|
+
# check the php settings are configured
|
39
|
+
expect(subject).to receive(:configure_php).with(env)
|
40
|
+
# check the varnish settings are configured
|
41
|
+
expect(subject).to receive(:configure_varnish).with(env)
|
42
|
+
# check the synced folder settings are configured
|
43
|
+
expect(subject).to receive(:configure_synced_folders).with(env)
|
44
|
+
# check the vagrant settings are configured
|
45
|
+
expect(subject).to receive(:configure_vagrant).with(env)
|
46
|
+
# check true is returned when settings are updated
|
47
|
+
expect( subject.ensure_settings_configured(env) ).to eq(true)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when settings are not updated" do
|
52
|
+
it "configures all the settings and returns false" do
|
53
|
+
# check retrieve_settings is called twice
|
54
|
+
expect(subject).to receive(:retrieve_settings).twice.with(no_args).and_return(retrieve_settings_before, retrieve_settings_before)
|
55
|
+
# check the magento settings are configured
|
56
|
+
expect(subject).to receive(:configure_magento).with(env)
|
57
|
+
# check the php settings are configured
|
58
|
+
expect(subject).to receive(:configure_php).with(env)
|
59
|
+
# check the varnish settings are configured
|
60
|
+
expect(subject).to receive(:configure_varnish).with(env)
|
61
|
+
# check the synced folder settings are configured
|
62
|
+
expect(subject).to receive(:configure_synced_folders).with(env)
|
63
|
+
# check the vagrant settings are configured
|
64
|
+
expect(subject).to receive(:configure_vagrant).with(env)
|
65
|
+
# check false is returned when settings are not updated
|
66
|
+
expect( subject.ensure_settings_configured(env) ).to eq(false)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
describe VagrantHypconfigmgmt::Command do
|
8
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
9
|
+
let(:app) { }
|
10
|
+
let(:env) { { :ui => ui } }
|
11
|
+
|
12
|
+
# pretend env contains the Vagrant ui element
|
13
|
+
let(:ui) do
|
14
|
+
double('ui').tap do |ui|
|
15
|
+
allow(ui).to receive(:info) { nil }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Call the method under test after every 'it'. Similar to setUp in Python TestCase
|
20
|
+
after do
|
21
|
+
subject.ensure_vagrant_box_type_configured(env)
|
22
|
+
end
|
23
|
+
|
24
|
+
# instantiate class of which a method is to be tested
|
25
|
+
subject { described_class.new(app, env) }
|
26
|
+
|
27
|
+
# the method that we are going to test
|
28
|
+
describe "#ensure_vagrant_box_type_configured" do
|
29
|
+
|
30
|
+
context "when php 7.0 is configured" do
|
31
|
+
let(:retrieved_settings) { { "php" => { "version" => 7.0 }, "vagrant" => Hash.new } }
|
32
|
+
it "sets the box name and box url to the right values for PHP 7.0" do
|
33
|
+
expected_settings = {
|
34
|
+
"php" => {
|
35
|
+
"version" => 7.0
|
36
|
+
},
|
37
|
+
"vagrant" => {
|
38
|
+
"box" => "hypernode_php7",
|
39
|
+
"box_url" => "http://vagrant.hypernode.com/customer/php7/catalog.json" }
|
40
|
+
}
|
41
|
+
# check if settings are retrieved from disk and pretend they return a configuration for php 7.0
|
42
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
43
|
+
# check if the settings that are written back to disk contain the right box (name) and box_url
|
44
|
+
expect(subject).to receive(:update_settings).once.with(expected_settings)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "when php 5.5 is configured" do
|
49
|
+
let(:retrieved_settings) { { "php" => { "version" => 5.5 }, "vagrant" => Hash.new } }
|
50
|
+
it "sets the box name and box url to the right values for PHP 5.5" do
|
51
|
+
expected_settings = {
|
52
|
+
"php" => {
|
53
|
+
"version" => 5.5
|
54
|
+
},
|
55
|
+
"vagrant" => {
|
56
|
+
"box" => "hypernode_php5",
|
57
|
+
"box_url" => "http://vagrant.hypernode.com/customer/php5/catalog.json" }
|
58
|
+
}
|
59
|
+
# check if settings are retrieved from disk and pretend they return a configuration for php 5.5
|
60
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
61
|
+
# check if the settings that are written back to disk contain the right box (name) and box_url
|
62
|
+
expect(subject).to receive(:update_settings).once.with(expected_settings)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when an unknown php version is configured" do
|
67
|
+
let(:retrieved_settings) { { "php" => { "version" => 1.0 }, "vagrant" => Hash.new } }
|
68
|
+
it "do not set the box name and box url" do
|
69
|
+
# check if settings are retrieved from disk and pretend they return an invalid php version
|
70
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
71
|
+
# check if the settings we write back to disk have an unaltered box (name) and box_url
|
72
|
+
expect(subject).to receive(:update_settings).once.with(retrieved_settings)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
describe VagrantHypconfigmgmt::Command do
|
8
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
9
|
+
let(:app) { }
|
10
|
+
let(:env) { { :ui => ui } }
|
11
|
+
|
12
|
+
# pretend env contains the Vagrant ui element
|
13
|
+
let(:ui) do
|
14
|
+
double('ui').tap do |ui|
|
15
|
+
allow(ui).to receive(:info) { nil }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# instantiate class of which a method is to be tested
|
21
|
+
subject { described_class.new(app, env) }
|
22
|
+
|
23
|
+
# the method that we are going to test
|
24
|
+
describe "#get_magento_version" do
|
25
|
+
|
26
|
+
context "when magento 1 is configured" do
|
27
|
+
it "it notifies the user about the /data/web/public webdir and returns the value" do
|
28
|
+
# check if the setting is prompted for and pretend it returns a "magento 1" answer
|
29
|
+
expect(subject).to receive(:get_setting).with(
|
30
|
+
env, AVAILABLE_MAGENTO_VERSIONS, DEFAULT_MAGENTO_VERSION,
|
31
|
+
"Is this a Magento #{subject.get_options_string(AVAILABLE_MAGENTO_VERSIONS)} Hypernode? [default #{DEFAULT_MAGENTO_VERSION}]: "
|
32
|
+
).and_return("1")
|
33
|
+
# check if the user is notified about the correct webdir
|
34
|
+
expect(ui).to receive(:info).once.with(/.*Magento 1*/)
|
35
|
+
# check if the function returns int 1 if a Magento 1 Vagrant is to be used
|
36
|
+
expect( subject.get_magento_version(env) ).to eq(1)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
context "when magento 2 is configured" do
|
42
|
+
it "it notifies the user about the /data/web/magento2/pub symlink returns the value" do
|
43
|
+
# check if the setting is prompted for and pretend it returns a "magento 2" answer
|
44
|
+
expect(subject).to receive(:get_setting).with(
|
45
|
+
env, AVAILABLE_MAGENTO_VERSIONS, DEFAULT_MAGENTO_VERSION,
|
46
|
+
"Is this a Magento #{subject.get_options_string(AVAILABLE_MAGENTO_VERSIONS)} Hypernode? [default #{DEFAULT_MAGENTO_VERSION}]: "
|
47
|
+
).and_return("2")
|
48
|
+
# check if the user is notified about the correct webdir
|
49
|
+
expect(ui).to receive(:info).once.with(/.*Magento 2*/)
|
50
|
+
# check if the function returns int 2 if a Magento 2 Vagrant is to be used
|
51
|
+
expect( subject.get_magento_version(env) ).to eq(2)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
describe VagrantHypconfigmgmt::Command do
|
8
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
9
|
+
let(:app) { }
|
10
|
+
let(:env) { }
|
11
|
+
|
12
|
+
# instantiate class of which a method is to be tested
|
13
|
+
subject { described_class.new(app, env) }
|
14
|
+
|
15
|
+
# the method that we are going to test
|
16
|
+
describe "#get_options_string" do
|
17
|
+
context "when there is only one option" do
|
18
|
+
it "return that options as a string" do
|
19
|
+
expect( subject.get_options_string([true]) ).to eq("true")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when the options are strings" do
|
24
|
+
it "returns them separated by 'or'" do
|
25
|
+
expect( subject.get_options_string(["yes", "no"]) ).to eq("yes or no")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when the options are bools" do
|
30
|
+
it "it casts the bools to strings and returns them separated by 'or'" do
|
31
|
+
expect( subject.get_options_string([true, false]) ).to eq("true or false")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when the options are floats" do
|
36
|
+
it "it casts the floats to strings and returns them separated by 'or'" do
|
37
|
+
expect( subject.get_options_string([5.5, 7.0]) ).to eq("5.5 or 7.0")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when the options are ints" do
|
42
|
+
it "it casts the ints to strings and returns them separated by 'or'" do
|
43
|
+
expect( subject.get_options_string([1, 2, 3]) ).to eq("1 or 2 or 3")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
describe VagrantHypconfigmgmt::Command do
|
8
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
9
|
+
let(:app) { }
|
10
|
+
let(:env) { { :ui => ui } }
|
11
|
+
|
12
|
+
# pretend env contains the Vagrant ui element
|
13
|
+
let(:ui) do
|
14
|
+
double('ui').tap do |ui|
|
15
|
+
allow(ui).to receive(:info) { nil }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# instantiate class of which a method is to be tested
|
21
|
+
subject { described_class.new(app, env) }
|
22
|
+
|
23
|
+
# the method that we are going to test
|
24
|
+
describe "#get_php_version" do
|
25
|
+
|
26
|
+
context "when PHP 5.5 is configured" do
|
27
|
+
it "it notifies the user that PHP 5.5 will be used and returns the value" do
|
28
|
+
# check if the setting is prompted for and pretend it returns a "PHP 5.5" answer
|
29
|
+
expect(subject).to receive(:get_setting).with(
|
30
|
+
env, AVAILABLE_PHP_VERSIONS, DEFAULT_PHP_VERSION,
|
31
|
+
"Is this a PHP #{subject.get_options_string(AVAILABLE_PHP_VERSIONS)} Hypernode? [default #{DEFAULT_PHP_VERSION}]: "
|
32
|
+
).and_return("5.5")
|
33
|
+
# check if the user is notified about the PHP version
|
34
|
+
expect(ui).to receive(:info).once.with(/.*PHP 5.5*/)
|
35
|
+
# check if the function returns float 5.5 if a PHP 5.5 Vagrant is to be used
|
36
|
+
expect( subject.get_php_version(env) ).to eq(5.5)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
context "when PHP 7.0 is configured" do
|
42
|
+
it "it notifies the user that PHP 7.0 will be used and returns the value" do
|
43
|
+
# check if the setting is prompted for and pretend it returns a "PHP 7.0" answer
|
44
|
+
expect(subject).to receive(:get_setting).with(
|
45
|
+
env, AVAILABLE_PHP_VERSIONS, DEFAULT_PHP_VERSION,
|
46
|
+
"Is this a PHP #{subject.get_options_string(AVAILABLE_PHP_VERSIONS)} Hypernode? [default #{DEFAULT_PHP_VERSION}]: "
|
47
|
+
).and_return("7.0")
|
48
|
+
# check if the user is notified about the PHP version
|
49
|
+
expect(ui).to receive(:info).once.with(/.*PHP 7.0*/)
|
50
|
+
# check if the function returns float 7.0 if a PHP 7.0 Vagrant is to be used
|
51
|
+
expect( subject.get_php_version(env) ).to eq(7.0)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|