rake-builder 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/Rakefile +8 -5
  2. data/examples/05_tests/Rakefile +3 -3
  3. data/examples/05_tests/include/units.h +2 -2
  4. data/lib/compiler.rb +25 -30
  5. data/lib/rake/builder.rb +135 -136
  6. data/lib/rake/builder/installer.rb +37 -0
  7. data/lib/rake/{local_config.rb → builder/local_config.rb} +13 -14
  8. data/lib/rake/builder/logger/formatter.rb +7 -1
  9. data/lib/rake/builder/presenters/makefile/builder_presenter.rb +66 -33
  10. data/lib/rake/builder/presenters/makefile_am/builder_presenter.rb +4 -4
  11. data/lib/rake/builder/qt_builder.rb +3 -8
  12. data/lib/rake/builder/task_definers/builder_task_definer.rb +1 -4
  13. data/lib/rake/builder/version.rb +1 -1
  14. data/lib/rake/{microsecond.rb → microsecond_task.rb} +22 -27
  15. data/lib/rake/once_task.rb +2 -7
  16. data/lib/rake/path.rb +1 -6
  17. data/spec/gather_rspec_coverage.rb +2 -0
  18. data/spec/spec_helper.rb +13 -98
  19. data/spec/unit/compiler_spec.rb +129 -0
  20. data/spec/unit/rake/builder/autoconf/version_spec.rb +62 -5
  21. data/spec/unit/rake/builder/configure_ac_spec.rb +53 -0
  22. data/spec/unit/rake/builder/install_spec.rb +101 -0
  23. data/spec/unit/rake/builder/local_config_spec.rb +53 -0
  24. data/spec/unit/rake/builder/logger/formatter_spec.rb +20 -0
  25. data/spec/unit/rake/builder/presenters/makefile/builder_presenter_spec.rb +163 -0
  26. data/spec/unit/rake/builder/presenters/makefile_am/builder_presenter_spec.rb +4 -2
  27. data/spec/unit/rake/builder/task_definers/builder_task_definer_spec.rb +6 -0
  28. data/spec/unit/rake/builder_spec.rb +391 -16
  29. data/spec/unit/rake/microsecond_task_spec.rb +63 -0
  30. metadata +39 -55
  31. data/examples/01_hello_world_cpp/vendor/bundle/gems/coderay-1.0.8/Rakefile +0 -35
  32. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/Rakefile +0 -412
  33. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/fbuffer/fbuffer.h +0 -185
  34. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/generator/generator.c +0 -1427
  35. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/generator/generator.h +0 -149
  36. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/parser/parser.c +0 -2204
  37. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/parser/parser.h +0 -77
  38. data/examples/01_hello_world_cpp/vendor/bundle/gems/method_source-0.8.1/Rakefile +0 -79
  39. data/examples/01_hello_world_cpp/vendor/bundle/gems/pry-0.9.11.3/Rakefile +0 -136
  40. data/examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/Rakefile +0 -374
  41. data/examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/doc/example/a.c +0 -6
  42. data/examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/doc/example/b.c +0 -6
  43. data/examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/doc/example/main.c +0 -11
  44. data/examples/01_hello_world_cpp/vendor/bundle/gems/slop-3.4.3/Rakefile +0 -29
  45. data/lib/rake/file_task_alias.rb +0 -24
  46. data/spec/c_project/main.c +0 -12
  47. data/spec/c_project/main.h +0 -6
  48. data/spec/c_project_spec.rb +0 -41
  49. data/spec/cpp_project/main.cpp +0 -12
  50. data/spec/cpp_project/main.h +0 -8
  51. data/spec/cpp_project_spec.rb +0 -203
  52. data/spec/generated_files_spec.rb +0 -65
  53. data/spec/libraries_spec.rb +0 -35
  54. data/spec/local_config_spec.rb +0 -95
  55. data/spec/logger_spec.rb +0 -25
  56. data/spec/microsecond_task_spec.rb +0 -32
  57. data/spec/objective_c_project/main.h +0 -1
  58. data/spec/objective_c_project/main.m +0 -18
  59. data/spec/objective_c_project_spec.rb +0 -72
  60. data/spec/paths_spec.rb +0 -19
  61. data/spec/project_spec.rb +0 -20
  62. data/spec/target_spec.rb +0 -48
@@ -1,9 +1,5 @@
1
- require 'rubygems' if RUBY_VERSION < '1.9'
2
-
3
1
  module Rake
4
-
5
2
  module Path
6
-
7
3
  def self.find_files( paths, extension )
8
4
  files = paths.reduce( [] ) do | memo, path |
9
5
  case
@@ -45,7 +41,6 @@ module Rake
45
41
  path
46
42
  end
47
43
  end
48
-
49
44
  end
50
-
51
45
  end
46
+
@@ -0,0 +1,2 @@
1
+ GATHER_RSPEC_COVERAGE = 1
2
+
@@ -1,113 +1,28 @@
1
1
  require 'rspec'
2
- require File.expand_path( File.dirname(__FILE__) + '/../lib/rake/builder' )
2
+ require 'simplecov' if RUBY_VERSION > '1.9'
3
3
 
4
- module RakeBuilderHelper
5
-
6
- SPEC_PATH ||= File.expand_path( File.dirname(__FILE__) )
7
- TARGET ||= {
8
- :executable => 'the_executable',
9
- :static_library => 'libthe_static_library.a',
10
- :shared_library => 'libthe_dynamic_library.so',
11
- }
12
-
13
- def cpp_task( type, namespace = nil )
14
- Rake::Builder.new do |builder|
15
- builder.programming_language = 'c++'
16
- builder.target = TARGET[ type ]
17
- builder.task_namespace = namespace
18
- builder.source_search_paths = [ 'cpp_project' ]
19
- builder.include_paths = [ 'cpp_project' ]
20
- builder.generated_files << 'rake-builder-testfile.txt'
21
- yield builder if block_given?
22
- end
23
- end
24
-
25
- def c_task( type, namespace = nil )
26
- Rake::Builder.new do |builder|
27
- builder.programming_language = 'c'
28
- builder.target = TARGET[ type ]
29
- builder.task_namespace = namespace
30
- builder.source_search_paths = [ 'c_project' ]
31
- builder.include_paths = [ 'c_project' ]
32
- builder.generated_files << 'rake-c-testfile.txt'
33
- yield builder if block_given?
34
- end
35
- end
36
-
37
- def objective_c_task( type, namespace = nil )
38
- Rake::Builder.new do |builder|
39
- builder.programming_language = 'objective-c'
40
- builder.target = TARGET[ type ]
41
- builder.task_namespace = namespace
42
- builder.source_search_paths = [ 'objective_c_project' ]
43
- builder.include_paths = [ 'objective_c_project' ]
44
- builder.generated_files << 'rake-builder-testfile.txt'
45
- builder.library_dependencies = [ 'objc' ]
46
- builder.linker_options = '-framework CoreFoundation -framework Foundation'
47
- yield builder if block_given?
4
+ if RUBY_VERSION > '1.9'
5
+ if defined?(GATHER_RSPEC_COVERAGE)
6
+ SimpleCov.start do
7
+ add_filter "/spec/"
8
+ add_filter "/vendor/"
48
9
  end
49
10
  end
11
+ end
50
12
 
51
- def touch( file )
52
- `touch #{file}`
53
- end
54
-
55
- def exist?( file )
56
- File.exist? file
57
- end
58
-
59
- def task_names
60
- Rake::Task.tasks.map( &:to_s )
61
- end
62
-
63
- def default_tasks
64
- [ 'build', 'clean', 'compile', 'load_makedepend' ]
65
- end
66
-
67
- def expected_tasks( extras, scope = nil )
68
- t = scoped_tasks( default_tasks, scope )
69
- t += extras
70
- t << if scope.nil?
71
- 'default'
72
- else
73
- scope
74
- end
75
- t
76
- end
77
-
78
- def scoped_tasks( tasks, scope )
79
- return tasks if scope.nil?
80
- tasks.map{ |t| "#{scope}:#{t}" }
81
- end
13
+ require File.expand_path(File.join('..', 'lib', 'rake', 'builder'), File.dirname(__FILE__))
82
14
 
15
+ module InputOutputTestHelper
83
16
  def capturing_output
84
- originals = [$stdout, $stderr]
17
+ originals = $stdout, $stderr
85
18
  stdout, stderr = StringIO.new, StringIO.new
86
19
  $stdout, $stderr = stdout, stderr
87
- yield
88
- [stdout.string, stderr.string]
89
- ensure
90
- $stdout, $stderr = *originals
91
- end
92
-
93
- # Most file systems have a 1s resolution
94
- # Force a wait into the next second around a task
95
- # So FileTask's out_of_date? will behave correctly
96
- def isolating_seconds
97
- sec = Time.now.sec
98
- yield
99
- while( Time.now.sec == sec ) do end
100
- end
101
-
102
- def touching_temporarily( file, touch_time )
103
20
  begin
104
- atime = File.atime( file )
105
- mtime = File.mtime( file )
106
- File.utime( atime, touch_time, file )
107
21
  yield
108
22
  ensure
109
- File.utime( atime, mtime, file )
23
+ $stdout, $stderr = originals
110
24
  end
25
+ [stdout.string, stderr.string]
111
26
  end
112
-
113
27
  end
28
+
@@ -0,0 +1,129 @@
1
+ require 'spec_helper'
2
+
3
+ describe Compiler::Base do
4
+ context '.for' do
5
+ it 'returns a compiler' do
6
+ expect(Compiler::Base.for(:gcc)).to be_a(Compiler::GCC)
7
+ end
8
+ end
9
+
10
+ subject { Compiler::Base.new }
11
+
12
+ context '#include_paths' do
13
+ before do
14
+ File.stub(:exist?).
15
+ with('/opt/local/include/foo/bar.h').
16
+ and_return(false)
17
+ end
18
+
19
+ it 'checks extra paths' do
20
+ File.should_receive(:exist?).
21
+ with('/opt/local/include/foo/bar.h').
22
+ and_return(true)
23
+
24
+ subject.include_paths(['foo/bar.h'])
25
+ end
26
+
27
+ it 'throws an error is the headers are not found' do
28
+ expect {
29
+ subject.include_paths(['foo/bar.h'])
30
+ }.to raise_error(RuntimeError, /Can't find header/)
31
+ end
32
+ end
33
+ end
34
+
35
+ describe Compiler::GCC do
36
+
37
+ subject { Compiler::GCC.new }
38
+
39
+ context '.framework_path' do
40
+ it 'returns a path with the framework and QT version' do
41
+ path = Compiler::GCC.framework_path('foo', '1.2.3')
42
+
43
+ expect(path).to match(%r(Library/Frameworks/foo.*?/1.2.3/))
44
+ end
45
+ end
46
+
47
+ context 'default_include_paths' do
48
+ let(:include_paths) do
49
+ %w(
50
+ /usr/include/c++/4.6
51
+ /usr/include/c++/4.6/x86_64-linux-gnu/.
52
+ /usr/include/c++/4.6/backward
53
+ /usr/lib/gcc/x86_64-linux-gnu/4.6/include
54
+ /usr/local/include
55
+ /usr/lib/gcc/x86_64-linux-gnu/4.6/include-fixed
56
+ /usr/include/x86_64-linux-gnu
57
+ /usr/include
58
+ )
59
+ end
60
+
61
+ let(:gcc_output) do
62
+ <<-EOT
63
+ Using built-in specs.
64
+ COLLECT_GCC=gcc
65
+ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
66
+ Target: x86_64-linux-gnu
67
+ Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
68
+ Thread model: posix
69
+ gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
70
+ COLLECT_GCC_OPTIONS='-v' '-E' '-mtune=generic' '-march=x86-64'
71
+ /usr/lib/gcc/x86_64-linux-gnu/4.6/cc1plus -E -quiet -v -imultilib . -imultiarch x86_64-linux-gnu -D_GNU_SOURCE - -mtune=generic -march=x86-64 -fstack-protector
72
+ ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
73
+ ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../x86_64-linux-gnu/include"
74
+ #include "..." search starts here:
75
+ #include <...> search starts here:
76
+ /usr/include/c++/4.6
77
+ /usr/include/c++/4.6/x86_64-linux-gnu/.
78
+ /usr/include/c++/4.6/backward
79
+ /usr/lib/gcc/x86_64-linux-gnu/4.6/include
80
+ /usr/local/include
81
+ /usr/lib/gcc/x86_64-linux-gnu/4.6/include-fixed
82
+ /usr/include/x86_64-linux-gnu
83
+ /usr/include
84
+ End of search list.
85
+ COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.6/:/usr/lib/gcc/x86_64-linux-gnu/4.6/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.6/:/usr/lib/gcc/x86_64-linux-gnu/
86
+ LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.6/:/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../:/lib/:/usr/lib/
87
+ COLLECT_GCC_OPTIONS='-v' '-E' '-mtune=generic' '-march=x86-64'
88
+ EOT
89
+ end
90
+
91
+ before { subject.stub(:`).with(/gcc/).and_return(gcc_output) }
92
+
93
+ it 'calls gcc' do
94
+ subject.should_receive(:`).with(/gcc/).and_return(gcc_output)
95
+
96
+ subject.default_include_paths('c++')
97
+ end
98
+
99
+ it 'parses gcc output' do
100
+ actual = subject.default_include_paths('c++')
101
+
102
+ expect(actual).to eq(include_paths)
103
+ end
104
+ end
105
+
106
+ context 'missing_headers' do
107
+ let(:makedepend_output) do
108
+ <<-EOT
109
+ makedepend: warning: main.cpp (reading main.h, line 4): cannot find include file "baz.h"
110
+ not in /usr/include/iostream
111
+ EOT
112
+ end
113
+
114
+ before { subject.stub(:`).with(/makedepend/).and_return(makedepend_output) }
115
+
116
+ it 'calls makedepend' do
117
+ subject.should_receive(:`).with(/makedepend/).and_return(makedepend_output)
118
+
119
+ subject.missing_headers(['/foo'], ['bar.cpp'])
120
+ end
121
+
122
+ it 'returns missing headers' do
123
+ missing = subject.missing_headers(['/foo'], ['bar.cpp'])
124
+
125
+ expect(missing).to eq(['baz.h'])
126
+ end
127
+ end
128
+ end
129
+
@@ -1,6 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Rake::Builder::Autoconf::Version do
4
+ before do
5
+ File.stub(:exist? => true)
6
+ File.stub(:read => '1.2.3')
7
+ end
8
+
4
9
  context '.new' do
5
10
  context 'with parameter' do
6
11
  it 'fails if the version parameter is not nn.nn.nn' do
@@ -17,11 +22,6 @@ describe Rake::Builder::Autoconf::Version do
17
22
  end
18
23
 
19
24
  context 'VERSION file' do
20
- before do
21
- File.stub(:exist? => true)
22
- File.stub(:read => '1.2.3')
23
- end
24
-
25
25
  it 'checks for a the file' do
26
26
  File.should_receive(:exist?).
27
27
  with('VERSION').
@@ -54,6 +54,63 @@ describe Rake::Builder::Autoconf::Version do
54
54
  end
55
55
 
56
56
  context '#decide' do
57
+ let(:with_parameter) { Rake::Builder::Autoconf::Version.new('4.5.6') }
58
+ let(:without_parameter) { Rake::Builder::Autoconf::Version.new }
59
+
60
+ before { File.stub(:open).with('VERSION', 'w') }
61
+
62
+ context 'file version is nil' do
63
+ before { File.stub(:exist? => false) }
64
+
65
+ context 'parameter is nil' do
66
+ it 'raises an error' do
67
+ expect {
68
+ without_parameter.decide
69
+ }.to raise_error(RuntimeError, /Please do one of the following/)
70
+ end
71
+ end
72
+
73
+ context 'parameter not nil' do
74
+ it 'saves the version' do
75
+ File.should_receive(:open).with('VERSION', 'w')
76
+
77
+ with_parameter.decide
78
+ end
79
+
80
+ it 'returns the parameter version' do
81
+ expect(with_parameter.decide).to eq('4.5.6')
82
+ end
83
+ end
84
+ end
85
+
86
+ context 'file version not nil' do
87
+ before do
88
+ File.stub(:exist? => true)
89
+ File.stub(:read).with('VERSION').and_return("6.6.6\n")
90
+ end
91
+
92
+ context 'parameter is nil' do
93
+ it 'returns the file version' do
94
+ expect(without_parameter.decide).to eq('6.6.6')
95
+ end
96
+ end
97
+
98
+ context 'parameter not nil' do
99
+ it 'fails if the two versions differ'do
100
+ File.should_receive(:read).with('VERSION').and_return("6.6.6\n")
101
+
102
+ expect {
103
+ with_parameter.decide
104
+ }.to raise_error(RuntimeError, /parameter.*?is different to.*?VERSION/)
105
+ end
106
+
107
+ it 'returns the version' do
108
+ File.should_receive(:read).with('VERSION').and_return("4.5.6\n")
109
+
110
+ expect(with_parameter.decide).to eq('4.5.6')
111
+ end
112
+ end
113
+ end
57
114
  end
58
115
  end
59
116
 
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rake::Builder::ConfigureAc do
4
+ subject { Rake::Builder::ConfigureAc.new('title', '1.2.3', '/source/file.c') }
5
+
6
+ context '.new' do
7
+ it 'takes three parameters' do
8
+ expect {
9
+ Rake::Builder::ConfigureAc.new
10
+ }.to raise_error(ArgumentError, /wrong number of arguments/)
11
+ end
12
+ end
13
+
14
+ context '#to_s' do
15
+ it 'sets up AC_INIT' do
16
+ expected = 'AC_INIT(title, 1.2.3)'
17
+
18
+ expect(subject.to_s).to include(expected)
19
+ end
20
+
21
+ it 'indicates a source file in AC_CONFIG_SRCDIR' do
22
+ expected = 'AC_CONFIG_SRCDIR([/source/file.c])'
23
+
24
+ expect(subject.to_s).to include(expected)
25
+ end
26
+
27
+ it 'sets up AM_INIT_AUTOMAKE' do
28
+ expected = 'AM_INIT_AUTOMAKE([title], [1.2.3])'
29
+
30
+ expect(subject.to_s).to include(expected)
31
+ end
32
+ end
33
+
34
+ context '#save' do
35
+ it 'creates the file' do
36
+ File.should_receive(:open).with('configure.ac', 'w')
37
+
38
+ subject.save
39
+ end
40
+
41
+ it 'saves the content' do
42
+ file = stub('File')
43
+ File.stub(:open).with('configure.ac', 'w') do |&block|
44
+ block.call file
45
+ end
46
+
47
+ file.should_receive(:write).with(/AC_PREREQ\(2\.61\)/)
48
+
49
+ subject.save
50
+ end
51
+ end
52
+ end
53
+
@@ -0,0 +1,101 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rake::Builder::Installer do
4
+ let(:destination_path) { '/destination/path' }
5
+ let(:destination_pathname) { '/destination/path/install' }
6
+
7
+ context '#install' do
8
+ let(:file_to_install) { '/file/to/install' }
9
+
10
+ before do
11
+ File.stub(:exist?).with(file_to_install).and_return(true)
12
+ File.stub(:exist?).with(destination_path).and_return(true)
13
+ File.stub(:directory?).with(destination_path).and_return(true)
14
+ File.stub(:writable?).with(destination_path).and_return(true)
15
+ File.stub(:file?).with(destination_pathname).and_return(false)
16
+ File.stub(:writable?).with(destination_pathname).and_return(true)
17
+ FileUtils.stub(:copy_file).with(file_to_install, destination_path)
18
+ end
19
+
20
+ it 'checks the source exists' do
21
+ File.should_receive(:exist?).with(file_to_install).and_return(true)
22
+
23
+ subject.install file_to_install, destination_path
24
+ end
25
+
26
+ it 'fails if the source does not exist' do
27
+ File.stub(:exist?).with(file_to_install).and_return(false)
28
+
29
+ expect {
30
+ subject.install file_to_install, destination_path
31
+ }.to raise_error(RuntimeError, /does not exist/)
32
+ end
33
+
34
+ it 'checks the destination directory exists' do
35
+ File.should_receive(:exist?).with(destination_path).and_return(false)
36
+
37
+ expect {
38
+ subject.install file_to_install, destination_path
39
+ }.to raise_error(RuntimeError, /does not exist/)
40
+ end
41
+
42
+ it 'checks the destination is a directory' do
43
+ File.should_receive(:directory?).with(destination_path).and_return(false)
44
+
45
+ expect {
46
+ subject.install file_to_install, destination_path
47
+ }.to raise_error(RuntimeError, /is not a directory/)
48
+ end
49
+
50
+ it 'check it can overwrite an existing destination file' do
51
+ File.stub(:file?).with(destination_pathname).and_return(true)
52
+ File.stub(:writable?).with(destination_pathname).and_return(false)
53
+
54
+ expect {
55
+ subject.install file_to_install, destination_path
56
+ }.to raise_error(RuntimeError, /cannot be overwritten/)
57
+ end
58
+
59
+ it 'copies the file to the destination' do
60
+ FileUtils.should_receive(:copy_file).with(file_to_install, destination_path)
61
+
62
+ subject.install file_to_install, destination_path
63
+ end
64
+ end
65
+
66
+ context '#uninstall' do
67
+ before do
68
+ File.stub(:exist?).with(destination_pathname).and_return(true)
69
+ File.stub(:writable?).with(destination_path).and_return(true)
70
+ File.stub(:unlink).with(destination_pathname)
71
+ end
72
+
73
+ it 'checks if the file exists' do
74
+ File.should_receive(:exist?).with(destination_pathname).and_return(true)
75
+
76
+ subject.uninstall destination_pathname
77
+ end
78
+
79
+ it 'does nothing if the file does not exist' do
80
+ File.should_receive(:exist?).with(destination_pathname).and_return(false)
81
+ File.should_not_receive(:unlink)
82
+
83
+ subject.uninstall destination_pathname
84
+ end
85
+
86
+ it 'fails if the directory is not writable' do
87
+ File.should_receive(:writable?).with(destination_path).and_return(false)
88
+
89
+ expect {
90
+ subject.uninstall destination_pathname
91
+ }.to raise_error(RuntimeError, /directory.*?writable/)
92
+ end
93
+
94
+ it 'deletes the file' do
95
+ File.should_receive(:unlink).with(destination_pathname)
96
+
97
+ subject.uninstall destination_pathname
98
+ end
99
+ end
100
+ end
101
+