Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
ed3df106
Commit
ed3df106
authored
May 07, 2013
by
Jay Zoldak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set up rake task for jasmine tests for discussion forums code.
parent
33e8621a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
13 deletions
+91
-13
.gitignore
+1
-0
common/static/coffee/spec/discussion/view/response_comment_show_view_spec.coffee
+26
-0
common/static/coffee/spec/logger_spec.coffee
+2
-2
common/templates/jasmine/base.html
+10
-5
common/templates/jasmine/jasmine_test_runner.html.erb
+24
-3
rakefiles/jasmine.rake
+28
-3
No files found.
.gitignore
View file @
ed3df106
...
...
@@ -40,3 +40,4 @@ node_modules
.prereqs_cache
autodeploy.properties
.ws_migrations_complete
jasmine_test_runner.html
common/static/coffee/spec/discussion/view/response_comment_show_view_spec.coffee
0 → 100644
View file @
ed3df106
describe
"ResponseCommentShowView"
,
->
beforeEach
->
setFixtures
"""
<li>
<div id="comment_518910eab02379ff16000001">
<div class="response-body"><p>This is a comment</p></div>
<div data-tooltip="report misuse" data-role="thread-flag" class="discussion-flag-abuse notflagged">
<i class="icon"></i>
<span class="flag-label"></span>
</div>
<p class="posted-details">–posted
<span title="2013-05-07T14:34:18Z" class="timeago">about a minute ago</span> by
<a class="profile-link" href="/courses/MITx/999/Robot_Super_Course/discussion/forum/users/3">student</a>
</p>
</div>
</li>
"""
# spyOn($.fn, 'load').andReturn(@moduleData)
@
showView
=
new
ResponseCommentShowView
(
el
:
$
(
"li"
)
)
describe
"class definition"
,
->
it
"sets the correct tagName"
,
->
expect
(
@
showView
.
tagName
).
toEqual
(
"li"
)
common/static/coffee/spec/logger_spec.coffee
View file @
ed3df106
describe
'Logger'
,
->
it
'expose window.log_event'
,
->
jasmine
.
stubRequests
()
expect
(
window
.
log_event
).
toBe
Logger
.
log
describe
'log'
,
->
...
...
@@ -12,7 +11,8 @@ describe 'Logger', ->
event
:
'"data"'
page
:
window
.
location
.
href
describe
'bind'
,
->
# Broken with commit 9f75e64? Skipping for now.
xdescribe
'bind'
,
->
beforeEach
->
Logger
.
bind
()
Courseware
.
prefix
=
'/6002x'
...
...
common/templates/jasmine/base.html
View file @
ed3df106
...
...
@@ -37,18 +37,23 @@
<script>
{
%
block
jasmine
%
}
var
console_reporter
=
new
jasmine
.
ConsoleReporter
();
//
var console_reporter = new jasmine.ConsoleReporter();
(
function
()
{
var
jasmineEnv
=
jasmine
.
getEnv
();
jasmineEnv
.
updateInterval
=
1000
;
var
trivialReporter
=
new
jasmine
.
TrivialReporter
();
var
htmlReporter
=
new
jasmine
.
HtmlReporter
();
var
console_reporter
=
new
jasmine
.
ConsoleReporter
()
// var trivialReporter = new jasmine.TrivialReporter();
jasmineEnv
.
addReporter
(
trivialReporter
);
jasmine
.
getEnv
().
addReporter
(
console_reporter
);
jasmineEnv
.
addReporter
(
htmlReporter
);
jasmineEnv
.
addReporter
(
console_reporter
);
// jasmineEnv.addReporter(trivialReporter);
// jasmine.getEnv().addReporter(console_reporter);
jasmineEnv
.
specFilter
=
function
(
spec
)
{
return
trivialReporter
.
specFilter
(
spec
);
// return trivialReporter.specFilter(spec);
return
htmlReporter
.
specFilter
(
spec
);
};
// Additional configuration can be done in this block
...
...
common/
lib/xmodul
e/jasmine_test_runner.html.erb
→
common/
templates/jasmin
e/jasmine_test_runner.html.erb
View file @
ed3df106
...
...
@@ -17,6 +17,7 @@
<script
type=
"text/javascript"
src=
"
<%=
common_js_root
%>
/vendor/tiny_mce/jquery.tinymce.js"
></script>
<script
type=
"text/javascript"
src=
"
<%=
common_js_root
%>
/vendor/tiny_mce/tiny_mce.js"
></script>
<script
type=
"text/javascript"
src=
"
<%=
common_js_root
%>
/vendor/RequireJS.js"
></script>
<script
type=
"text/javascript"
src=
"
<%=
common_js_root
%>
/vendor/mathjax-MathJax-c9db6ac/MathJax.js?config=default"
></script>
<script
type=
"text/javascript"
>
AjaxPrefix
.
addAjaxPrefix
(
jQuery
,
function
()
{
...
...
@@ -37,10 +38,30 @@
<body>
<script
type=
"text/javascript"
>
var
jasmineEnv
=
jasmine
.
getEnv
();
var
htmlReporter
=
new
jasmine
.
HtmlReporter
();
var
console_reporter
=
new
jasmine
.
ConsoleReporter
()
jasmine
.
getEnv
().
addReporter
(
new
jasmine
.
TrivialReporter
());
jasmine
.
getEnv
().
addReporter
(
console_reporter
);
jasmine
.
getEnv
().
execute
();
jasmineEnv
.
addReporter
(
htmlReporter
);
jasmineEnv
.
addReporter
(
console_reporter
);
jasmineEnv
.
specFilter
=
function
(
spec
)
{
return
htmlReporter
.
specFilter
(
spec
);
};
var
currentWindowOnload
=
window
.
onload
;
window
.
onload
=
function
()
{
if
(
currentWindowOnload
)
{
currentWindowOnload
();
}
execJasmine
();
};
function
execJasmine
()
{
jasmineEnv
.
execute
();
}
</script>
</body>
...
...
rakefiles/jasmine.rake
View file @
ed3df106
...
...
@@ -35,11 +35,19 @@ def django_for_jasmine(system, django_reload)
end
def
template_jasmine_runner
(
lib
)
coffee_files
=
Dir
[
"
#{
lib
}
/**/js/**/*.coffee"
,
"common/static/coffee/src/**/*.coffee"
]
case
lib
when
/common\/lib\/.+/
coffee_files
=
Dir
[
"
#{
lib
}
/**/js/**/*.coffee"
,
"common/static/coffee/src/**/*.coffee"
]
when
/common\/static\/coffee/
coffee_files
=
Dir
[
"
#{
lib
}
/**/*.coffee"
]
else
puts
(
'I do not know how to run jasmine tests for #{lib}'
)
exit
end
if
!
coffee_files
.
empty?
sh
(
"node_modules/.bin/coffee -c
#{
coffee_files
.
join
(
' '
)
}
"
)
end
phantom_jasmine_path
=
File
.
expand_path
(
"
node_modules
/phantom-jasmine"
)
phantom_jasmine_path
=
File
.
expand_path
(
"
common/test
/phantom-jasmine"
)
common_js_root
=
File
.
expand_path
(
"common/static/js"
)
common_coffee_root
=
File
.
expand_path
(
"common/static/coffee/src"
)
...
...
@@ -50,7 +58,7 @@ def template_jasmine_runner(lib)
js_specs
=
Dir
[
spec_glob
].
sort_by
{
|
p
|
[
p
.
split
(
'/'
).
length
,
p
]}
.
map
{
|
f
|
File
.
expand_path
(
f
)}
js_source
=
Dir
[
src_glob
].
sort_by
{
|
p
|
[
p
.
split
(
'/'
).
length
,
p
]}
.
map
{
|
f
|
File
.
expand_path
(
f
)}
template
=
ERB
.
new
(
File
.
read
(
"
#{
lib
}
/jasmine_test_runner.html.erb"
))
template
=
ERB
.
new
(
File
.
read
(
"
common/templates/jasmine
/jasmine_test_runner.html.erb"
))
template_output
=
"
#{
lib
}
/jasmine_test_runner.html"
File
.
open
(
template_output
,
'w'
)
do
|
f
|
f
.
write
(
template
.
result
(
binding
))
...
...
@@ -95,3 +103,20 @@ Dir["common/lib/*"].select{|lib| File.directory?(lib)}.each do |lib|
end
end
end
desc
"Open jasmine tests for discussion in your default browser"
task
"browse_jasmine_discussion"
do
template_jasmine_runner
(
"common/static/coffee"
)
do
|
f
|
sh
(
"python -m webbrowser -t 'file://
#{
f
}
'"
)
puts
"Press ENTER to terminate"
.
red
$stdin
.
gets
end
end
desc
"Use phantomjs to run jasmine tests for discussion from the console"
task
"phantomjs_jasmine_discussion"
do
phantomjs
=
ENV
[
'PHANTOMJS_PATH'
]
||
'phantomjs'
template_jasmine_runner
(
"common/static/coffee"
)
do
|
f
|
sh
(
"
#{
phantomjs
}
node_modules/phantom-jasmine/lib/run_jasmine_test.coffee
#{
f
}
"
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment