jspec-steventux 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.md +763 -0
- data/Manifest +73 -0
- data/README.md +974 -0
- data/Rakefile +44 -0
- data/bin/jspec +178 -0
- data/jspec-steventux.gemspec +44 -0
- data/lib/images/bg.png +0 -0
- data/lib/images/hr.png +0 -0
- data/lib/images/loading.gif +0 -0
- data/lib/images/sprites.bg.png +0 -0
- data/lib/images/sprites.png +0 -0
- data/lib/images/vr.png +0 -0
- data/lib/jspec.css +149 -0
- data/lib/jspec.growl.js +115 -0
- data/lib/jspec.jquery.js +72 -0
- data/lib/jspec.js +1756 -0
- data/lib/jspec.shell.js +39 -0
- data/lib/jspec.timers.js +90 -0
- data/lib/jspec.xhr.js +195 -0
- data/spec/commands/example_command.rb +19 -0
- data/spec/dom.html +33 -0
- data/spec/fixtures/test.html +1 -0
- data/spec/fixtures/test.json +1 -0
- data/spec/fixtures/test.xml +5 -0
- data/spec/node.js +17 -0
- data/spec/rhino.js +23 -0
- data/spec/ruby/bin/init_spec.rb +101 -0
- data/spec/ruby/bin/install_spec.rb +142 -0
- data/spec/ruby/bin/run_spec.rb +0 -0
- data/spec/ruby/bin/shell_spec.rb +13 -0
- data/spec/ruby/bin/spec_helper.rb +8 -0
- data/spec/ruby/bin/update_spec.rb +72 -0
- data/spec/server.html +29 -0
- data/spec/server.rb +2 -0
- data/spec/support/env.js +10118 -0
- data/spec/support/jquery.js +4376 -0
- data/spec/unit/helpers.js +64 -0
- data/spec/unit/spec.fixtures.js +17 -0
- data/spec/unit/spec.grammar-less.js +34 -0
- data/spec/unit/spec.grammar.js +241 -0
- data/spec/unit/spec.jquery.js +178 -0
- data/spec/unit/spec.jquery.xhr.js +84 -0
- data/spec/unit/spec.js +187 -0
- data/spec/unit/spec.matchers.js +577 -0
- data/spec/unit/spec.modules.js +51 -0
- data/spec/unit/spec.shared-behaviors.js +80 -0
- data/spec/unit/spec.utils.js +346 -0
- data/spec/unit/spec.xhr.js +157 -0
- data/src/browsers.rb +294 -0
- data/src/helpers.rb +67 -0
- data/src/installables.rb +229 -0
- data/src/project.rb +341 -0
- data/src/routes.rb +57 -0
- data/src/server.rb +99 -0
- data/support/js.jar +0 -0
- data/templates/default/History.md +5 -0
- data/templates/default/Readme.md +29 -0
- data/templates/default/lib/yourlib.js +2 -0
- data/templates/default/spec/commands/example_command.rb +19 -0
- data/templates/default/spec/dom.html +22 -0
- data/templates/default/spec/node.js +10 -0
- data/templates/default/spec/rhino.js +10 -0
- data/templates/default/spec/server.html +18 -0
- data/templates/default/spec/server.rb +4 -0
- data/templates/default/spec/unit/spec.helper.js +0 -0
- data/templates/default/spec/unit/spec.js +8 -0
- data/templates/rails/commands/example_commands.rb +19 -0
- data/templates/rails/dom.html +22 -0
- data/templates/rails/rhino.js +10 -0
- data/templates/rails/server.html +18 -0
- data/templates/rails/server.rb +4 -0
- data/templates/rails/unit/spec.helper.js +0 -0
- data/templates/rails/unit/spec.js +8 -0
- metadata +185 -0
data/src/helpers.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
|
2
|
+
helpers do
|
3
|
+
|
4
|
+
##
|
5
|
+
# Return dotted assertion graph for _assertions_.
|
6
|
+
|
7
|
+
def assertion_graph_for assertions
|
8
|
+
return if assertions.empty?
|
9
|
+
assertions.map do |assertion|
|
10
|
+
assertion['passed'] ? green('.') : red('.')
|
11
|
+
end.join
|
12
|
+
end
|
13
|
+
|
14
|
+
##
|
15
|
+
# Override Sinatra's #send_file to prevent caching.
|
16
|
+
|
17
|
+
def send_file *args
|
18
|
+
response['Cache-Control'] = 'no-cache'
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# Find the browser name for the current user agent.
|
24
|
+
|
25
|
+
def browser_name
|
26
|
+
Browser.subclasses.find do |browser|
|
27
|
+
browser.matches_agent? env['HTTP_USER_AGENT']
|
28
|
+
end.new
|
29
|
+
rescue
|
30
|
+
'Unknown'
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Wrap _string_ with ansi escape sequence using _code_.
|
35
|
+
|
36
|
+
def color string, code
|
37
|
+
"\e[#{code}m#{string}\e[0m"
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# Bold _string_.
|
42
|
+
|
43
|
+
def bold string
|
44
|
+
color string, 1
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# Color _string_ red.
|
49
|
+
|
50
|
+
def red string
|
51
|
+
color string, 31
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
# Color _string_ green.
|
56
|
+
|
57
|
+
def green string
|
58
|
+
color string, 32
|
59
|
+
end
|
60
|
+
|
61
|
+
##
|
62
|
+
# Color _string_ blue.
|
63
|
+
|
64
|
+
def blue string
|
65
|
+
color string, 34
|
66
|
+
end
|
67
|
+
end
|
data/src/installables.rb
ADDED
@@ -0,0 +1,229 @@
|
|
1
|
+
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
module JSpec
|
5
|
+
class Installable
|
6
|
+
|
7
|
+
##
|
8
|
+
# Options array
|
9
|
+
|
10
|
+
attr_reader :options
|
11
|
+
|
12
|
+
##
|
13
|
+
# Initialize with _options_
|
14
|
+
|
15
|
+
def initialize options = {}
|
16
|
+
@options = options
|
17
|
+
end
|
18
|
+
|
19
|
+
##
|
20
|
+
# Called before installing.
|
21
|
+
|
22
|
+
def before; end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Called after installing.
|
26
|
+
|
27
|
+
def after; end
|
28
|
+
|
29
|
+
##
|
30
|
+
# Message to display after installation.
|
31
|
+
|
32
|
+
def install_message; end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Weither or not to use the progress bar.
|
36
|
+
|
37
|
+
def use_progress_bar?; true end
|
38
|
+
|
39
|
+
#--
|
40
|
+
# URI based installations
|
41
|
+
#++
|
42
|
+
|
43
|
+
class URI < self
|
44
|
+
|
45
|
+
##
|
46
|
+
# Release specified or the current release.
|
47
|
+
|
48
|
+
def release
|
49
|
+
options[:release] || self.class.current
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
# Installation path.
|
54
|
+
|
55
|
+
def path
|
56
|
+
options[:to] + "/#{self.class.name.downcase.tr(' ', '.')}.js"
|
57
|
+
end
|
58
|
+
|
59
|
+
##
|
60
|
+
# Installation uri.
|
61
|
+
|
62
|
+
def uri
|
63
|
+
self.class.uri.sub 'RELEASE', release
|
64
|
+
end
|
65
|
+
|
66
|
+
##
|
67
|
+
# Install.
|
68
|
+
|
69
|
+
def install
|
70
|
+
File.open(path, 'w+') do |file|
|
71
|
+
file.write open(uri).read
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
##
|
76
|
+
# Installation message.
|
77
|
+
|
78
|
+
def install_message
|
79
|
+
"#{self.class.name} #{release} installed to #{path}"
|
80
|
+
end
|
81
|
+
|
82
|
+
#--
|
83
|
+
# DSL
|
84
|
+
#++
|
85
|
+
|
86
|
+
class << self
|
87
|
+
|
88
|
+
##
|
89
|
+
# Human readable name.
|
90
|
+
|
91
|
+
def name string = nil
|
92
|
+
string ? @name = string : @name
|
93
|
+
end
|
94
|
+
|
95
|
+
##
|
96
|
+
# Current release _string_.
|
97
|
+
|
98
|
+
def current string = nil
|
99
|
+
string ? @current = string : @current
|
100
|
+
end
|
101
|
+
|
102
|
+
##
|
103
|
+
# Installable uri _string_. use RELEASE as the release placeholder.
|
104
|
+
|
105
|
+
def uri string = nil
|
106
|
+
string ? @uri = string : @uri
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
#--
|
113
|
+
# Rhino
|
114
|
+
#++
|
115
|
+
|
116
|
+
class Rhino < URI
|
117
|
+
name 'Rhino'
|
118
|
+
uri 'ftp://ftp.mozilla.org/pub/mozilla.org/js/RELEASE.zip'
|
119
|
+
|
120
|
+
##
|
121
|
+
# No thanks!
|
122
|
+
|
123
|
+
def use_progress_bar?
|
124
|
+
false
|
125
|
+
end
|
126
|
+
|
127
|
+
##
|
128
|
+
# Extension destination.
|
129
|
+
|
130
|
+
def path
|
131
|
+
options[:to] + '/js.jar'
|
132
|
+
end
|
133
|
+
|
134
|
+
##
|
135
|
+
# Warn that --release is not yet supported.
|
136
|
+
|
137
|
+
def release
|
138
|
+
warn 'Rhino does not yet support --release' if options[:release]
|
139
|
+
'rhino1_7R2'
|
140
|
+
end
|
141
|
+
|
142
|
+
##
|
143
|
+
# Install
|
144
|
+
|
145
|
+
def install
|
146
|
+
say "... fetching #{uri}"; `curl #{uri} -o /tmp/rhino.zip 2> /dev/null`
|
147
|
+
say "... decompressing"; `unzip /tmp/rhino.zip -d /tmp`
|
148
|
+
say "... installing to #{path}"; `mv /tmp/rhino1_7R2/js.jar #{path}`
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
#--
|
154
|
+
# Envjs
|
155
|
+
#++
|
156
|
+
|
157
|
+
class Envjs < URI
|
158
|
+
name 'Env.js'
|
159
|
+
uri 'http://github.com/thatcher/env-js/raw/master/dist/env.rhino.js'
|
160
|
+
|
161
|
+
##
|
162
|
+
# Warn that --release is not yet supported.
|
163
|
+
|
164
|
+
def release
|
165
|
+
warn 'Envjs does not yet support --release' if options[:release]
|
166
|
+
'edge'
|
167
|
+
end
|
168
|
+
|
169
|
+
##
|
170
|
+
# Installation path.
|
171
|
+
|
172
|
+
def path
|
173
|
+
options[:to] + '/env.js'
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
#--
|
179
|
+
# jQuery
|
180
|
+
#++
|
181
|
+
|
182
|
+
class Jquery < URI
|
183
|
+
name 'jQuery'
|
184
|
+
current '1.3.2'
|
185
|
+
uri 'http://ajax.googleapis.com/ajax/libs/jquery/RELEASE/jquery.js'
|
186
|
+
end
|
187
|
+
|
188
|
+
#--
|
189
|
+
# jQuery UI.
|
190
|
+
#++
|
191
|
+
|
192
|
+
class Jqueryui < URI
|
193
|
+
name 'jQuery UI'
|
194
|
+
current '1.7.2'
|
195
|
+
uri 'http://ajax.googleapis.com/ajax/libs/jqueryui/RELEASE/jquery-ui.js'
|
196
|
+
end
|
197
|
+
|
198
|
+
#--
|
199
|
+
# Prototype
|
200
|
+
#++
|
201
|
+
|
202
|
+
class Prototype < URI
|
203
|
+
name 'Prototype'
|
204
|
+
current '1.6.1.0'
|
205
|
+
uri 'http://ajax.googleapis.com/ajax/libs/prototype/RELEASE/prototype.js'
|
206
|
+
end
|
207
|
+
|
208
|
+
#--
|
209
|
+
# MooTools
|
210
|
+
#++
|
211
|
+
|
212
|
+
class Mootools < URI
|
213
|
+
name 'MooTools'
|
214
|
+
current '1.2.3'
|
215
|
+
uri 'http://ajax.googleapis.com/ajax/libs/mootools/RELEASE/mootools.js'
|
216
|
+
end
|
217
|
+
|
218
|
+
#--
|
219
|
+
# Dojo
|
220
|
+
#++
|
221
|
+
|
222
|
+
class Dojo < URI
|
223
|
+
name 'Dojo'
|
224
|
+
current '1.3.2'
|
225
|
+
uri 'http://ajax.googleapis.com/ajax/libs/dojo/RELEASE/dojo/dojo.xd.js.uncompressed.js'
|
226
|
+
end
|
227
|
+
|
228
|
+
end
|
229
|
+
end
|
data/src/project.rb
ADDED
@@ -0,0 +1,341 @@
|
|
1
|
+
|
2
|
+
module JSpec
|
3
|
+
|
4
|
+
#--
|
5
|
+
# Base project
|
6
|
+
#++
|
7
|
+
|
8
|
+
class Project
|
9
|
+
|
10
|
+
#--
|
11
|
+
# Constants
|
12
|
+
#++
|
13
|
+
|
14
|
+
BIND_PATHS = 'lib/**/*.js', 'spec/**/*.js'
|
15
|
+
RHINO = JSPEC_ROOT + '/support/js.jar'
|
16
|
+
|
17
|
+
##
|
18
|
+
# Destination directory.
|
19
|
+
|
20
|
+
attr_reader :dest
|
21
|
+
|
22
|
+
##
|
23
|
+
# Initialize project with _dest_.
|
24
|
+
|
25
|
+
def initialize dest
|
26
|
+
@dest = dest || '.'
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# Execute _file_ with Node.js
|
31
|
+
|
32
|
+
def node file
|
33
|
+
system "node #{file}"
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Execute _file_ with Rhino.
|
38
|
+
|
39
|
+
def rhino file
|
40
|
+
system "java -jar #{rhino_jar} #{file}"
|
41
|
+
end
|
42
|
+
|
43
|
+
##
|
44
|
+
# Locate Rhino jar.
|
45
|
+
#
|
46
|
+
# * checks spec/support/js.jar
|
47
|
+
# * defaults to JSpec's support/js.jar
|
48
|
+
#
|
49
|
+
|
50
|
+
def rhino_jar
|
51
|
+
if File.exists? normalize('support/js.jar')
|
52
|
+
normalize 'support/js.jar'
|
53
|
+
else
|
54
|
+
RHINO
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
##
|
59
|
+
# Install project _name_ with _options_.
|
60
|
+
|
61
|
+
def install name, options = {}
|
62
|
+
raise ArgumentError, ':to option required' unless options.include? :to
|
63
|
+
project = JSpec::Installable.const_get(name.downcase.capitalize).new options
|
64
|
+
if project.use_progress_bar?
|
65
|
+
progress [:before, :install, :after],
|
66
|
+
:complete_message => project.install_message,
|
67
|
+
:format => "Installing #{name} (:progress_bar) %:percent_complete" do |method|
|
68
|
+
project.send method
|
69
|
+
end
|
70
|
+
else
|
71
|
+
project.before
|
72
|
+
project.install
|
73
|
+
project.after
|
74
|
+
say project.install_message
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
##
|
79
|
+
# Initialize the project with _options_
|
80
|
+
|
81
|
+
def init! options = {}
|
82
|
+
verify_empty!
|
83
|
+
copy_template :default
|
84
|
+
vendorize_with_symlink if options.include? :symlink
|
85
|
+
vendorize_with_copy if options.include? :freeze
|
86
|
+
replace_root
|
87
|
+
end
|
88
|
+
|
89
|
+
##
|
90
|
+
# Vendorize JSpec with symlink.
|
91
|
+
|
92
|
+
def vendorize_with_symlink
|
93
|
+
FileUtils.symlink "#{JSPEC_ROOT}/lib", normalize('lib'), :force => true
|
94
|
+
end
|
95
|
+
|
96
|
+
##
|
97
|
+
# Vendorize JSpec with copy.
|
98
|
+
|
99
|
+
def vendorize_with_copy
|
100
|
+
FileUtils.cp_r "#{JSPEC_ROOT}/lib", normalize('lib')
|
101
|
+
end
|
102
|
+
|
103
|
+
##
|
104
|
+
# Copy template _name_ to the destination.
|
105
|
+
|
106
|
+
def copy_template name, options = {}
|
107
|
+
FileUtils.mkdir_p dest
|
108
|
+
FileUtils.cp_r path_to_template(name), options[:to] ?
|
109
|
+
"#{dest}/#{options[:to]}" :
|
110
|
+
dest
|
111
|
+
end
|
112
|
+
|
113
|
+
##
|
114
|
+
# Normalize _path_.
|
115
|
+
|
116
|
+
def normalize path
|
117
|
+
"#{dest}/spec/#{path}"
|
118
|
+
end
|
119
|
+
|
120
|
+
##
|
121
|
+
# Check if we are working with vendorized JSpec.
|
122
|
+
|
123
|
+
def vendorized?
|
124
|
+
File.directory?(normalize(:lib)) && normalize(:lib)
|
125
|
+
end
|
126
|
+
|
127
|
+
##
|
128
|
+
# Replace absolute JSPEC_ROOT paths.
|
129
|
+
|
130
|
+
def replace_root
|
131
|
+
replace_root_in 'dom.html', 'rhino.js', 'node.js'
|
132
|
+
end
|
133
|
+
|
134
|
+
##
|
135
|
+
# Root JSpec directory.
|
136
|
+
|
137
|
+
def root
|
138
|
+
vendorized? ? './spec' : JSPEC_ROOT
|
139
|
+
end
|
140
|
+
|
141
|
+
##
|
142
|
+
# Replace absolute JSPEC_ROOT _paths_.
|
143
|
+
|
144
|
+
def replace_root_in *paths
|
145
|
+
paths.each do |path|
|
146
|
+
next unless File.exists? normalize(path)
|
147
|
+
jspec_root = root
|
148
|
+
jspec_root = '.' if vendorized? and path.include? '.html'
|
149
|
+
contents = File.read(normalize(path)).gsub 'JSPEC_ROOT', jspec_root
|
150
|
+
File.open(normalize(path), 'w') { |file| file.write contents }
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
##
|
155
|
+
# Path to template _name_.
|
156
|
+
|
157
|
+
def path_to_template name
|
158
|
+
"#{JSPEC_ROOT}/templates/#{name}/."
|
159
|
+
end
|
160
|
+
|
161
|
+
##
|
162
|
+
# Verify that the current directory is empty, otherwise
|
163
|
+
# prompt for continuation.
|
164
|
+
|
165
|
+
def verify_empty!
|
166
|
+
unless Dir[dest + '/*'].empty?
|
167
|
+
abort unless agree "`#{dest}' is not empty; continue? "
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
##
|
172
|
+
# Update absolute paths and/or vendorized libraries.
|
173
|
+
|
174
|
+
def update!
|
175
|
+
if path = vendorized?
|
176
|
+
type = File.symlink?(path) ? :symlink : :copy
|
177
|
+
FileUtils.rm_rf normalize(:lib)
|
178
|
+
send "vendorize_with_#{type}"
|
179
|
+
say "updated #{type} #{path} -> #{program(:version)}"
|
180
|
+
else
|
181
|
+
['dom.html', 'rhino.js', 'node.js'].each do |path|
|
182
|
+
path = normalize path
|
183
|
+
next unless File.exists? path
|
184
|
+
contents = File.read(path).gsub /jspec-(\d+\.\d+\.\d+)/, "jspec-#{program(:version)}"
|
185
|
+
if program(:version) == $1
|
186
|
+
say "skipping #{path}; already #{$1}"
|
187
|
+
next
|
188
|
+
end
|
189
|
+
File.open(path, 'r+'){ |file| file.write contents }
|
190
|
+
say "updated #{path}; #{$1} -> #{program(:version)}"
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
##
|
196
|
+
# Start server with _path_ html and _options_.
|
197
|
+
|
198
|
+
def start_server path, options = {}
|
199
|
+
options[:port] ||= 4444
|
200
|
+
set :port, options[:port]
|
201
|
+
set :server, 'Mongrel'
|
202
|
+
enable :sessions
|
203
|
+
disable :logging
|
204
|
+
hook = File.expand_path normalize('server.rb')
|
205
|
+
load hook if File.exists? hook
|
206
|
+
browsers = browsers_for(options[:browsers]) if options.include? :browsers
|
207
|
+
JSpec::Server.new(path, options[:port]).start(browsers)
|
208
|
+
end
|
209
|
+
|
210
|
+
##
|
211
|
+
# Return array of browser instances for the given _names_.
|
212
|
+
|
213
|
+
def browsers_for names
|
214
|
+
names.map do |name|
|
215
|
+
begin
|
216
|
+
Browser.subclasses.find do |browser|
|
217
|
+
browser.matches_name? name
|
218
|
+
end.new
|
219
|
+
rescue
|
220
|
+
raise "Unsupported browser `#{name}'"
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
##
|
226
|
+
# Run _path_ with _options_.
|
227
|
+
|
228
|
+
def run! path = nil, options = {}
|
229
|
+
paths = options[:paths] || self.class::BIND_PATHS
|
230
|
+
|
231
|
+
# Action
|
232
|
+
|
233
|
+
case
|
234
|
+
when options.include?(:node)
|
235
|
+
path ||= normalize('node.js')
|
236
|
+
action = lambda { node(path) }
|
237
|
+
when options.include?(:rhino)
|
238
|
+
path ||= normalize('rhino.js')
|
239
|
+
action = lambda { rhino(path) }
|
240
|
+
when options.include?(:server)
|
241
|
+
raise 'Cannot use --bind with --server' if options.include? :bind
|
242
|
+
path ||= normalize('server.html')
|
243
|
+
action = lambda { start_server path, options }
|
244
|
+
else
|
245
|
+
path ||= normalize('dom.html')
|
246
|
+
browsers = browsers_for options[:browsers] || ['default']
|
247
|
+
action = lambda do
|
248
|
+
browsers.each do |browser|
|
249
|
+
browser.visit File.expand_path(path)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
# Bind action
|
255
|
+
|
256
|
+
if options.include? :bind
|
257
|
+
Bind::Listener.new(
|
258
|
+
:paths => paths,
|
259
|
+
:interval => 1,
|
260
|
+
:actions => [action],
|
261
|
+
:debug => $stdout).run!
|
262
|
+
else
|
263
|
+
exit !! action.call
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
##
|
268
|
+
# Return the Project instance which should be used for _dest_.
|
269
|
+
|
270
|
+
def self.for dest
|
271
|
+
(File.directory?("#{dest}/vendor") ?
|
272
|
+
JSpec::Project::Rails :
|
273
|
+
JSpec::Project).new(dest)
|
274
|
+
end
|
275
|
+
|
276
|
+
##
|
277
|
+
# Load all commands at the given _dir_.
|
278
|
+
|
279
|
+
def self.load_commands_at dir
|
280
|
+
Dir["#{dir}/**/*_command.rb"].each { |file| load file }
|
281
|
+
end
|
282
|
+
|
283
|
+
#--
|
284
|
+
# Rails project
|
285
|
+
#++
|
286
|
+
|
287
|
+
class Rails < self
|
288
|
+
|
289
|
+
#--
|
290
|
+
# Constants
|
291
|
+
#++
|
292
|
+
|
293
|
+
BIND_PATHS = 'public/javascripts/**/*.js', 'jspec/**/*.js'
|
294
|
+
|
295
|
+
##
|
296
|
+
# Initialize the project with _options_
|
297
|
+
|
298
|
+
def init! options = {}
|
299
|
+
verify_rails!
|
300
|
+
copy_template :rails, :to => :jspec
|
301
|
+
vendorize_with_symlink if options.include? :symlink
|
302
|
+
vendorize_with_copy if options.include? :freeze
|
303
|
+
replace_root
|
304
|
+
end
|
305
|
+
|
306
|
+
##
|
307
|
+
# Root JSpec directory.
|
308
|
+
|
309
|
+
def root
|
310
|
+
vendorized? ? './jspec' : JSPEC_ROOT
|
311
|
+
end
|
312
|
+
|
313
|
+
##
|
314
|
+
# Normalize _path_.
|
315
|
+
|
316
|
+
def normalize path
|
317
|
+
"#{dest}/jspec/#{path}"
|
318
|
+
end
|
319
|
+
|
320
|
+
##
|
321
|
+
# Verify that the current directory is rails, otherwise
|
322
|
+
# prompt for continuation.
|
323
|
+
|
324
|
+
def verify_rails!
|
325
|
+
unless rails?
|
326
|
+
abort unless agree "`#{dest}' does not appear to be a rails app; continue? "
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
##
|
331
|
+
# Check if the destination is the root of
|
332
|
+
# a rails application.
|
333
|
+
|
334
|
+
def rails?
|
335
|
+
File.directory? dest + '/vendor'
|
336
|
+
end
|
337
|
+
|
338
|
+
end
|
339
|
+
|
340
|
+
end
|
341
|
+
end
|