File tree 5 files changed +31
-57
lines changed
5 files changed +31
-57
lines changed Original file line number Diff line number Diff line change @@ -5,3 +5,9 @@ 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,17 +6,37 @@ Opal::RSpec::RakeTask.new(:default)
6
6
7
7
desc "Build opal/opal/rspec/rspec.js"
8
8
task :build do
9
- Opal ::RSpec . build_rspec_js true
9
+ File . open ( 'opal/opal/rspec/rspec.js' , 'w+' ) do |out |
10
+ out << build_rspec
11
+ end
10
12
end
11
13
12
- desc ' Show dev/min sizes'
14
+ desc " Show dev/min sizes"
13
15
task :sizes do
14
- code = Opal :: RSpec . build_rspec
16
+ code = build_rspec
15
17
min = uglify code
16
18
17
19
puts "\n development: #{ code . size } , minified: #{ min . size } "
18
20
end
19
21
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
+
20
40
def uglify ( str )
21
41
IO . popen ( 'uglifyjs' , 'r+' ) do |i |
22
42
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
-
42
4
# Just register our opal code path with opal build tools
43
- Opal . append_path File . join ( Opal :: RSpec . base_dir , ' opal')
5
+ Opal . append_path File . expand_path ( '../../../ opal', __FILE__ )
44
6
Original file line number Diff line number Diff line change @@ -11,10 +11,8 @@ 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
-
16
14
desc "Run opal specs in phantomjs"
17
- task name => 'opal:rspec:build' do
15
+ task name do
18
16
require 'rack'
19
17
require 'webrick'
20
18
@@ -39,12 +37,6 @@ def initialize(name = 'opal:rspec', &block)
39
37
40
38
exit 1 unless success
41
39
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
-
48
40
end
49
41
end
50
42
end
Original file line number Diff line number Diff line change @@ -18,12 +18,6 @@ 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
-
27
21
s . add_development_dependency 'rake'
28
22
end
29
23
You can’t perform that action at this time.
0 commit comments