jasmine-rails 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +57 -11
- data/lib/jasmine_rails/engine.rb +1 -0
- data/lib/jasmine_rails/offline_asset_paths.rb +8 -6
- data/lib/jasmine_rails/version.rb +1 -1
- data/lib/tasks/jasmine-rails_tasks.rake +6 -2
- metadata +40 -2
data/Rakefile
CHANGED
@@ -3,20 +3,66 @@ begin
|
|
3
3
|
require 'bundler/setup'
|
4
4
|
rescue LoadError
|
5
5
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
exit # bundler is required for testbeds
|
6
7
|
end
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
require 'testbeds/rake'
|
10
|
+
require 'rspec/core/rake_task'
|
10
11
|
Bundler::GemHelper.install_tasks
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
cd spec/dummy
|
15
|
-
bundle exec rake spec:javascript
|
16
|
-
BASH
|
17
|
-
end
|
13
|
+
if File.directory?(File.expand_path('spec/testbeds', File.dirname(__FILE__)))
|
14
|
+
all_test_tasks = []
|
18
15
|
|
19
|
-
|
20
|
-
|
16
|
+
each_testbed do |testbed| # namespace 'testbed:rails-3.2'
|
17
|
+
|
18
|
+
desc "run specs with phantomjs in #{testbed.name}"
|
19
|
+
task :run_jasmine_rake_in_dummy do
|
20
|
+
p testbed.gemfile
|
21
|
+
ENV['BUNDLE_GEMFILE'] = testbed.gemfile
|
22
|
+
cmd = 'bundle exec rake testbed:current:spec:javascript'
|
23
|
+
raise 'specs failed' unless system cmd
|
24
|
+
end
|
21
25
|
|
22
|
-
|
26
|
+
desc "run specs with browser in #{testbed.name}"
|
27
|
+
task :run_browser_spec_in_dummy do
|
28
|
+
p testbed.gemfile
|
29
|
+
ENV['BUNDLE_GEMFILE'] = testbed.gemfile
|
30
|
+
unless Rake::Task.task_defined?('_in_browser')
|
31
|
+
RSpec::Core::RakeTask.new(:_in_browser) do |t|
|
32
|
+
deps = testbed.dependencies
|
33
|
+
t.pattern = "spec/jasmine_spec.rb"
|
34
|
+
t.rspec_opts = deps.collect { |d| [ '-r', d ] }.flatten
|
35
|
+
end
|
36
|
+
end
|
37
|
+
Rake::Task['_in_browser'].invoke
|
38
|
+
Rake::Task['_in_browser'].reenable
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "run all tests in #{testbed.name}"
|
42
|
+
task :all => [
|
43
|
+
"#{testbed.namespace}:run_jasmine_rake_in_dummy",
|
44
|
+
"#{testbed.namespace}:run_browser_spec_in_dummy"
|
45
|
+
]
|
46
|
+
|
47
|
+
all_test_tasks << "#{testbed.namespace}:all"
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "run all tests"
|
51
|
+
task :default => all_test_tasks
|
52
|
+
else
|
53
|
+
desc "run all tests"
|
54
|
+
task :default do
|
55
|
+
puts "To run tests, you must generate testbeds:"
|
56
|
+
puts
|
57
|
+
puts "1. Install bundle for each file in gemfiles/*:"
|
58
|
+
Dir['gemfiles/*'].each do |dir|
|
59
|
+
next if dir['.lock']
|
60
|
+
puts " BUNDLE_GEMFILE=#{dir} bundle install"
|
61
|
+
end
|
62
|
+
puts
|
63
|
+
puts "2. Execute `generate-testbeds` to generate testbed apps."
|
64
|
+
puts " (Don't use `bundle exec` for this.)"
|
65
|
+
puts
|
66
|
+
puts "3. Run `rake` again."
|
67
|
+
end
|
68
|
+
end
|
data/lib/jasmine_rails/engine.rb
CHANGED
@@ -5,6 +5,7 @@ module JasmineRails
|
|
5
5
|
isolate_namespace JasmineRails
|
6
6
|
|
7
7
|
initializer :assets do |config|
|
8
|
+
Rails.application.config.assets.debug = false
|
8
9
|
Rails.application.config.assets.paths << Jasmine::Core.path
|
9
10
|
Rails.application.config.assets.paths << JasmineRails.spec_dir
|
10
11
|
end
|
@@ -7,6 +7,12 @@ module JasmineRails
|
|
7
7
|
mattr_accessor :disabled
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
included do
|
10
|
+
if ::Rails::VERSION::MAJOR == 4
|
11
|
+
alias_method :compute_public_path, :compute_asset_path
|
12
|
+
alias_method :compute_asset_path_with_offline_asset, :compute_public_path_with_offline_asset
|
13
|
+
alias_method_chain :compute_asset_path, :offline_asset
|
14
|
+
end
|
15
|
+
|
10
16
|
alias_method_chain :compute_public_path, :offline_asset
|
11
17
|
end
|
12
18
|
|
@@ -14,17 +20,13 @@ module JasmineRails
|
|
14
20
|
return compute_public_path_without_offline_asset(source, dir, options) if JasmineRails::OfflineAssetPaths.disabled
|
15
21
|
return source if source.starts_with?('/')
|
16
22
|
content = Rails.application.assets[source].to_s
|
17
|
-
source_path =
|
23
|
+
source_path = Rails.root.join('spec/tmp/assets').join(source)
|
18
24
|
|
19
25
|
FileUtils.mkdir_p File.dirname(source_path)
|
20
26
|
Rails.logger.debug "Compiling #{source} to #{source_path}"
|
21
27
|
File.open(source_path, 'w') {|f| f << content }
|
22
|
-
"assets/#{source}"
|
28
|
+
"/assets/#{source}"
|
23
29
|
end
|
24
30
|
|
25
|
-
private
|
26
|
-
def offline_asset_dir
|
27
|
-
Rails.root.join('spec/tmp/assets')
|
28
|
-
end
|
29
31
|
end
|
30
32
|
end
|
@@ -10,7 +10,11 @@ namespace :spec do
|
|
10
10
|
task :javascript => :environment do
|
11
11
|
Rails.application.config.assets.debug = false
|
12
12
|
require 'jasmine_rails/offline_asset_paths'
|
13
|
-
|
13
|
+
if Rails::VERSION::MAJOR == 4
|
14
|
+
Sprockets::Rails::Helper.send :include, JasmineRails::OfflineAssetPaths
|
15
|
+
else
|
16
|
+
ActionView::AssetPaths.send :include, JasmineRails::OfflineAssetPaths
|
17
|
+
end
|
14
18
|
spec_filter = ENV['SPEC']
|
15
19
|
app = ActionController::Integration::Session.new(Rails.application)
|
16
20
|
path = JasmineRails.route_path
|
@@ -19,7 +23,7 @@ namespace :spec do
|
|
19
23
|
raise "Jasmine runner at '#{path}' returned a #{app.response.status} error: #{app.response.message}" unless app.response.success?
|
20
24
|
html = app.response.body
|
21
25
|
runner_path = Rails.root.join('spec/tmp/runner.html')
|
22
|
-
File.open(runner_path, 'w') {|f| f << html}
|
26
|
+
File.open(runner_path, 'w') {|f| f << html.gsub('/assets', './assets')}
|
23
27
|
|
24
28
|
run_cmd %{phantomjs "#{File.join(File.dirname(__FILE__), 'runner.js')}" "file://#{runner_path.to_s}?spec=#{spec_filter}"}
|
25
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jasmine-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-05-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -29,6 +29,22 @@ dependencies:
|
|
29
29
|
- - ! '>='
|
30
30
|
- !ruby/object:Gem::Version
|
31
31
|
version: 3.1.0
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: sprockets-rails
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
32
48
|
- !ruby/object:Gem::Dependency
|
33
49
|
name: jasmine-core
|
34
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,6 +61,22 @@ dependencies:
|
|
45
61
|
- - ~>
|
46
62
|
- !ruby/object:Gem::Version
|
47
63
|
version: '1.3'
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: testbeds
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
type: :development
|
73
|
+
prerelease: false
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
48
80
|
description: Provides a Jasmine Spec Runner that plays nicely with Rails 3.1 assets
|
49
81
|
and sets up jasmine-headless-webkit
|
50
82
|
email:
|
@@ -85,12 +117,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
117
|
- - ! '>='
|
86
118
|
- !ruby/object:Gem::Version
|
87
119
|
version: '0'
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
hash: 2871315701798434786
|
88
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
124
|
none: false
|
90
125
|
requirements:
|
91
126
|
- - ! '>='
|
92
127
|
- !ruby/object:Gem::Version
|
93
128
|
version: '0'
|
129
|
+
segments:
|
130
|
+
- 0
|
131
|
+
hash: 2871315701798434786
|
94
132
|
requirements: []
|
95
133
|
rubyforge_project:
|
96
134
|
rubygems_version: 1.8.23
|