0
@@ -44,7 +44,7 @@ describe "Installer" do
0
@installer.copy_configuration
0
it "should copy the plugin to the destination directory" do
0
File.expects(:dirname).with(@installer_source_file).returns(@lib_path)
0
plugin_dir = "#{@path}/builder_plugins/installed/smoke_signals"
0
@@ -55,33 +55,70 @@ describe "Installer" do
0
+ it "should remove the configuration from the appropriate directory" do
0
+ FileUtils.expects(:rm).with("#{@path}/config/smoke_signals.yml")
0
+ @installer.remove_configuration
0
+ it "should remove the plugin from the appropriate directory" do
0
+ FileUtils.expects(:rm_rf).with("#{@path}/builder_plugins/installed/smoke_signals")
0
+ @installer.remove_plugin
0
- it "should not run any installation if it's not at the root directory" do
0
- installer_mock = mock()
0
- installer_mock.expects(:at_root?).returns(false)
0
- installer_mock.expects(:copy_configuration).never
0
- installer_mock.expects(:copy_plugin).never
0
+ it "should uninstall itself when it's installed" do
0
+ @installer.expects(:installed?).returns(true)
0
+ @installer.expects(:remove_configuration)
0
+ @installer.expects(:remove_plugin)
0
- Installer.expects(:new).with(@path).returns(installer_mock)
0
+ @installer.uninstall.should.be true
0
+ it "should not uninstall when it's not installed" do
0
+ @installer.expects(:installed?).returns(false)
0
+ @installer.expects(:remove_configuration).never
0
+ @installer.expects(:remove_plugin).never
0
- Installer.run(@path) do |installer|
0
- installer.copy_configuration
0
+ @installer.uninstall.should.be false
0
+ it "should install when it's not installed" do
0
+ @installer.expects(:installed?).returns(false)
0
+ @installer.expects(:copy_configuration)
0
+ @installer.expects(:copy_plugin)
0
+ @installer.install.should.be true
0
- it "should run the installation if it's at the root directory" do
0
- installer_mock = mock()
0
- installer_mock.expects(:at_root?).returns(true)
0
- installer_mock.expects(:copy_configuration).once.with(nil)
0
- installer_mock.expects(:copy_plugin).once.with(nil)
0
+ it "should not install when it's installed" do
0
+ @installer.expects(:installed?).returns(true)
0
+ @installer.expects(:copy_configuration).never
0
+ @installer.expects(:copy_plugin).never
0
+ @installer.install.should.be false
0
+ it "should know which command to run" do
0
+ installer_mock = mock(:at_root? => true, command.to_sym => true)
0
Installer.expects(:new).with(@path).returns(installer_mock)
0
- Installer.run(@path) do |installer|
0
- installer.copy_configuration
0
+ Installer.run(command, @path).should.be true
0
+ it "should not run any commands if the installer isn't at the root directory" do
0
+ installer_mock = mock(:at_root? => false)
0
+ installer_mock.expects(command).never
0
+ Installer.expects(:new).with(@path).returns(installer_mock)
0
+ Installer.run(command, @path).should.be false
0
+ it "should raise an exception if the command isn't available" do
0
+ proc = lambda { Installer.run('bad_command', @path) }
0
+ proc.should.raise Installer::InvalidCommandError
Comments
No one has commented yet.