spec/appliance-spec.rb in boxgrinder-build-0.9.0 vs spec/appliance-spec.rb in boxgrinder-build-0.9.1
- old
+ new
@@ -143,11 +143,12 @@
prepare_appliance({}, "#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.ks")
appliance_config = ApplianceConfig.new
appliance_helper = mock(ApplianceDefinitionHelper)
- appliance_helper.should_receive(:read_definitions).with("#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.ks").and_raise("Unknown format")
+ appliance_helper.should_receive(:read_definitions).with("#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.ks")
+ appliance_helper.should_receive(:appliance_configs).and_return([])
clazz = mock('PluginClass')
plugin_manager = mock(PluginManager)
plugin_manager.should_receive(:plugins).and_return({:os => {:fedora => {:class => clazz, :type => :os, :name => :fedora, :full_name => "Fedora", :versions => ["11", "12", "13", "14", "rawhide"]}}})
@@ -177,11 +178,12 @@
it "should read definition with kickstart appliance definition file and fail because there was no plugin able to read .ks" do
prepare_appliance({}, "#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.ks")
appliance_helper = mock(ApplianceDefinitionHelper)
- appliance_helper.should_receive(:read_definitions).with("#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.ks").and_raise("Unknown format")
+ appliance_helper.should_receive(:read_definitions).with("#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.ks")
+ appliance_helper.should_receive(:appliance_configs).and_return([])
plugin_manager = mock(PluginManager)
plugin_manager.should_receive(:plugins).and_return({:os => {}})
@@ -189,86 +191,10 @@
ApplianceDefinitionHelper.should_receive(:new).with(:log => @log).and_return(appliance_helper)
lambda {
@appliance.read_definition
- }.should raise_error("Couldn't read appliance definition file: jeos-f13.ks")
- end
- end
-
- describe ".validate_definition" do
- it "should validate definition and pass" do
- prepare_appliance
- @appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
-
- appliance_config_validator = mock(ApplianceConfigValidator)
- appliance_config_validator.should_receive(:validate)
-
- ApplianceConfigValidator.should_receive(:new).with(@appliance_config).and_return(appliance_config_validator)
-
- plugin_manager = mock(PluginManager)
- plugin_manager.stub!(:plugins).and_return({:os => {:fedora => {:type => :os, :name => :fedora, :full_name => "Fedora", :versions => ["11", "12", "13", "14", "rawhide"]}}})
-
- PluginManager.stub!(:instance).and_return(plugin_manager)
-
- @appliance.validate_definition
- end
-
- it "should validate definition and fail because no operating system plugins are installed" do
- prepare_appliance
- @appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
-
- appliance_config_validator = mock(ApplianceConfigValidator)
- appliance_config_validator.should_receive(:validate)
-
- ApplianceConfigValidator.should_receive(:new).with(@appliance_config).and_return(appliance_config_validator)
-
- plugin_manager = mock(PluginManager)
- plugin_manager.stub!(:plugins).and_return({:os => {}})
-
- PluginManager.stub!(:instance).and_return(plugin_manager)
-
- lambda {
- @appliance.validate_definition
- }.should raise_error(RuntimeError, "No operating system plugins installed. Install one or more operating system plugin. See http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#Operating_system_plugins for more info.")
- end
-
- it "should validate definition and fail because no supported operating system plugins is installed" do
- prepare_appliance
- @appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
-
- appliance_config_validator = mock(ApplianceConfigValidator)
- appliance_config_validator.should_receive(:validate)
-
- ApplianceConfigValidator.should_receive(:new).with(@appliance_config).and_return(appliance_config_validator)
-
- plugin_manager = mock(PluginManager)
- plugin_manager.stub!(:plugins).and_return({:os => {:rhel => {}}})
-
- PluginManager.stub!(:instance).and_return(plugin_manager)
-
- lambda {
- @appliance.validate_definition
- }.should raise_error(RuntimeError, "Not supported operating system selected: fedora. Make sure you have installed right operating system plugin, see http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#Operating_system_plugins. Supported OSes are: rhel")
- end
-
- it "should validate definition and fail because no supported operating system version plugins is installed" do
- prepare_appliance
- @appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
-
- appliance_config_validator = mock(ApplianceConfigValidator)
- appliance_config_validator.should_receive(:validate)
-
- ApplianceConfigValidator.should_receive(:new).with(@appliance_config).and_return(appliance_config_validator)
-
- plugin_manager = mock(PluginManager)
- plugin_manager.stub!(:plugins).and_return({:os => {:fedora => {:type => :os, :name => :fedora, :full_name => "Fedora", :versions => ["xyz"]}}})
-
- PluginManager.stub!(:instance).and_return(plugin_manager)
-
- lambda {
- @appliance.validate_definition
- }.should raise_error(RuntimeError, "Not supported operating system version selected: 11. Supported versions are: xyz")
+ }.should raise_error(ValidationError, "Couldn't read appliance definition file: jeos-f13.ks.")
end
end
it "should remove old builds" do
prepare_appliance