gokart 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +0 -0
- data/README.md +0 -0
- data/assets/Gemfile +24 -0
- data/assets/Guardfile +37 -0
- data/assets/Rakefile +5 -0
- data/assets/config.rb +24 -0
- data/assets/spec/javascripts/support/jasmine.yml +76 -0
- data/assets/spec/javascripts/support/jasmine_config.rb +23 -0
- data/assets/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/assets/src/server/http_handler.go +139 -0
- data/assets/src/server/main.go +31 -0
- data/assets/src/server/my_test.go +13 -0
- data/assets/src/server/templates.go +42 -0
- data/assets/src/www/app/coffee/application.js.coffee +6 -0
- data/assets/src/www/app/coffee/helpers/properties.js.coffee +19 -0
- data/assets/src/www/app/coffee/libs/deferred.js.coffee +92 -0
- data/assets/src/www/app/coffee/libs/logger.js.coffee +40 -0
- data/assets/src/www/app/coffee/libs/mod_loader.js.coffee +44 -0
- data/assets/src/www/app/coffee/main.js.coffee +10 -0
- data/assets/src/www/app/partials/index.html +92 -0
- data/assets/src/www/app/sass/application.css.scss +136 -0
- data/assets/src/www/app/templates/application.gotmpl +2 -0
- data/assets/src/www/app/templates/base.gotmpl.erb +31 -0
- data/assets/src/www/app/templates/home.gotmpl +30 -0
- data/assets/src/www/spec/coffee/deferred-spec.coffee +202 -0
- data/assets/src/www/spec/coffee/mocks.coffee +137 -0
- data/assets/src/www/spec/coffee/mod_loader-spec.coffee +45 -0
- data/assets/src/www/spec/coffee/properties-spec.coffee +21 -0
- data/assets/tasks/app.rake +34 -0
- data/assets/tasks/jasmine.rake +8 -0
- data/assets/tasks/server.rake +58 -0
- data/assets/tasks/www.rake +162 -0
- data/bin/gokart +28 -0
- data/lib/gokart/base.rb +59 -0
- data/lib/gokart/environment.rb +39 -0
- data/lib/gokart/version.rb +3 -0
- data/lib/gokart.rb +8 -0
- metadata +253 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
<!DOCTYPE HTML>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta name="viewport" content="width=device-width, height=device-height, user-scalable=no, initial-scale=1" />
|
5
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
6
|
+
<title>Narwhal Champion: A Reddit Story</title>
|
7
|
+
<!-- app CSS -->
|
8
|
+
<!--<link rel="stylesheet" href="stylesheets/vendor/jq.ui.css" type="text/css" />-->
|
9
|
+
<link rel="stylesheet" href="stylesheets/application.css" type="text/css" />
|
10
|
+
|
11
|
+
<!-- third party libs -->
|
12
|
+
<script type="text/javascript" src="javascripts/vendor/touch.js"></script>
|
13
|
+
<script type="text/javascript" src="javascripts/vendor/jq.mobi.min.js"></script>
|
14
|
+
<script type="text/javascript" src="javascripts/vendor/jq.web.min.js"></script>
|
15
|
+
<script type="text/javascript" src="javascripts/vendor/jq.ui.min.js"></script>
|
16
|
+
|
17
|
+
<script type="text/javascript" src="javascripts/vendor/phonegap-1.1.0.js"></script>
|
18
|
+
<script type="text/javascript" src="javascripts/vendor/ICanHaz.min.js"></script>
|
19
|
+
|
20
|
+
<!-- application files -->
|
21
|
+
<script type="text/javascript" src="javascripts/libs/mod_loader.js"></script>
|
22
|
+
<script type="text/javascript" src="javascripts/libs/deferred.js"></script>
|
23
|
+
<script type="text/javascript" src="javascripts/libs/3rdparty.js"></script>
|
24
|
+
<script type="text/javascript" src="javascripts/libs/logger.js"></script>
|
25
|
+
<script type="text/javascript" src="javascripts/helpers/properties.js"></script>
|
26
|
+
<script type="text/javascript" src="javascripts/models/comment.js"></script>
|
27
|
+
<script type="text/javascript" src="javascripts/models/post.js"></script>
|
28
|
+
<script type="text/javascript" src="javascripts/models/sub_reddit.js"></script>
|
29
|
+
<script type="text/javascript" src="javascripts/adapters/dummy_data.js"></script>
|
30
|
+
<script type="text/javascript" src="javascripts/adapters/reddit.js"></script>
|
31
|
+
<script type="text/javascript" src="javascripts/widgets/posts.js"></script>
|
32
|
+
<script type="text/javascript" src="javascripts/widgets/post_detail.js"></script>
|
33
|
+
<script type="text/javascript" src="javascripts/widgets/subreddits.js"></script>
|
34
|
+
<script type="text/javascript" src="javascripts/controllers/nav.js"></script>
|
35
|
+
<script type="text/javascript" src="javascripts/controllers/subreddit_posts.js"></script>
|
36
|
+
<script type="text/javascript" src="javascripts/controllers/app.js"></script>
|
37
|
+
<script type="text/javascript" src="javascripts/main.js"></script>
|
38
|
+
|
39
|
+
<!-- Templates -->
|
40
|
+
<script id="subReddits" type="text/html">
|
41
|
+
{{#subs}}
|
42
|
+
<li><a href="#subreddit-posts-{{id}}" id="{{id}}">{{name}}</a></li>
|
43
|
+
{{/subs}}
|
44
|
+
</script>
|
45
|
+
|
46
|
+
<script id="posts" type="text/html">
|
47
|
+
{{#posts}}
|
48
|
+
<li class="post-short {{nsfw}}">
|
49
|
+
<h3><a href="javascript:;" onclick="$.ui.loadContent('test-show-post',false,false,'slide')">{{title}}</a></h3>
|
50
|
+
<p class="post">
|
51
|
+
<span class="score">{{score}}</span> - <span class="num-comments">{{numComments}}</span> comments, to <span class="subreddit">{{subreddit}}</span>
|
52
|
+
</p>
|
53
|
+
</li>
|
54
|
+
{{/posts}}
|
55
|
+
</div>
|
56
|
+
</script>
|
57
|
+
|
58
|
+
<script id="error_inline" type="text/html">
|
59
|
+
<p class="error-message">{{error}}</p>
|
60
|
+
</script>
|
61
|
+
|
62
|
+
</head>
|
63
|
+
<body>
|
64
|
+
<div id="header">
|
65
|
+
<div class="title"><h2>Loading...</h2></div>
|
66
|
+
<div class="search-bar">
|
67
|
+
<form name="search" action="#search" method="get"><input type='text' name="search-text" value="Search"/></form>
|
68
|
+
</div>
|
69
|
+
<div class="search-button"><p>S</p></div>
|
70
|
+
</div>
|
71
|
+
|
72
|
+
<div id="navbar">
|
73
|
+
<div id="subreddit-wrapper">
|
74
|
+
<ul class="subreddits"></ul>
|
75
|
+
</div>
|
76
|
+
</div>
|
77
|
+
|
78
|
+
<div id="content">
|
79
|
+
<div id="subreddit-posts" class="panel" selected="true">
|
80
|
+
<div id="posts-wrapper">
|
81
|
+
<ul class="posts"></ul>
|
82
|
+
</div>
|
83
|
+
</div>
|
84
|
+
<div id="test-subreddit-posts" class="panel">
|
85
|
+
<p>Test showing moving to a different subreddit page</p>
|
86
|
+
</div>
|
87
|
+
<div id="test-show-post" class="panel">
|
88
|
+
<p>Test showing moving to view a post's content</p>
|
89
|
+
</div>
|
90
|
+
</div>
|
91
|
+
</body>
|
92
|
+
</html>
|
@@ -0,0 +1,136 @@
|
|
1
|
+
html, body {
|
2
|
+
width: 100%;
|
3
|
+
height: 100%;
|
4
|
+
}
|
5
|
+
|
6
|
+
html, body, div, h1, h2, h3, p, ul, li {
|
7
|
+
margin: 0;
|
8
|
+
padding: 0;
|
9
|
+
}
|
10
|
+
|
11
|
+
ul {
|
12
|
+
list-style-type: none;
|
13
|
+
}
|
14
|
+
|
15
|
+
h3 {font-size: 100%;}
|
16
|
+
|
17
|
+
$lightBlue: #3bbfce;
|
18
|
+
$warning: #f00;
|
19
|
+
|
20
|
+
* {
|
21
|
+
-webkit-user-select:none;
|
22
|
+
-webkit-box-sizing:border-box;
|
23
|
+
box-sizing:border-box;
|
24
|
+
}
|
25
|
+
|
26
|
+
body {
|
27
|
+
width: 100%;
|
28
|
+
height: 100%;
|
29
|
+
display: -webkit-box;
|
30
|
+
-webkit-box-orient: vertical;
|
31
|
+
}
|
32
|
+
|
33
|
+
.panel {
|
34
|
+
width: 100%;
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
/*********************
|
39
|
+
header bar
|
40
|
+
*********************/
|
41
|
+
#header {
|
42
|
+
display: -webkit-box;
|
43
|
+
height: 30px;
|
44
|
+
width: 100%;
|
45
|
+
|
46
|
+
color: $lightBlue;
|
47
|
+
background-image:-webkit-gradient(linear, left top, left bottom, from(rgba(16,25,33,1)), to(rgba(14,23,32,1)), color-stop(.5, rgba(27,36,46,1)), color-stop(.5, rgba(14,23,32,1)));
|
48
|
+
-webkit-box-shadow:0px 0px 24px rgba(0,0,0,0.8); box-shadow:0px 0px 24px rgba(0,0,0,0.8);
|
49
|
+
|
50
|
+
-webkit-box-orient: horizontal;
|
51
|
+
-webkit-box-align: center;
|
52
|
+
-webkit-box-pack: justify;
|
53
|
+
}
|
54
|
+
#header .title {
|
55
|
+
-webkit-box-flex: 1;
|
56
|
+
text-align: center;
|
57
|
+
}
|
58
|
+
#header .search-bar {
|
59
|
+
display: none;
|
60
|
+
}
|
61
|
+
#header .serach-bar.shown {
|
62
|
+
display: -webkit-box;
|
63
|
+
-webkit-box-flex: 1;
|
64
|
+
width: 100%;
|
65
|
+
}
|
66
|
+
#header .search-button {
|
67
|
+
padding: 5px;
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
/*********************
|
72
|
+
Nav Bar
|
73
|
+
*********************/
|
74
|
+
#navbar {
|
75
|
+
width: 100%;
|
76
|
+
display:-webkit-box;
|
77
|
+
-webkit-box-orient: horizontal;
|
78
|
+
-webkit-box-align: center;
|
79
|
+
overflow: hidden;
|
80
|
+
|
81
|
+
z-index:1000;
|
82
|
+
position:relative;
|
83
|
+
}
|
84
|
+
#subreddit-wrapper {
|
85
|
+
height: 40px;
|
86
|
+
display: -webkit-box;
|
87
|
+
}
|
88
|
+
#subreddit-wrapper ul.subreddits {
|
89
|
+
display: -webkit-box;
|
90
|
+
-webkit-box-orient: horizontal;
|
91
|
+
-webkit-box-align: center;
|
92
|
+
padding-left: 0;
|
93
|
+
white-space: nowrap;
|
94
|
+
}
|
95
|
+
#subreddit-wrapper .subreddits li {
|
96
|
+
display:inline;
|
97
|
+
a {
|
98
|
+
margin-right: 5px;
|
99
|
+
padding: 0 5px;
|
100
|
+
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
|
105
|
+
/***************************
|
106
|
+
App Content for main page
|
107
|
+
***************************/
|
108
|
+
#content{
|
109
|
+
z-index:180;
|
110
|
+
display:block;
|
111
|
+
position:relative;
|
112
|
+
} /* Accounts for positioning of the content area, which is everything below the header and above the navbar. */
|
113
|
+
|
114
|
+
.panel {
|
115
|
+
z-index:180;
|
116
|
+
width:100%;
|
117
|
+
height:100%;
|
118
|
+
display:none;
|
119
|
+
position:absolute; top:0px; left:-100%;
|
120
|
+
overflow:hidden;
|
121
|
+
}
|
122
|
+
|
123
|
+
#subreddit-posts {
|
124
|
+
display: -webkit-box;
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
/***************************
|
129
|
+
Formatting for Short posts
|
130
|
+
***************************/
|
131
|
+
.posts .post-short {
|
132
|
+
display: bock;
|
133
|
+
}
|
134
|
+
.posts .post-short.nsfw {
|
135
|
+
background-color: $warning;
|
136
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
{{define "base.header"}}
|
2
|
+
<!DOCTYPE html>
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>{{.Title}}</title>
|
6
|
+
{{if .Debug}}{{template "base.header.assets.debug" .}}{{else}}{{template "base.header.assets" .}}{{end}}
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
{{end}}
|
10
|
+
|
11
|
+
{{define "base.header.assets"}}
|
12
|
+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
|
13
|
+
<script type="text/javascript" src="{{.RootURL}}/assets/js/application.js"></script>
|
14
|
+
<link rel="stylesheet" type="text/css" href="{{.RootURL}}/assets/css/application.css">
|
15
|
+
{{end}}
|
16
|
+
|
17
|
+
{{define "base.header.assets.debug"}}
|
18
|
+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
|
19
|
+
<script type="text/javascript" src="{{.RootURL}}/assets/js/libs/mod_loader.js"></script>
|
20
|
+
<script type="text/javascript" src="{{.RootURL}}/assets/js/libs/deferred.js"></script>
|
21
|
+
<script type="text/javascript" src="{{.RootURL}}/assets/js/libs/logger.js"></script>
|
22
|
+
<script type="text/javascript" src="{{.RootURL}}/assets/js/helpers/properties.js"></script>
|
23
|
+
<script type="text/javascript" src="{{.RootURL}}/assets/js/main.js"></script>
|
24
|
+
<link rel="stylesheet" type="text/css" href="{{.RootURL}}/assets/css/application.css">
|
25
|
+
{{end}}
|
26
|
+
|
27
|
+
|
28
|
+
{{define "base.footer"}}
|
29
|
+
</body>
|
30
|
+
</html>
|
31
|
+
{{end}}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{{define "home.contents"}}
|
2
|
+
<h3>Go Kart</h3>
|
3
|
+
<p>Combination of tooks which will make developing webapps using go easier. The gokart gem by default combines SASS, Coffee Script, Rake, and Sprokets with Go to provide a great development environment. This environment supports test driven development (TDD) with ruby guard and jasmine.</p>
|
4
|
+
<p>There are no external dependancies other than Go and ruby (which I expect you already have...). All dependancies are installed via bundler after the project directory is created.</p>
|
5
|
+
<br />
|
6
|
+
<h4>Environment Structure</h4>
|
7
|
+
<p>The environment is split into the following sections:</p>
|
8
|
+
<ul>
|
9
|
+
<li><strong>bin/</strong> - This is where the application will run from once built, and where all the assets will be compiled to.</li>
|
10
|
+
<li><strong>bin/server/</strong> - Compiled Go http server.</li>
|
11
|
+
<li><strong>bin/assets/templates/</strong> - Compiled Go HTML templates</li>
|
12
|
+
<li><strong>bin/assets/www-min/</strong> - Compiled and minified CSS/JS/images using sprockets</li>
|
13
|
+
<li><strong>bin/assets/www-debug/</strong> - Compiled, but non-minified/concatonated CSS/JS source, images are here also</li>
|
14
|
+
<li><strong>lib/</strong> - Where any Go libraries your app depends on will be installed by running 'go get'. Note: You'll need to set the project into your GOPATH, I haven't figured out a good solution for this yet.</li>
|
15
|
+
<li><strong>spec/javascripts/</strong> - Where all of the compiled JS specs will be written to, and run from. Note: Currently these do not go through sprockets, but only the coffee-script compiler. So no preprocessing is available</li>
|
16
|
+
<li><strong>spec/javascripts/support</strong> - Configuration files for Jasmine. jasmin.yml contains the script specifiing the source files to load, and what order to load them in.</li>
|
17
|
+
<li><strong>src/server/</strong> - All of your Go code will go here following the normal Go 1.0 directory pattern</li>
|
18
|
+
<li><strong>src/www/app/</strong> - All of you Coffee script, sass, and Go Template are found here</li>
|
19
|
+
<li><strong>src/www/spec/</strong> - All coffee script spec files which will be compiled into js and run using jasmine.</li>
|
20
|
+
<li><strong>src/www/vendor/</strong> - js/css/image files for third party tools and libraries</li>
|
21
|
+
<li><strong>tasks/</strong> - Rake tasks to build, run, and test the application. There are sevearl tasks which you can run do 'rake --tasks' to see a complete list of them. 'rake app:test' to run test units, 'rake app:start' to build and run, use startdebug for a debug build. Note: when you do 'rake jasmine' or rake 'app:guard' you probably want to start these tasks in different tabs because they run until killed.</li>
|
22
|
+
</ul>
|
23
|
+
|
24
|
+
{{end}}
|
25
|
+
|
26
|
+
{{define "home"}}
|
27
|
+
{{template "base.header" .Common}}
|
28
|
+
{{template "home.contents" .Contents}}
|
29
|
+
{{template "base.footer"}}
|
30
|
+
{{end}}
|
@@ -0,0 +1,202 @@
|
|
1
|
+
describe 'Deferred Test', ->
|
2
|
+
Deferred = modLoader.require 'libs/deferred'
|
3
|
+
|
4
|
+
it 'should be able to create a deferred object, and get a promise from it', ->
|
5
|
+
df = Deferred.create()
|
6
|
+
expect(df).toBeDefined()
|
7
|
+
|
8
|
+
promise = df.promise()
|
9
|
+
expect(promise).toBeDefined()
|
10
|
+
|
11
|
+
it 'should be able to create a deferred which will resolve a promise, synchournously', ->
|
12
|
+
df = Deferred.create()
|
13
|
+
promise = df.promise()
|
14
|
+
|
15
|
+
wasFulfilled = false
|
16
|
+
promise.done ->
|
17
|
+
wasFulfilled = true
|
18
|
+
|
19
|
+
df.resolve()
|
20
|
+
|
21
|
+
waitsFor ->
|
22
|
+
return wasFulfilled
|
23
|
+
, 'promise to be fulfilled', 100
|
24
|
+
|
25
|
+
runs ->
|
26
|
+
expect(wasFulfilled).toBe(true)
|
27
|
+
|
28
|
+
it 'should be able to create a deferred which will reject a promise, synchournously', ->
|
29
|
+
df = Deferred.create()
|
30
|
+
promise = df.promise()
|
31
|
+
|
32
|
+
wasRejected = false
|
33
|
+
promise.fail ->
|
34
|
+
wasRejected = true
|
35
|
+
|
36
|
+
df.reject()
|
37
|
+
|
38
|
+
waitsFor ->
|
39
|
+
return wasRejected
|
40
|
+
, 'promise to be rejected', 100
|
41
|
+
|
42
|
+
runs ->
|
43
|
+
expect(wasRejected).toBe(true)
|
44
|
+
|
45
|
+
it 'should be able to resolve a promise before the promise is created, synchournously', ->
|
46
|
+
df = Deferred.create()
|
47
|
+
promise = df.promise()
|
48
|
+
|
49
|
+
df.resolve()
|
50
|
+
|
51
|
+
wasFulfilled = false
|
52
|
+
promise.done ->
|
53
|
+
wasFulfilled = true
|
54
|
+
|
55
|
+
waitsFor ->
|
56
|
+
return wasFulfilled
|
57
|
+
, 'promise to be fulfilled', 100
|
58
|
+
|
59
|
+
runs ->
|
60
|
+
expect(wasFulfilled).toBe(true)
|
61
|
+
|
62
|
+
it 'should be able to reject a promise before the promise is created, synchournously', ->
|
63
|
+
df = Deferred.create()
|
64
|
+
promise = df.promise()
|
65
|
+
|
66
|
+
df.reject()
|
67
|
+
|
68
|
+
wasRejected = false
|
69
|
+
promise.fail ->
|
70
|
+
wasRejected = true
|
71
|
+
|
72
|
+
waitsFor ->
|
73
|
+
return wasRejected
|
74
|
+
, 'promise to be rejected', 100
|
75
|
+
|
76
|
+
runs ->
|
77
|
+
expect(wasRejected).toBe(true)
|
78
|
+
|
79
|
+
it 'should be able to resolve a promise with data', ->
|
80
|
+
df = Deferred.create()
|
81
|
+
promise = df.promise()
|
82
|
+
|
83
|
+
df.resolve({myObj: true})
|
84
|
+
|
85
|
+
wasFulfilled = false
|
86
|
+
promise.done (obj)->
|
87
|
+
expect(obj.myObj).toBe(true)
|
88
|
+
wasFulfilled = true
|
89
|
+
|
90
|
+
|
91
|
+
waitsFor ->
|
92
|
+
return wasFulfilled
|
93
|
+
, 'promise to be fulfilled', 100
|
94
|
+
|
95
|
+
runs ->
|
96
|
+
expect(wasFulfilled).toBe(true)
|
97
|
+
|
98
|
+
it 'should be able to reject a promise with data', ->
|
99
|
+
df = Deferred.create()
|
100
|
+
promise = df.promise()
|
101
|
+
|
102
|
+
df.reject({myObj: true})
|
103
|
+
|
104
|
+
wasRejected = false
|
105
|
+
promise.fail (obj)->
|
106
|
+
expect(obj.myObj).toBe(true)
|
107
|
+
wasRejected = true
|
108
|
+
|
109
|
+
|
110
|
+
waitsFor ->
|
111
|
+
return wasRejected
|
112
|
+
, 'promise to be reject', 100
|
113
|
+
|
114
|
+
runs ->
|
115
|
+
expect(wasRejected).toBe(true)
|
116
|
+
|
117
|
+
it 'should be able to resolve a promise with multile datas', ->
|
118
|
+
df = Deferred.create()
|
119
|
+
promise = df.promise()
|
120
|
+
|
121
|
+
df.resolve({myObj: true}, {myObj2: true}, {myObj3: true})
|
122
|
+
|
123
|
+
wasFulfilled = false
|
124
|
+
promise.done (obj, obj2, obj3)->
|
125
|
+
expect(obj.myObj).toBe(true)
|
126
|
+
expect(obj2.myObj2).toBe(true)
|
127
|
+
expect(obj3.myObj3).toBe(true)
|
128
|
+
wasFulfilled = true
|
129
|
+
|
130
|
+
|
131
|
+
waitsFor ->
|
132
|
+
return wasFulfilled
|
133
|
+
, 'promise to be fulfilled', 100
|
134
|
+
|
135
|
+
runs ->
|
136
|
+
expect(wasFulfilled).toBe(true)
|
137
|
+
|
138
|
+
it 'should be able to reject a promise with multile datas', ->
|
139
|
+
df = Deferred.create()
|
140
|
+
promise = df.promise()
|
141
|
+
|
142
|
+
df.reject({myObj: true}, {myObj2: true}, {myObj3: true})
|
143
|
+
|
144
|
+
wasRejected = false
|
145
|
+
promise.fail (obj, obj2, obj3)->
|
146
|
+
expect(obj.myObj).toBe(true)
|
147
|
+
expect(obj2.myObj2).toBe(true)
|
148
|
+
expect(obj3.myObj3).toBe(true)
|
149
|
+
wasRejected = true
|
150
|
+
|
151
|
+
|
152
|
+
waitsFor ->
|
153
|
+
return wasRejected
|
154
|
+
, 'promise to be rejected', 100
|
155
|
+
|
156
|
+
runs ->
|
157
|
+
expect(wasRejected).toBe(true)
|
158
|
+
|
159
|
+
|
160
|
+
it 'should be able to resolve a promise with data, using the then', ->
|
161
|
+
df = Deferred.create()
|
162
|
+
promise = df.promise()
|
163
|
+
|
164
|
+
df.resolve({myObj: true})
|
165
|
+
|
166
|
+
wasFulfilled = false
|
167
|
+
promise.then (obj)->
|
168
|
+
expect(obj.myObj).toBe(true)
|
169
|
+
wasFulfilled = true
|
170
|
+
, (obj)->
|
171
|
+
expect('not to be called').toBe(true)
|
172
|
+
wasFulfilled = false
|
173
|
+
|
174
|
+
waitsFor ->
|
175
|
+
return wasFulfilled
|
176
|
+
, 'promise to be fulfilled', 100
|
177
|
+
|
178
|
+
runs ->
|
179
|
+
expect(wasFulfilled).toBe(true)
|
180
|
+
|
181
|
+
|
182
|
+
it 'should be able to reject a promise with data, using the then', ->
|
183
|
+
df = Deferred.create()
|
184
|
+
promise = df.promise()
|
185
|
+
|
186
|
+
df.reject({myObj: true})
|
187
|
+
|
188
|
+
wasRejected = false
|
189
|
+
promise.then (obj)->
|
190
|
+
expect('not to be called').toBe(true)
|
191
|
+
wasRejected = false
|
192
|
+
, (obj)->
|
193
|
+
expect(obj.myObj).toBe(true)
|
194
|
+
wasRejected = true
|
195
|
+
|
196
|
+
waitsFor ->
|
197
|
+
return wasRejected
|
198
|
+
, 'promise to be rejected', 100
|
199
|
+
|
200
|
+
runs ->
|
201
|
+
expect(wasRejected).toBe(true)
|
202
|
+
|
@@ -0,0 +1,137 @@
|
|
1
|
+
|
2
|
+
modLoader.define 'mocks', (require, exports)->
|
3
|
+
|
4
|
+
exports.ajax = jasmine.createSpy('AJAX Stub').andCallFake () ->
|
5
|
+
return
|
6
|
+
|
7
|
+
exports.model_subreddit = {
|
8
|
+
id:'fake id',
|
9
|
+
title:'fake title',
|
10
|
+
name:'fake name'
|
11
|
+
url: '/r/programming/'
|
12
|
+
}
|
13
|
+
|
14
|
+
exports.rsp_reddits = {
|
15
|
+
"kind":"Listing",
|
16
|
+
"data":{
|
17
|
+
"modhash":"yqpsudqtcv91b6a8e81dcce79d45fcaf82bfc6b147f7fab330",
|
18
|
+
"children":[
|
19
|
+
{
|
20
|
+
"kind":"t5",
|
21
|
+
"data":{
|
22
|
+
"display_name":"pics",
|
23
|
+
"name":"t5_2qh0u",
|
24
|
+
"title":"Pictures and Images",
|
25
|
+
"url":"/r/pics/",
|
26
|
+
"created":1201221069.0,
|
27
|
+
"created_utc":1201221069.0,
|
28
|
+
"over18":false,
|
29
|
+
"subscribers":1098672,
|
30
|
+
"id":"2qh0u",
|
31
|
+
"description":"A place to share interesting photographs and pictures. Feel free to post your own, but please **read the rules first** (see below), and note that we are *not a catch-all* for general images (of text, comics, etc.)\n\n\n#Announcement#\n*Oct 13th, 2011* - **We have a [new ruleset](http://www.reddit.com/r/pics/comments/lb24q/rpics_ruleset/)**, please read it carefully before submitting anything. \n\n#Rules#\n\n1. **No pictures of text.** *This includes images with superimposed text, such as [image macros](http://en.wikipedia.org/wiki/Image_macro) and comics, as well as screenshots, and (non-historical) handwritten text.*\n\n1. **No gore, porn or anything NSFW.** *This subreddit is strictly SFW, and there are better places for such content.*\n\n1. **No personal information.** *This includes anything hosted on Facebook's servers, as they can be traced to the original account holder. Stalking & harassment will not be tolerated.*\n\n1. **No solicitation of votes or DAE posts.** \n\n1. **No non-author URLs in images.** *We only tolerate URLs in images if they serve to give credit to the original author.*\n\n**Please also read the full version of these rules [here](http://www.reddit.com/r/pics/comments/lb24q/rpics_ruleset/).**\n\n\nIf your submission appears to be banned but meets the above rules, [please send us a message](/message/compose?to=%23pics). Don't delete it as that makes the filter hate you! \n\n\nIf you come across any rule violations, please report the submission or [message the mods](http://www.reddit.com/message/compose?to=%23pics) and one of us will remove it!\n\n#Related subreddits#\n\n* **[misc](/r/misc/)**\n* **[gifs](/r/gifs/)**\n* **[f7u12](/r/fffffffuuuuuuuuuuuu/)**\n* **[Vertical](/r/Vertical)**\n* **[Demotivational](/r/Demotivational)**\n* **[Advice Animals](/r/AdviceAnimals)**\n* **[The SFWPorn Network](http://reddit.com/r/earthporn+villageporn+cityporn+spaceporn+waterporn+abandonedporn+animalporn+humanporn+botanicalporn+adrenalineporn+destructionporn+movieposterporn+albumartporn+machineporn+newsporn+geekporn+bookporn+mapporn+adporn+designporn+roomporn+militaryporn+historyporn+quotesporn+skyporn+fireporn+infrastructureporn)**\n* [Rage Novels](/r/ragenovels/)\n* [Rage Ops](/r/rageops)\n* [Advice Atheists](/r/AdviceAtheists)\n* [a6theism10](/r/aaaaaatheismmmmmmmmmm)\n* [Trolling Animals](/r/TrollingAnimals)\n* [/r/AnythingGoesPics](/r/AnythingGoesPics)\n* [/r/OriginalHub](/r/OriginalHub)\n* [/r/screenshots](/r/screenshots)\n* [/r/tradingfaces](/r/tradingfaces)\n* [/r/nostalgia](/r/nostalgia)\n* [/r/facepalm](/r/facepalm)\n* [/r/gamingpics](/r/gamingpics)\n* [/r/aww](/r/aww)\n* [/r/eCards](/r/eCards)\n* [/r/comics](/r/comics)\n* [/r/webcomics](/r/webcomics)\n* [/r/photography](/r/photography)\n* [/r/PictureChallenge](/r/PictureChallenge)\n* [/r/photocritique](/r/photocritique)\n* [/r/windowshots](/r/windowshots)\n* [/r/wallpaper](/r/wallpaper)\n* [/r/wallpapers](/r/wallpapers)\n* [/r/1000words](/r/1000words)\n* [/r/newreddits](/r/newreddits)\n\nAlso check out http://irc.reddit.com\n\n### [***20/10/11 New Ruleset***: Please report violations using the 'report' button.](http://www.reddit.com/r/pics/comments/lb24q/rpics_ruleset/)###"
|
32
|
+
}
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"kind":"t5",
|
36
|
+
"data":{
|
37
|
+
"display_name":"funny",
|
38
|
+
"name":"t5_2qh33",
|
39
|
+
"title":"funny",
|
40
|
+
"url":"/r/funny/",
|
41
|
+
"created":1201242956.0,
|
42
|
+
"created_utc":1201242956.0,
|
43
|
+
"over18":false,
|
44
|
+
"subscribers":1111900,
|
45
|
+
"id":"2qh33",
|
46
|
+
"description":"***New Rule***: No posts with their sole purpose being to communicate with another redditor. [Example.](http://www.reddit.com/r/funny/comments/lq3uv/a_student_in_a_course_i_teach_is_constantly/) Sorry, you're going to have to use a different form of communication.\n\n---\n\n1. [**New r/Funny Rule**, click here to see.](http://www.reddit.com/r/funny/comments/lqgx7/new_rule_use_your_phone_or_something/)\n\n**Welcome to r/Funny:**\n\nYou may only post if you are funny. \n\nNo rage comics. Go to [/F7U12](http://www.reddit.com/r/fffffffuuuuuuuuuuuu) instead.\n\n**No Memes!** Go to [/AdviceAnimals](/r/adviceanimals) instead.\n\nRehosted webcomics will be removed. Please submit a link to the original comic's site and preferably an imgur link in the comments. [(*)](http://www.reddit.com/r/funny/comments/kqwwx/we_need_to_talk_about_rehosting_wecomics/)\n\nBefore you submit a screenshot of a reddit thread *here*, you might want to check out [r/BestOf](http://www.reddit.com/r/bestof). \n\nNeed more? Check out:\n\n* [humor](http://www.reddit.com/r/humor) for more in-depth stuff\n* [jokes](/r/jokes)\n* [comics](/r/comics)\n* [punny](/r/punny)\n* [Very Punny](/r/verypunny)\n* [lolcats](/r/lolcats)\n* [lol](/r/lol)\n* [TrollingAnimals](/r/TrollingAnimals)\n* [Rage Novels](/r/ragenovels/)\n* [Demotivational](http://www.reddit.com/r/Demotivational)\n* **[misc](/r/misc/)** for anything else\n\nStill need more? See Reddit's [best / worst](http://www.reddit.com/r/AskReddit/comments/8ft5j/tell_me_your_best_worst_joke_reddit/?sort=top) and [offensive](http://www.reddit.com/r/funny/comments/7rxyh/collection_of_totally_offensive_jokes_not_for_the/?sort=top) joke collections (warning: some of those jokes are offensive / nsfw!). \n\n\n------\n\nPlease DO NOT post [personal information](http://www.reddit.com/help/faq#Ispostingpersonalinformationok). This includes anything hosted on Facebook's servers, as they can be traced to the original account holder.\n\n----\n\nIf your submission appears to be banned, please don't just delete it as that makes the filter hate you! Instead please [send us a message](/message/compose?to=%23funny). We'll unban it and it should get better. please allow 10 minutes for the post to appear before messaging moderators\n\n----\n\nCSS - BritishEnglishPolice \u00a92011"
|
47
|
+
}
|
48
|
+
}
|
49
|
+
],
|
50
|
+
"after":"t5_2qq5c",
|
51
|
+
"before":null
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
exports.rsp_posts = {
|
56
|
+
"kind":"Listing",
|
57
|
+
"data":{
|
58
|
+
"modhash":"s7069nuzol41d61f1b1ff780c40b025a4848c4b06c6ebaa061",
|
59
|
+
"children":[
|
60
|
+
{
|
61
|
+
"kind":"t3",
|
62
|
+
"data":{
|
63
|
+
"domain":"perlbuzz.com",
|
64
|
+
"media_embed":{
|
65
|
+
|
66
|
+
},
|
67
|
+
"levenshtein":null,
|
68
|
+
"subreddit":"programming",
|
69
|
+
"selftext_html":null,
|
70
|
+
"selftext":"",
|
71
|
+
"likes":null,
|
72
|
+
"saved":false,
|
73
|
+
"id":"ms13h",
|
74
|
+
"clicked":false,
|
75
|
+
"title":"Finding a lost dog's owner with Perl",
|
76
|
+
"media":null,
|
77
|
+
"score":426,
|
78
|
+
"over_18":false,
|
79
|
+
"hidden":false,
|
80
|
+
"thumbnail":"",
|
81
|
+
"subreddit_id":"t5_2fwo",
|
82
|
+
"author_flair_css_class":null,
|
83
|
+
"downs":222,
|
84
|
+
"is_self":false,
|
85
|
+
"permalink":"/r/programming/comments/ms13h/finding_a_lost_dogs_owner_with_perl/",
|
86
|
+
"name":"t3_ms13h",
|
87
|
+
"created":1322517472.0,
|
88
|
+
"url":"http://perlbuzz.com/2011/11/finding-a-lost-dogs-owner-with-perl-and-wwwmechanize.html",
|
89
|
+
"author_flair_text":null,
|
90
|
+
"author":"mpeters",
|
91
|
+
"created_utc":1322492272.0,
|
92
|
+
"num_comments":61,
|
93
|
+
"ups":648
|
94
|
+
}
|
95
|
+
},
|
96
|
+
{
|
97
|
+
"kind":"t3",
|
98
|
+
"data":{
|
99
|
+
"domain":"elegantcoding.com",
|
100
|
+
"media_embed":{
|
101
|
+
|
102
|
+
},
|
103
|
+
"levenshtein":null,
|
104
|
+
"subreddit":"programming",
|
105
|
+
"selftext_html":null,
|
106
|
+
"selftext":"",
|
107
|
+
"likes":null,
|
108
|
+
"saved":false,
|
109
|
+
"id":"msl7x",
|
110
|
+
"clicked":false,
|
111
|
+
"title":"Eleven equations every Computer Science geeks should know",
|
112
|
+
"media":null,
|
113
|
+
"score":76,
|
114
|
+
"over_18":false,
|
115
|
+
"hidden":false,
|
116
|
+
"thumbnail":"",
|
117
|
+
"subreddit_id":"t5_2fwo",
|
118
|
+
"author_flair_css_class":null,
|
119
|
+
"downs":41,
|
120
|
+
"is_self":false,
|
121
|
+
"permalink":"/r/programming/comments/msl7x/eleven_equations_every_computer_science_geeks/",
|
122
|
+
"name":"t3_msl7x",
|
123
|
+
"created":1322547476.0,
|
124
|
+
"url":"http://www.elegantcoding.com/2011/11/eleven-equations-true-computer-science.html",
|
125
|
+
"author_flair_text":null,
|
126
|
+
"author":"chandershivdasani",
|
127
|
+
"created_utc":1322522276.0,
|
128
|
+
"num_comments":34,
|
129
|
+
"ups":117
|
130
|
+
}
|
131
|
+
}
|
132
|
+
],
|
133
|
+
"after":"t3_mqs0s",
|
134
|
+
"before":null
|
135
|
+
}
|
136
|
+
}
|
137
|
+
return
|