rake-compiler 1.2.2 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,237 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- require 'rake/javaextensiontask'
4
- require 'rbconfig'
5
-
6
- describe Rake::JavaExtensionTask do
7
- context '#new' do
8
- context '(basic)' do
9
- it 'should raise an error if no name is provided' do
10
- lambda {
11
- Rake::JavaExtensionTask.new
12
- }.should raise_error(RuntimeError, /Extension name must be provided/)
13
- end
14
-
15
- it 'should allow string as extension name assignation' do
16
- ext = Rake::JavaExtensionTask.new('extension_one')
17
- ext.name.should == 'extension_one'
18
- end
19
-
20
- it 'should allow string as extension name using block assignation' do
21
- ext = Rake::JavaExtensionTask.new do |ext|
22
- ext.name = 'extension_two'
23
- end
24
- ext.name.should == 'extension_two'
25
- end
26
-
27
- it 'should return itself for the block' do
28
- from_block = nil
29
- from_lasgn = Rake::JavaExtensionTask.new('extension_three') do |ext|
30
- from_block = ext
31
- end
32
- from_block.should == from_lasgn
33
- end
34
-
35
- it 'should accept a gem specification as parameter' do
36
- spec = mock_gem_spec
37
- ext = Rake::JavaExtensionTask.new('extension_three', spec)
38
- ext.gem_spec.should == spec
39
- end
40
-
41
- it 'should allow gem specification be defined using block assignation' do
42
- spec = mock_gem_spec
43
- ext = Rake::JavaExtensionTask.new('extension_four') do |ext|
44
- ext.gem_spec = spec
45
- end
46
- ext.gem_spec.should == spec
47
- end
48
-
49
- it 'should allow forcing of platform' do
50
- ext = Rake::JavaExtensionTask.new('weird_extension') do |ext|
51
- ext.platform = 'java-128bit'
52
- end
53
- ext.platform.should == 'java-128bit'
54
- end
55
- end
56
- end
57
-
58
- context '(defaults)' do
59
- before :each do
60
- @ext = Rake::JavaExtensionTask.new('extension_one')
61
- end
62
-
63
- it 'should dump intermediate files to tmp/' do
64
- @ext.tmp_dir.should == 'tmp'
65
- end
66
-
67
- it 'should copy build extension into lib/' do
68
- @ext.lib_dir.should == 'lib'
69
- end
70
-
71
- it 'should look for Java files pattern (.java)' do
72
- @ext.source_pattern.should == "**/*.java"
73
- end
74
-
75
- it 'should have no configuration options preset to delegate' do
76
- @ext.config_options.should be_empty
77
- end
78
-
79
- it 'should have no lint option preset to delegate' do
80
- @ext.lint_option.should be_falsey
81
- end
82
-
83
- it 'should default to Java platform' do
84
- @ext.platform.should == 'java'
85
- end
86
- end
87
-
88
- context '(tasks)' do
89
- before :each do
90
- Rake.application.clear
91
- CLEAN.clear
92
- CLOBBER.clear
93
- end
94
-
95
- context '(one extension)' do
96
- before :each do
97
- allow(Rake::FileList).to receive(:[]).and_return(["ext/extension_one/source.java"])
98
- @ext = Rake::JavaExtensionTask.new('extension_one')
99
- @ext_bin = ext_bin('extension_one')
100
- @platform = 'java'
101
- end
102
-
103
- context 'compile' do
104
- it 'should define as task' do
105
- Rake::Task.task_defined?('compile').should == true
106
- end
107
-
108
- it "should depend on 'compile:{platform}'" do
109
- pending 'needs fixing'
110
- Rake::Task['compile'].prerequisites.should include("compile:#{@platform}")
111
- end
112
- end
113
-
114
- context 'compile:extension_one' do
115
- it 'should define as task' do
116
- Rake::Task.task_defined?('compile:extension_one').should == true
117
- end
118
-
119
- it "should depend on 'compile:extension_one:{platform}'" do
120
- pending 'needs fixing'
121
- Rake::Task['compile:extension_one'].prerequisites.should include("compile:extension_one:#{@platform}")
122
- end
123
- end
124
-
125
- context 'lib/extension_one.jar' do
126
- it 'should define as task' do
127
- pending 'needs fixing'
128
- Rake::Task.task_defined?("lib/#{@ext_bin}").should be_true
129
- end
130
-
131
- it "should depend on 'copy:extension_one:{platform}'" do
132
- pending 'needs fixing'
133
- Rake::Task["lib/#{@ext_bin}"].prerequisites.should include("copy:extension_one:#{@platform}")
134
- end
135
- end
136
-
137
- context 'tmp/{platform}/extension_one/extension_one.jar' do
138
- it 'should define as task' do
139
- Rake::Task.task_defined?("tmp/#{@platform}/extension_one/#{@ext_bin}").should == true
140
- end
141
-
142
- it "should depend on checkpoint file" do
143
- Rake::Task["tmp/#{@platform}/extension_one/#{@ext_bin}"].prerequisites.should include("tmp/#{@platform}/extension_one/.build")
144
- end
145
- end
146
-
147
- context 'tmp/{platform}/extension_one/.build' do
148
- it 'should define as task' do
149
- Rake::Task.task_defined?("tmp/#{@platform}/extension_one/.build").should == true
150
- end
151
-
152
- it 'should depend on source files' do
153
- Rake::Task["tmp/#{@platform}/extension_one/.build"].prerequisites.should include("ext/extension_one/source.java")
154
- end
155
- end
156
-
157
- context 'clean' do
158
- it "should include 'tmp/{platform}/extension_one' in the pattern" do
159
- CLEAN.should include("tmp/#{@platform}/extension_one")
160
- end
161
- end
162
-
163
- context 'clobber' do
164
- it "should include 'lib/extension_one.jar'" do
165
- CLOBBER.should include("lib/#{@ext_bin}")
166
- end
167
-
168
- it "should include 'tmp'" do
169
- CLOBBER.should include('tmp')
170
- end
171
- end
172
- end
173
-
174
- context 'A custom extension' do
175
- let(:extension) do
176
- Rake::JavaExtensionTask.new('extension_two') do |ext|
177
- ext.lint_option = lint_option if lint_option
178
- ext.release = release if release
179
- end
180
- end
181
-
182
- context 'without a specified lint option' do
183
- let(:lint_option) { nil }
184
- let(:release) { nil }
185
-
186
- it 'should honor the lint option' do
187
- (extension.lint_option).should be_falsey
188
- (extension.send :java_lint_arg).should eq '-Xlint'
189
- end
190
- end
191
-
192
- context "with a specified lint option of 'deprecated'" do
193
- let(:lint_option) { 'deprecated'.freeze }
194
- let(:release) { nil }
195
-
196
- it 'should honor the lint option' do
197
- (extension.lint_option).should eq lint_option
198
- (extension.send :java_lint_arg).should eq '-Xlint:deprecated'
199
- end
200
- end
201
-
202
- context "without release option" do
203
- let(:lint_option) { nil }
204
- let(:release) { nil }
205
-
206
- it 'should generate -target and -source build options' do
207
- extension.target_version = "1.8"
208
- extension.source_version = "1.8"
209
- (extension.send :java_target_args).should eq ["-target", "1.8", "-source", "1.8"]
210
- end
211
- end
212
-
213
- context "with release option" do
214
- let(:lint_option) { nil }
215
- let(:release) { '8' }
216
-
217
- it 'should generate --release option even with target_version/source_version' do
218
- extension.target_version = "1.8"
219
- extension.source_version = "1.8"
220
- (extension.send :java_target_args).should eq ["--release=8"]
221
- end
222
- end
223
- end
224
- end
225
- private
226
-
227
- def ext_bin(extension_name)
228
- "#{extension_name}.jar"
229
- end
230
-
231
- def mock_gem_spec(stubs = {})
232
- double(Gem::Specification,
233
- { :name => 'my_gem', :platform => 'ruby' }.merge(stubs)
234
- )
235
- end
236
-
237
- end
data/spec/spec.opts DELETED
@@ -1,3 +0,0 @@
1
- --colour
2
- --format nested
3
- --loadby mtime
data/spec/spec_helper.rb DELETED
@@ -1,15 +0,0 @@
1
- require 'rspec'
2
-
3
- # Console redirection helper
4
- require File.expand_path('../support/capture_output_helper', __FILE__)
5
-
6
- RSpec.configure do |config|
7
- config.include CaptureOutputHelper
8
- end
9
-
10
- # Rake::Task matcher helper
11
- RSpec::Matchers.define :have_defined do |task|
12
- match do |tasks|
13
- tasks.task_defined?(task)
14
- end
15
- end
@@ -1,22 +0,0 @@
1
- module CaptureOutputHelper
2
- def capture_output(&block)
3
- old_stdout = $stdout
4
- old_stderr = $stderr
5
-
6
- stream_out = StringIO.new
7
- stream_err = StringIO.new
8
-
9
- begin
10
- $stdout = stream_out
11
- $stderr = stream_err
12
- yield
13
- ensure
14
- $stdout = old_stdout
15
- $stderr = old_stderr
16
- end
17
- stream_out.rewind
18
- stream_err.rewind
19
-
20
- [stream_out.read, stream_err.read]
21
- end
22
- end