File tree 5 files changed +57
-31
lines changed
5 files changed +57
-31
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,3 @@ gem 'opal', :github => 'opal/opal'
5
5
gem 'opal-sprockets' , :github => 'opal/opal-sprockets'
6
6
7
7
gem 'rake'
8
-
9
- gem 'rspec' , '3.0.0.beta1'
10
- gem 'rspec-support' , '3.0.0.beta1'
11
- gem 'rspec-core' , '3.0.0.beta1'
12
- gem 'rspec-mocks' , '3.0.0.beta1'
13
- gem 'rspec-expectations' , '3.0.0.beta1'
Original file line number Diff line number Diff line change @@ -6,37 +6,17 @@ Opal::RSpec::RakeTask.new(:default)
6
6
7
7
desc "Build opal/opal/rspec/rspec.js"
8
8
task :build do
9
- File . open ( 'opal/opal/rspec/rspec.js' , 'w+' ) do |out |
10
- out << build_rspec
11
- end
9
+ Opal ::RSpec . build_rspec_js true
12
10
end
13
11
14
- desc " Show dev/min sizes"
12
+ desc ' Show dev/min sizes'
15
13
task :sizes do
16
- code = build_rspec
14
+ code = Opal :: RSpec . build_rspec
17
15
min = uglify code
18
16
19
17
puts "\n development: #{ code . size } , minified: #{ min . size } "
20
18
end
21
19
22
- def build_rspec
23
- Opal ::Processor . dynamic_require_severity = :warning
24
- Opal . append_path 'app'
25
-
26
- Opal . use_gem 'rspec'
27
- Opal . use_gem 'rspec-expectations'
28
-
29
- %w[ time fileutils test/unit/assertions coderay optparse shellwords socket uri
30
- drb/drb diff/lcs diff/lcs/hunk ] . each do |asset |
31
- Opal ::Processor . stub_file asset
32
- end
33
-
34
- # bug in rspec? this autoload doesnt exist so we must stub it
35
- Opal ::Processor . stub_file 'rspec/matchers/built_in/have'
36
-
37
- Opal . process ( 'rspec-builder' )
38
- end
39
-
40
20
def uglify ( str )
41
21
IO . popen ( 'uglifyjs' , 'r+' ) do |i |
42
22
i . puts str
Original file line number Diff line number Diff line change 1
1
require 'opal'
2
2
require 'opal/rspec/version'
3
3
4
+ module Opal
5
+ module RSpec
6
+ extend self
7
+
8
+ def base_dir
9
+ File . expand_path ( '../../..' , __FILE__ )
10
+ end
11
+
12
+ def build_rspec_js force = false
13
+ path = File . expand_path ( '../../../opal/opal/rspec/rspec.js' , __FILE__ )
14
+ puts "Building: #{ path } ..."
15
+ return if File . exist? path and not( force )
16
+ File . open ( path , 'w+' ) { |out | out << rspec_js_code }
17
+ end
18
+
19
+ def rspec_js_code
20
+ previous_severity = Opal ::Processor . dynamic_require_severity
21
+ Opal ::Processor . dynamic_require_severity = :warning
22
+ Opal . append_path File . join ( base_dir , 'app' )
23
+
24
+ Opal . use_gem 'rspec'
25
+ Opal . use_gem 'rspec-expectations'
26
+
27
+ %w[ time fileutils test/unit/assertions coderay optparse shellwords socket uri
28
+ drb/drb diff/lcs diff/lcs/hunk ] . each do |asset |
29
+ Opal ::Processor . stub_file asset
30
+ end
31
+
32
+ # bug in rspec? this autoload doesnt exist so we must stub it
33
+ Opal ::Processor . stub_file 'rspec/matchers/built_in/have'
34
+
35
+ Opal . process ( 'rspec-builder' ) . tap do
36
+ Opal ::Processor . dynamic_require_severity = previous_severity
37
+ end
38
+ end
39
+ end
40
+ end
41
+
4
42
# Just register our opal code path with opal build tools
5
- Opal . append_path File . expand_path ( '../../../opal' , __FILE__ )
43
+ Opal . append_path File . join ( Opal :: RSpec . base_dir , 'opal' )
6
44
Original file line number Diff line number Diff line change @@ -11,8 +11,10 @@ class RakeTask
11
11
URL = "http://localhost:9999/"
12
12
13
13
def initialize ( name = 'opal:rspec' , &block )
14
+ Opal ::RSpec . build_rspec_js
15
+
14
16
desc "Run opal specs in phantomjs"
15
- task name do
17
+ task name => 'opal:rspec:build' do
16
18
require 'rack'
17
19
require 'webrick'
18
20
@@ -37,6 +39,12 @@ def initialize(name = 'opal:rspec', &block)
37
39
38
40
exit 1 unless success
39
41
end
42
+
43
+ desc 'Build opal/opal/rspec/rspec.js'
44
+ task 'opal:rspec:build' do
45
+ Opal ::RSpec . build_rspec_js
46
+ end
47
+
40
48
end
41
49
end
42
50
end
Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ Gem::Specification.new do |s|
18
18
s . add_dependency 'opal' , '~> 0.6.0'
19
19
s . add_dependency 'opal-sprockets' , '~> 0.4.0'
20
20
21
+ s . add_dependency 'rspec' , '3.0.0.beta1'
22
+ s . add_dependency 'rspec-support' , '3.0.0.beta1'
23
+ s . add_dependency 'rspec-core' , '3.0.0.beta1'
24
+ s . add_dependency 'rspec-mocks' , '3.0.0.beta1'
25
+ s . add_dependency 'rspec-expectations' , '3.0.0.beta1'
26
+
21
27
s . add_development_dependency 'rake'
22
28
end
23
29
You can’t perform that action at this time.
0 commit comments