smoke 0.0.3 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/LICENSE +20 -0
  2. data/README.markdown +101 -0
  3. data/Rakefile +53 -4
  4. data/VERSION.yml +4 -0
  5. data/examples/web_search_joined.rb +25 -0
  6. data/examples/yql_web_search.rb +11 -0
  7. data/lib/core_ext/hash.rb +20 -0
  8. data/lib/core_ext/string.rb +6 -0
  9. data/lib/smoke.rb +103 -3
  10. data/lib/smoke/cache.rb +56 -0
  11. data/lib/smoke/origin.rb +251 -0
  12. data/lib/smoke/request.rb +57 -0
  13. data/lib/smoke/source/data.rb +39 -0
  14. data/lib/smoke/source/feed.rb +24 -0
  15. data/lib/smoke/source/join.rb +33 -0
  16. data/lib/smoke/source/yql.rb +85 -0
  17. data/rdoc/classes/Smoke.html +260 -0
  18. data/rdoc/classes/Smoke/Origin.html +340 -0
  19. data/rdoc/classes/Smoke/Source/Data.html +126 -0
  20. data/rdoc/classes/Smoke/Source/Feed.html +117 -0
  21. data/rdoc/classes/Smoke/Source/YQL.html +223 -0
  22. data/rdoc/created.rid +1 -0
  23. data/rdoc/files/README_markdown.html +180 -0
  24. data/rdoc/files/lib/core_ext/hash_rb.html +49 -0
  25. data/rdoc/files/lib/smoke/origin_rb.html +49 -0
  26. data/rdoc/files/lib/smoke/request_rb.html +49 -0
  27. data/rdoc/files/lib/smoke/source/data_rb.html +49 -0
  28. data/rdoc/files/lib/smoke/source/feed_rb.html +49 -0
  29. data/rdoc/files/lib/smoke/source/join_rb.html +49 -0
  30. data/rdoc/files/lib/smoke/source/yql_rb.html +49 -0
  31. data/rdoc/files/lib/smoke_rb.html +65 -0
  32. data/rdoc/fr_class_index.html +21 -0
  33. data/rdoc/fr_file_index.html +28 -0
  34. data/rdoc/fr_method_index.html +4459 -0
  35. data/rdoc/index.html +15 -0
  36. data/rdoc/rdoc-style.css +319 -0
  37. data/spec/core_ext/hash_spec.rb +25 -0
  38. data/spec/smoke/cache_spec.rb +75 -0
  39. data/spec/smoke/origin_spec.rb +220 -0
  40. data/spec/smoke/request_spec.rb +49 -0
  41. data/spec/smoke/shared_spec.rb +182 -0
  42. data/spec/smoke/source/data_spec.rb +65 -0
  43. data/spec/smoke/source/feed_spec.rb +49 -0
  44. data/spec/smoke/source/join_spec.rb +53 -0
  45. data/spec/smoke/source/yql_spec.rb +111 -0
  46. data/spec/smoke_spec.rb +51 -0
  47. data/spec/spec.opts +1 -0
  48. data/spec/spec_helper.rb +17 -0
  49. data/spec/supports/amc_pacer.json.yql +10 -0
  50. data/spec/supports/datatables.yql +12 -0
  51. data/spec/supports/flickr-photo.json +7 -0
  52. data/spec/supports/gzip_response.txt +0 -0
  53. data/spec/supports/search-web.json.yql +12 -0
  54. data/spec/supports/search-web.xml.yql +83 -0
  55. data/spec/supports/slashdot.xml +98 -0
  56. data/spec/supports/test_source.rb +10 -0
  57. metadata +144 -67
  58. data/History.txt +0 -13
  59. data/License.txt +0 -21
  60. data/Manifest.txt +0 -44
  61. data/README.txt +0 -3
  62. data/bin/smoke +0 -41
  63. data/bin/smoked +0 -43
  64. data/config/hoe.rb +0 -70
  65. data/config/requirements.rb +0 -17
  66. data/contrib/processors/smoke/remote_port_status_check_processor.rb +0 -10
  67. data/contrib/processors/smoke/system_load_processor.rb +0 -52
  68. data/contrib/signals/smoke/remote_port_status_check.rb +0 -39
  69. data/contrib/signals/smoke/system_load.rb +0 -23
  70. data/lib/smoke/client.rb +0 -50
  71. data/lib/smoke/client/connection.rb +0 -44
  72. data/lib/smoke/client/signal_runner.rb +0 -40
  73. data/lib/smoke/client/version.rb +0 -11
  74. data/lib/smoke/server.rb +0 -18
  75. data/lib/smoke/server/signal_handler.rb +0 -64
  76. data/lib/smoke/server/signal_router.rb +0 -38
  77. data/lib/smoke/server/version.rb +0 -11
  78. data/lib/smoke/signal.rb +0 -19
  79. data/lib/smoke/signal_processor.rb +0 -29
  80. data/lib/smoke/version.rb +0 -9
  81. data/log/debug.log +0 -0
  82. data/log/development.log +0 -0
  83. data/log/production.log +0 -0
  84. data/log/server.log +0 -0
  85. data/log/test.log +0 -0
  86. data/script/destroy +0 -14
  87. data/script/generate +0 -14
  88. data/script/txt2html +0 -74
  89. data/setup.rb +0 -1585
  90. data/tasks/deployment.rake +0 -35
  91. data/tasks/environment.rake +0 -7
  92. data/tasks/website.rake +0 -17
  93. data/test/test_helper.rb +0 -2
  94. data/test/test_server.rb +0 -11
  95. data/website/index.html +0 -87
  96. data/website/index.txt +0 -29
  97. data/website/javascripts/rounded_corners_lite.inc.js +0 -285
  98. data/website/stylesheets/screen.css +0 -138
  99. data/website/template.rhtml +0 -48
data/rdoc/index.html ADDED
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
2
+ <html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
3
+ <head>
4
+ <title>smoke</title>
5
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
6
+ </head>
7
+ <frameset border='1' bordercolor='gray' cols='20%, *' frameborder='1'>
8
+ <frameset rows='15%, 35%, 50%'>
9
+ <frame name='Files' src='fr_file_index.html' title='Files'></frame>
10
+ <frame name='Classes' src='fr_class_index.html'></frame>
11
+ <frame name='Methods' src='fr_method_index.html'></frame>
12
+ </frameset>
13
+ <frame name='docwin' src='files/README_markdown.html'></frame>
14
+ </frameset>
15
+ </html>
@@ -0,0 +1,319 @@
1
+ html, body {
2
+ height: 100%; }
3
+
4
+ body {
5
+ font-family: Lucida Grande , Verdana, Arial, Helvetica, sans-serif;
6
+ font-size: 90%;
7
+ margin: 0;
8
+ padding: 0;
9
+ background: white;
10
+ color: black; }
11
+
12
+ #wrapper {
13
+ min-height: 100%;
14
+ height: auto !important;
15
+ height: 100%;
16
+ margin: 0 auto -43px; }
17
+
18
+ #footer-push {
19
+ height: 43px; }
20
+
21
+ div.header, #footer {
22
+ background: #eee; }
23
+
24
+ #footer {
25
+ border-top: 1px solid silver;
26
+ margin-top: 12px;
27
+ padding: 0 2em;
28
+ line-height: 30px;
29
+ text-align: center;
30
+ font-variant: small-caps;
31
+ font-size: 95%; }
32
+
33
+ .clearing:after {
34
+ content: ".";
35
+ visibility: hidden;
36
+ height: 0;
37
+ display: block;
38
+ clear: both; }
39
+ * html .clearing {
40
+ height: 1px; }
41
+ .clearing *:first-child + html {
42
+ overflow: hidden; }
43
+
44
+ h1, h2, h3, h4, h5, h6 {
45
+ margin: 0;
46
+ font-weight: normal; }
47
+
48
+ a {
49
+ color: #0b3e71; }
50
+ a:hover {
51
+ background: #336699;
52
+ text-decoration: none;
53
+ color: #eef; }
54
+
55
+ #diagram img {
56
+ border: 0; }
57
+
58
+ #description a, .method .description a, .header a {
59
+ color: #336699; }
60
+ #description a:hover, .method .description a:hover, .header a:hover {
61
+ color: #eee; }
62
+ #description h1 a, #description h2 a, #description h3 a, #description h4 a, #description h5 a, #description h6 a, .method .description h1 a, .method .description h2 a, .method .description h3 a, .method .description h4 a, .method .description h5 a, .method .description h6 a, .header h1 a, .header h2 a, .header h3 a, .header h4 a, .header h5 a, .header h6 a {
63
+ color: #0b3e71; }
64
+
65
+ ol {
66
+ margin: 0;
67
+ padding: 0;
68
+ list-style: none; }
69
+ ol li {
70
+ margin-left: 0;
71
+ white-space: nowrap; }
72
+ ol li.other {
73
+ display: none; }
74
+
75
+ ol.expanded li.other {
76
+ display: list-item; }
77
+
78
+ table {
79
+ margin-bottom: 1em;
80
+ font-size: 1em;
81
+ border-collapse: collapse; }
82
+ table td, table th {
83
+ padding: .4em .8em; }
84
+ table thead {
85
+ background-color: #e8e8e8; }
86
+ table thead th {
87
+ font-variant: small-caps;
88
+ color: #666666; }
89
+ table tr {
90
+ border-bottom: 1px solid silver; }
91
+
92
+ #index a.show, div.header a.show {
93
+ text-decoration: underline;
94
+ font-style: italic;
95
+ color: #666666; }
96
+ #index a.show:after, div.header a.show:after {
97
+ content: " ..."; }
98
+ #index a.show:hover, div.header a.show:hover {
99
+ color: black;
100
+ background: #ffe; }
101
+
102
+ #index {
103
+ font: 85%/1.2 Arial, Helvetica, sans-serif; }
104
+ #index a {
105
+ text-decoration: none; }
106
+ #index h1 {
107
+ padding: .2em .5em .1em;
108
+ background: #ccc;
109
+ font: small-caps 1.2em Georgia, serif;
110
+ color: #333;
111
+ border-bottom: 1px solid gray; }
112
+ #index form {
113
+ margin: 0;
114
+ padding: 0; }
115
+ #index form input {
116
+ margin: .4em;
117
+ margin-bottom: 0;
118
+ width: 90%; }
119
+ #index form #search.untouched {
120
+ color: #777777; }
121
+ #index ol {
122
+ padding: .4em .5em; }
123
+ #index ol li {
124
+ white-space: nowrap; }
125
+ #index #index-entries li a {
126
+ padding: 1px 2px; }
127
+ #index #index-entries.classes {
128
+ font-size: 1.1em; }
129
+ #index #index-entries.classes ol {
130
+ padding: 0; }
131
+ #index #index-entries.classes span.nodoc {
132
+ display: none; }
133
+ #index #index-entries.classes span.nodoc, #index #index-entries.classes a {
134
+ font-weight: bold; }
135
+ #index #index-entries.classes .parent {
136
+ font-weight: normal; }
137
+ #index #index-entries.methods li, #index #search-results.methods li {
138
+ margin-bottom: 0.2em; }
139
+ #index #index-entries.methods li a .method_name, #index #search-results.methods li a .method_name {
140
+ margin-right: 0.25em; }
141
+ #index #index-entries.methods li a .module_name, #index #search-results.methods li a .module_name {
142
+ color: #666666; }
143
+ #index #index-entries.methods li a:hover .module_name, #index #search-results.methods li a:hover .module_name {
144
+ color: #ddd; }
145
+
146
+ div.header {
147
+ font-size: 80%;
148
+ padding: .5em 2%;
149
+ font-family: Arial, Helvetica, sans-serif;
150
+ border-bottom: 1px solid silver; }
151
+ div.header .name {
152
+ font-size: 1.6em;
153
+ font-family: Georgia, serif; }
154
+ div.header .name .type {
155
+ color: #666666;
156
+ font-size: 80%;
157
+ font-variant: small-caps; }
158
+ div.header h1.name {
159
+ font-size: 2.2em; }
160
+ div.header .paths, div.header .last-update, div.header .parent {
161
+ color: #666666; }
162
+ div.header .last-update .datetime {
163
+ color: #484848; }
164
+ div.header .parent {
165
+ margin-top: .3em; }
166
+ div.header .parent strong {
167
+ font-weight: normal;
168
+ color: #484848; }
169
+
170
+ #content {
171
+ padding: 12px 2%; }
172
+ div.class #content {
173
+ position: relative;
174
+ width: 72%; }
175
+ #content pre, #content .method .synopsis {
176
+ font: 14px Monaco, DejaVu Sans Mono , Bitstream Vera Sans Mono , Courier New , monospace; }
177
+ #content pre {
178
+ color: black;
179
+ background: #eee;
180
+ border: 1px solid silver;
181
+ padding: .5em .8em;
182
+ overflow: auto; }
183
+ #content p code, #content p tt, #content li code, #content li tt, #content dl code, #content dl tt {
184
+ font: 14px Monaco, DejaVu Sans Mono , Bitstream Vera Sans Mono , Courier New , monospace;
185
+ background: #ffffe3;
186
+ padding: 2px 3px;
187
+ line-height: 1.4; }
188
+ #content h1 code, #content h1 tt, #content h2 code, #content h2 tt, #content h3 code, #content h3 tt, #content h4 code, #content h4 tt, #content h5 code, #content h5 tt, #content h6 code, #content h6 tt {
189
+ font-size: 1.1em; }
190
+ #content #text {
191
+ position: relative; }
192
+ #content #description p {
193
+ margin-top: .5em; }
194
+ #content #description h1, #content #description h2, #content #description h3, #content #description h4, #content #description h5, #content #description h6 {
195
+ font-family: Georgia, serif; }
196
+ #content #description h1 {
197
+ font-size: 2.2em;
198
+ margin-bottom: .2em;
199
+ border-bottom: 3px double #d8d8d8;
200
+ padding-bottom: .1em; }
201
+ #content #description h2 {
202
+ font-size: 1.8em;
203
+ color: #0e3062;
204
+ margin: .8em 0 .3em 0; }
205
+ #content #description h3 {
206
+ font-size: 1.6em;
207
+ margin: .8em 0 .3em 0;
208
+ color: #666666; }
209
+ #content #description h4 {
210
+ font-size: 1.4em;
211
+ margin: .8em 0 .3em 0; }
212
+ #content #description h5 {
213
+ font-size: 1.2em;
214
+ margin: .8em 0 .3em 0;
215
+ color: #0e3062; }
216
+ #content #description h6 {
217
+ font-size: 1.0em;
218
+ margin: .8em 0 .3em 0;
219
+ color: #666666; }
220
+ #content #description ul, #content #description ol, #content .method .description ul, #content .method .description ol {
221
+ margin: .8em 0;
222
+ padding-left: 1.5em; }
223
+ #content #description ol, #content .method .description ol {
224
+ list-style: decimal; }
225
+ #content #description ol li, #content .method .description ol li {
226
+ white-space: normal; }
227
+
228
+ #method-list {
229
+ position: absolute;
230
+ top: 0px;
231
+ right: -33%;
232
+ width: 28%;
233
+ background: #eee;
234
+ border: 1px solid silver;
235
+ padding: .4em 1%;
236
+ overflow: hidden; }
237
+ #method-list h2 {
238
+ font-size: 1.3em; }
239
+ #method-list h3 {
240
+ font-variant: small-caps;
241
+ text-transform: capitalize;
242
+ font-family: Georgia, serif;
243
+ color: #666;
244
+ font-size: 1.1em; }
245
+ #method-list ol {
246
+ padding: 0 0 .5em .5em; }
247
+
248
+ #context {
249
+ border-top: 1px dashed silver;
250
+ margin-top: 1em;
251
+ margin-bottom: 1em; }
252
+
253
+ #context h2, #section h2 {
254
+ font: small-caps 1.2em Georgia, serif;
255
+ color: #444;
256
+ margin: 1em 0 .2em 0; }
257
+
258
+ #methods .method {
259
+ border: 1px solid silver;
260
+ margin-top: .5em;
261
+ background: #eee; }
262
+ #methods .method .synopsis {
263
+ color: black;
264
+ background: silver;
265
+ padding: .2em 1em; }
266
+ #methods .method .synopsis .name {
267
+ font-weight: bold; }
268
+ #methods .method .synopsis a {
269
+ text-decoration: none; }
270
+ #methods .method .description {
271
+ padding: 0 1em; }
272
+ #methods .method .description pre {
273
+ background: #f8f8f8; }
274
+ #methods .method .source {
275
+ margin: .5em 0; }
276
+ #methods .method .source-toggle {
277
+ font-size: 85%;
278
+ margin-left: 1em; }
279
+ #methods .public-class {
280
+ background: #ffffe4; }
281
+ #methods .public-instance .synopsis {
282
+ color: #eee;
283
+ background: #336699; }
284
+
285
+ #content .method .source pre {
286
+ background: #262626;
287
+ color: #ffdead;
288
+ margin: 1em;
289
+ padding: 0.5em;
290
+ border: 1px dashed #999;
291
+ overflow: auto; }
292
+ #content .method .source pre .ruby-constant {
293
+ color: #7fffd4;
294
+ background: transparent; }
295
+ #content .method .source pre .ruby-keyword {
296
+ color: #00ffff;
297
+ background: transparent; }
298
+ #content .method .source pre .ruby-ivar {
299
+ color: #eedd82;
300
+ background: transparent; }
301
+ #content .method .source pre .ruby-operator {
302
+ color: #00ffee;
303
+ background: transparent; }
304
+ #content .method .source pre .ruby-identifier {
305
+ color: #ffdead;
306
+ background: transparent; }
307
+ #content .method .source pre .ruby-node {
308
+ color: #ffa07a;
309
+ background: transparent; }
310
+ #content .method .source pre .ruby-comment {
311
+ color: #b22222;
312
+ font-weight: bold;
313
+ background: transparent; }
314
+ #content .method .source pre .ruby-regexp {
315
+ color: #ffa07a;
316
+ background: transparent; }
317
+ #content .method .source pre .ruby-value {
318
+ color: #7fffd4;
319
+ background: transparent; }
@@ -0,0 +1,25 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ describe Hash do
4
+ before :all do
5
+ @item = {:a => "a key", :c => "another key"}
6
+ end
7
+
8
+ describe "transformations" do
9
+ it "should be renamable" do
10
+ @item.should respond_to(:rename)
11
+ end
12
+
13
+ it "should have a transform object" do
14
+ @item.rename(:a => :b).should == {:b => "a key", :c => "another key"}
15
+ end
16
+
17
+ it "should rename many keys" do
18
+ @item.rename(:a => :b, :c => :d).should == {:b => "a key", :d => "another key"}
19
+ end
20
+
21
+ it "should symbolise string keys" do
22
+ {"a" => {"b" => "bee"}}.symbolize_keys!.should == {:a => {:b => "bee"}}
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,75 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ describe Smoke::Cache do
4
+ describe "class methods" do
5
+ it "should respond to fetch" do
6
+ Smoke::Cache.should respond_to(:fetch)
7
+ end
8
+
9
+ it "should responsd to enabled?" do
10
+ Smoke::Cache.should respond_to(:enabled?)
11
+ end
12
+ end
13
+
14
+ describe "configuration" do
15
+ it "should not be enabled (by default)" do
16
+ Smoke::Cache.should_not be_enabled
17
+ end
18
+
19
+ it "should be enabled" do
20
+ Smoke.configure {|c| c[:cache][:enabled] = true }
21
+ Smoke::Cache.should be_enabled
22
+ end
23
+
24
+ it "should not be enabled" do
25
+ Smoke.configure {|c| c[:cache][:enabled] = false }
26
+ Smoke::Cache.should_not be_enabled
27
+ end
28
+
29
+ describe "invalid configuration" do
30
+ before do
31
+ @kernel = mock(Kernel)
32
+ @kernel.stub!(:exit)
33
+ end
34
+
35
+ it "should log with bad configuration" do
36
+ Proc.new {
37
+ Smoke.should_receive(:log)
38
+ Smoke.configure {|c| c[:cache][:store] = :ponies }
39
+ }
40
+ end
41
+ end
42
+ end
43
+
44
+ describe "caching my block" do
45
+ before :all do
46
+ Smoke.configure do |c|
47
+ c[:cache][:enabled] = true
48
+ c[:cache][:store] = :memory
49
+ end
50
+
51
+ @url = "http://memory.tld/store"
52
+ FakeWeb.register_uri(@url, :file => File.join(SPEC_DIR, 'supports', 'slashdot.xml'))
53
+
54
+ require 'moneta/memory'
55
+ @store = Moneta::Memory.new
56
+ Moneta::Memory.stub!(:new).and_return(@store)
57
+ end
58
+
59
+ it "should use the moneta::memory store" do
60
+ Moneta::Memory.should_receive(:new).with(Smoke.config[:cache][:options])
61
+
62
+ Smoke::Cache.fetch @url, {}
63
+ end
64
+
65
+ it "should try to read from the memory store" do
66
+ @store.should_receive(:[])
67
+ Smoke::Cache.fetch @url, {}
68
+ end
69
+
70
+ it "should be stored in the cache" do
71
+ Smoke::Cache.fetch @url, {}
72
+ @store['33af9f13054e64520430f7a437cdd377'].should_not be_nil
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,220 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ describe Smoke::Origin do
4
+ before :all do
5
+ @origin = TestSource.source(:test) do
6
+ emit do
7
+ rename(:head => :title)
8
+ sort(:title)
9
+ reverse
10
+ truncate 1
11
+
12
+ transform :title, :name do |title|
13
+ title.gsub(/Animal: /, '')
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ describe "transformations" do
20
+ it "should have renamed properties" do
21
+ Smoke[:test].output.first.should have_key(:title)
22
+ end
23
+
24
+ it "should sort by a given property" do
25
+ Smoke[:test].output.first[:title].should == "Platypus"
26
+ end
27
+
28
+ it "should reverse the results" do
29
+ Smoke[:test].output.should == [{:title => "Platypus", :name => "Peter"}]
30
+ end
31
+
32
+ it "should truncate results given a length" do
33
+ Smoke[:test].output.size.should == 1
34
+ end
35
+
36
+ it "should output" do
37
+ Smoke[:test].output.should be_an_instance_of(Array)
38
+ end
39
+
40
+ it "should output json" do
41
+ Smoke[:test].output(:json).should =~ /^\[\{/
42
+ end
43
+
44
+ it "should output yml" do
45
+ Smoke[:test].output(:yaml).should =~ /^--- \n- :/
46
+ end
47
+
48
+ describe "filtering" do
49
+ before :all do
50
+ TestSource.source(:keep) do
51
+ emit do
52
+ keep(:head, /roo/)
53
+ end
54
+ end
55
+
56
+ TestSource.source(:discard) do
57
+ emit do
58
+ discard(:head, /roo/)
59
+ end
60
+ end
61
+ end
62
+
63
+ it "should keep items" do
64
+ Smoke[:keep].should(respond_to(:keep))
65
+ end
66
+
67
+ it "should only contain items that match" do
68
+ Smoke[:keep].output.should == [{:head => "Animal: Kangaroo", :name => "Kelly"}]
69
+ end
70
+
71
+ it "should discard items" do
72
+ Smoke[:discard].should(respond_to(:discard))
73
+ end
74
+
75
+ it "should not contain items that match" do
76
+ Smoke[:discard].output.should == [{:head => "Animal: Platypus", :name => "Peter"}]
77
+ end
78
+ end
79
+ end
80
+
81
+ describe "dispatching" do
82
+ it "should dispatch when output is called" do
83
+ TestSource.source(:no_dispatch)
84
+ Smoke[:no_dispatch].should_not_receive(:dispatch)
85
+
86
+ TestSource.source(:dispatch)
87
+ Smoke[:dispatch].should_receive(:dispatch)
88
+ Smoke[:dispatch].output
89
+ end
90
+ end
91
+
92
+ describe "preperation" do
93
+ before :all do
94
+ @source = TestSource.source(:preperation)
95
+ end
96
+
97
+ it "should respond to prepare" do
98
+ @source.should respond_to(:prepare)
99
+ end
100
+
101
+ it "should require a block" do
102
+ lambda { @source.prepare }.should raise_error
103
+ lambda { @source.prepare {} }.should_not raise_error
104
+ end
105
+ end
106
+
107
+ describe "call order" do
108
+ before :all do
109
+ @url = "http://domain.tld/benschwarz/feed"
110
+ FakeWeb.register_uri(@url, :response => File.join(SPEC_DIR, 'supports', 'flickr-photo.json'))
111
+
112
+ Smoke.data :feed_preperation_call_order do
113
+ prepare do
114
+ url "http://domain.tld/#{username}/feed", :type => :json
115
+ end
116
+
117
+ path :photos, :photo
118
+ end
119
+ end
120
+
121
+ describe "before setting variables" do
122
+ it "should fail" do
123
+ lambda { Smoke[:feed_preperation_call_order].output }.should raise_error(NameError)
124
+ end
125
+ end
126
+
127
+ describe "setting abstract properties" do
128
+ it "should not respond to a property that hasn't been set" do
129
+ lambda { Smoke[:feed_preperation_call_order].abstract }.should raise_error(NoMethodError)
130
+ end
131
+
132
+ it "should allow setting a property" do
133
+ lambda { Smoke[:feed_preperation_call_order].abstract(:value) }.should_not raise_error(NoMethodError)
134
+ Smoke[:feed_preperation_call_order].abstract.should == :value
135
+ end
136
+
137
+ it "should chain the source when setting a property" do
138
+ Smoke[:feed_preperation_call_order].abstract(:value).should be_an_instance_of(Smoke::Source::Data)
139
+ end
140
+ end
141
+
142
+ describe "after setting variables" do
143
+ it "should output successfully" do
144
+ lambda { Smoke[:feed_preperation_call_order].username("benschwarz").output }.should_not raise_error
145
+ end
146
+
147
+ it "should have used the correct url" do
148
+ Smoke[:feed_preperation_call_order].request.uri.should == @url
149
+ end
150
+ end
151
+ end
152
+
153
+ describe "transformations" do
154
+ it "should respond to emit" do
155
+ Smoke[:test].should respond_to(:emit)
156
+ end
157
+
158
+ it "emit should require a block" do
159
+ lambda { Smoke[:test].emit }.should raise_error
160
+ lambda { Smoke[:test].emit {} }.should_not raise_error
161
+ end
162
+
163
+ it "should respond to transform" do
164
+ Smoke[:test].should respond_to(:transform)
165
+ end
166
+
167
+ it "tranform should require a block" do
168
+ lambda { Smoke[:test].transform }.should raise_error
169
+ lambda { Smoke[:test].transform {} }.should_not raise_error
170
+ end
171
+
172
+ it "should have at least one transformation" do
173
+ Smoke[:test].transformation.size.should_not be_nil
174
+ end
175
+ end
176
+
177
+ describe "key insertion" do
178
+ before do
179
+ TestSource.source(:insertion) do
180
+ emit do
181
+ insert(:source, "twitter")
182
+ end
183
+ end
184
+ end
185
+
186
+ it "should respond to insert" do
187
+ Smoke[:insertion].should respond_to(:insert)
188
+ end
189
+
190
+ it "should insert values into each key" do
191
+ Smoke[:insertion].output.first.should have_key :source
192
+ Smoke[:insertion].output.first[:source].should == "twitter"
193
+ end
194
+ end
195
+
196
+ describe "sorting" do
197
+ before :all do
198
+ TestSource.source(:sorting) do
199
+ emit do
200
+ sort :header
201
+ end
202
+ end
203
+
204
+ TestSource.source(:reversed) do
205
+ emit do
206
+ sort :header
207
+ reverse
208
+ end
209
+ end
210
+ end
211
+
212
+ it "should softly error when attempting to sort on a key that doesn't exist" do
213
+ Smoke[:sorting].output.should_not raise_error("NoMethodError")
214
+ end
215
+
216
+ it "should be reversed" do
217
+ Smoke[:reversed].output.should == Smoke[:sorting].output.reverse
218
+ end
219
+ end
220
+ end