superbolt 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -6
- data/lib/superbolt.rb +0 -4
- data/lib/superbolt/app.rb +0 -12
- data/lib/superbolt/connection/app.rb +0 -5
- data/lib/superbolt/connection/queue.rb +0 -4
- data/lib/superbolt/incoming_message.rb +1 -8
- data/lib/superbolt/messenger.rb +0 -9
- data/lib/superbolt/runner/pg.rb +10 -2
- data/lib/superbolt/version.rb +1 -1
- data/spec/app_spec.rb +1 -18
- data/spec/config_spec.rb +1 -1
- data/spec/incoming_message_spec.rb +0 -12
- data/spec/lib/superbolt/runner/pg_spec.rb +26 -33
- data/spec/messenger_spec.rb +1 -17
- data/spec/queue_spec.rb +3 -3
- data/superbolt.gemspec +0 -1
- metadata +3 -26
- data/lib/superbolt/file_manager.rb +0 -24
- data/lib/superbolt/file_packer.rb +0 -7
- data/lib/superbolt/file_unpacker.rb +0 -7
- data/spec/file_packer_spec.rb +0 -27
- data/spec/file_unpacker_spec.rb +0 -26
- data/spec/support/commodore.jpg +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e553aac5d606b63183b802cb08a07c43e2a04e9d
|
4
|
+
data.tar.gz: 06a774880b8b0f9164defd612b5212d28655adaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7de9c9e6a98e5609d9157e23edc4c542d81c6bf533f6dc79d2b7cd54f2c7875c6650edd05344b682e7f3f7fa9d607010a1e1211da81004ff38dd355ff4b1d7d1
|
7
|
+
data.tar.gz: 1f8f67313fa1b123a73de0975e1f090467bd610f8dcf56f02b2c66d35efe45d2a5f6abc09fe50798b42618aadc4befbc3ed543f2d6c4b9b096976c4a739a3875
|
data/README.md
CHANGED
@@ -222,12 +222,6 @@ the Superbolt app. Errors will be logged and the notification will be sent
|
|
222
222
|
to the error notifier (none by default, can be airbrake) with information
|
223
223
|
about the exception raised.
|
224
224
|
|
225
|
-
The app can be shutdown gracefully by sending a quit message to a
|
226
|
-
special queue:
|
227
|
-
|
228
|
-
quit_queue = Superbolt::App.new('dorothy_inbox').quit_queue
|
229
|
-
quit_queue.push(message: 'for a deploy')
|
230
|
-
|
231
225
|
## Error reporting
|
232
226
|
|
233
227
|
`Superbolt::App` can hook into Airbrake by your command:
|
data/lib/superbolt.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'json'
|
2
2
|
|
3
|
-
require 'file_marshal'
|
4
3
|
require 'bunny'
|
5
4
|
require 'amqp'
|
6
5
|
require 'eventmachine'
|
@@ -36,9 +35,6 @@ require "superbolt/app"
|
|
36
35
|
require "superbolt/processor"
|
37
36
|
require "superbolt/facade"
|
38
37
|
require "superbolt/messenger"
|
39
|
-
require "superbolt/file_manager"
|
40
|
-
require "superbolt/file_unpacker"
|
41
|
-
require "superbolt/file_packer"
|
42
38
|
|
43
39
|
require "superbolt/spec_helpers"
|
44
40
|
|
data/lib/superbolt/app.rb
CHANGED
@@ -16,11 +16,6 @@ module Superbolt
|
|
16
16
|
env ? "#{@name}_#{env}" : @name
|
17
17
|
end
|
18
18
|
|
19
|
-
# just in case you have a handle to the app and want to quit it
|
20
|
-
def quit_queue
|
21
|
-
Queue.new("#{connection.name}.quit", connection.config)
|
22
|
-
end
|
23
|
-
|
24
19
|
def connection
|
25
20
|
@connection ||= Connection::Queue.new(name, config)
|
26
21
|
end
|
@@ -33,15 +28,8 @@ module Superbolt
|
|
33
28
|
connection.q
|
34
29
|
end
|
35
30
|
|
36
|
-
def quit_subscriber_queue
|
37
|
-
connection.qq
|
38
|
-
end
|
39
|
-
|
40
31
|
def run(&block)
|
41
32
|
runner_class.new(queue, error_notifier, logger, block).run
|
42
|
-
# quit_subscriber_queue.subscribe do |message|
|
43
|
-
# (message)
|
44
|
-
# end
|
45
33
|
end
|
46
34
|
|
47
35
|
def runner_class
|
@@ -9,8 +9,7 @@ module Superbolt
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def parse
|
12
|
-
|
13
|
-
unpack_files(hash)
|
12
|
+
JSON.parse(payload)
|
14
13
|
rescue JSON::ParserError
|
15
14
|
payload
|
16
15
|
end
|
@@ -22,11 +21,5 @@ module Superbolt
|
|
22
21
|
def ack
|
23
22
|
channel.acknowledge(tag)
|
24
23
|
end
|
25
|
-
|
26
|
-
def unpack_files(hash)
|
27
|
-
return hash unless hash.is_a?(Hash) && hash["arguments"].is_a?(Hash)
|
28
|
-
hash['arguments'] = FileUnpacker.new(hash["arguments"]).perform
|
29
|
-
hash
|
30
|
-
end
|
31
24
|
end
|
32
25
|
end
|
data/lib/superbolt/messenger.rb
CHANGED
@@ -47,18 +47,9 @@ module Superbolt
|
|
47
47
|
|
48
48
|
def send!(args=nil)
|
49
49
|
self.arguments = args if args
|
50
|
-
pack_files
|
51
50
|
queue.push(message)
|
52
51
|
end
|
53
52
|
|
54
|
-
def pack_files
|
55
|
-
return unless arguments.is_a?(Hash)
|
56
|
-
file_keys = arguments.keys.find_all { |key| key.to_s.match(Superbolt.file_matcher) }
|
57
|
-
file_keys.each do |key|
|
58
|
-
arguments[key] = FileMarshal::Dumper.new(arguments[key]).to_hash
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
53
|
def queue
|
63
54
|
unless name
|
64
55
|
raise "no destination app name defined, please pass one in"
|
data/lib/superbolt/runner/pg.rb
CHANGED
@@ -2,12 +2,20 @@ module Superbolt
|
|
2
2
|
module Runner
|
3
3
|
class Pg < AckOne
|
4
4
|
def on_error(message, error)
|
5
|
-
if error
|
6
|
-
ActiveRecord::Base.connection.
|
5
|
+
if reconnect_after_error?(error)
|
6
|
+
ActiveRecord::Base.connection.reconnect!
|
7
7
|
end
|
8
8
|
|
9
9
|
super
|
10
10
|
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def reconnect_after_error?(error)
|
15
|
+
error.is_a?(ActiveRecord::StatementInvalid) and
|
16
|
+
error.message.start_with?("PG::UnableToSend") or
|
17
|
+
error.message.start_with?("PG::ConnectionBad")
|
18
|
+
end
|
11
19
|
end
|
12
20
|
end
|
13
21
|
end
|
data/lib/superbolt/version.rb
CHANGED
data/spec/app_spec.rb
CHANGED
@@ -13,33 +13,17 @@ describe Superbolt::App do
|
|
13
13
|
let(:name) { 'superbolt' }
|
14
14
|
let(:logger) { Logger.new('/dev/null') }
|
15
15
|
let(:queue) { Superbolt::Queue.new("#{name}_#{env}") }
|
16
|
-
let(:quit_queue) { Superbolt::Queue.new("#{name}_#{env}.quit") }
|
17
|
-
let(:error_queue) { Superbolt::Queue.new("#{name}_#{env}.error") }
|
18
16
|
let(:messages) { [] }
|
19
17
|
|
20
18
|
before do
|
21
19
|
queue.clear
|
22
|
-
quit_queue.clear
|
23
|
-
error_queue.clear
|
24
20
|
end
|
25
21
|
|
26
22
|
after do
|
27
23
|
queue.clear
|
28
|
-
quit_queue.clear
|
29
|
-
error_queue.clear
|
30
24
|
end
|
31
25
|
|
32
26
|
shared_examples 'app' do
|
33
|
-
# it "shuts down with any message to the quit queue" do
|
34
|
-
# queue.push({please: 'stop'})
|
35
|
-
# app.run do |arguments|
|
36
|
-
# quit_queue.push({message: 'just because'})
|
37
|
-
# end
|
38
|
-
|
39
|
-
# queue.size.should == 0
|
40
|
-
# quit_queue.size.should == 0
|
41
|
-
# end
|
42
|
-
|
43
27
|
it 'passes messages to the block for processing' do
|
44
28
|
queue.push({first: 1})
|
45
29
|
queue.push({last: 2})
|
@@ -88,11 +72,10 @@ describe Superbolt::App do
|
|
88
72
|
|
89
73
|
app.run do |message, logger|
|
90
74
|
logger.info(message)
|
91
|
-
# quit_queue.push({message: 'stop!'})
|
92
75
|
app.quit
|
93
76
|
end
|
94
77
|
|
95
|
-
message_received.should
|
78
|
+
message_received.should eq true
|
96
79
|
end
|
97
80
|
|
98
81
|
context 'notifying errors' do
|
data/spec/config_spec.rb
CHANGED
@@ -19,18 +19,6 @@ describe Superbolt::IncomingMessage do
|
|
19
19
|
it "parses it to a hash" do
|
20
20
|
message.parse.should == {'some' => 'message'}
|
21
21
|
end
|
22
|
-
|
23
|
-
context 'payload has a file' do
|
24
|
-
let(:payload) { { 'arguments' => {'some_file' => {'file_hash' => 'yup'}} }.to_json }
|
25
|
-
let(:packer) { double('packer', perform: {'some_file' => 'some_file'} ) }
|
26
|
-
|
27
|
-
it "uses FilePacker to rewrite files into a hash" do
|
28
|
-
Superbolt::FileUnpacker.should_receive(:new)
|
29
|
-
.with({'some_file' => {'file_hash' => 'yup'}})
|
30
|
-
.and_return(packer)
|
31
|
-
message.parse.should == {'arguments' => packer.perform}
|
32
|
-
end
|
33
|
-
end
|
34
22
|
end
|
35
23
|
end
|
36
24
|
|
@@ -2,52 +2,45 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module ActiveRecord
|
4
4
|
class Base
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
module PG
|
9
|
-
class UnableToSend
|
10
|
-
def self.message
|
11
|
-
'oh noes'
|
5
|
+
def self.connection
|
6
|
+
@@connection
|
12
7
|
end
|
13
8
|
|
14
|
-
|
15
|
-
|
9
|
+
@@connection = Class.new do
|
10
|
+
def self.reset!
|
11
|
+
end
|
16
12
|
end
|
17
13
|
end
|
18
14
|
|
19
|
-
class
|
20
|
-
def self.message
|
21
|
-
'oh noes'
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.backtrace
|
25
|
-
'trace me'
|
26
|
-
end
|
15
|
+
class StatementInvalid < StandardError
|
27
16
|
end
|
28
17
|
end
|
29
18
|
|
19
|
+
PG_UNABLE_TO_SEND_ERROR = ActiveRecord::StatementInvalid.new("PG::UnableToSend: server closed the connection unexpectedly\n\tThis probably means the server terminated abnormally\n\tbefore or while processing the request.\n: SELECT \"data_sources\".* FROM \"data_sources\" WHERE \"data_sources\".\"program_id\" = 1 AND \"data_sources\".\"identifier\" = 'qz.com/feed' ORDER BY \"data_sources\".\"id\" ASC LIMIT 1")
|
20
|
+
|
21
|
+
PG_CONNECTION_BAD_ERROR = ActiveRecord::StatementInvalid.new("PG::ConnectionBad: PQsocket() can't get socket descriptor: BEGIN")
|
22
|
+
|
30
23
|
describe "Superbolt::Runner::Pg" do
|
31
|
-
|
32
|
-
let(:connection) { double('connection', reset!: true) }
|
24
|
+
subject(:runner) { Superbolt::Runner::Pg.new('berkin', Superbolt::ErrorNotifier::None.new, 'whatever', 'some block') }
|
33
25
|
|
34
|
-
|
35
|
-
ActiveRecord::
|
36
|
-
|
26
|
+
describe "#on_error" do
|
27
|
+
it "reconnects ActiveRecord when it gets PG::UnableToSend" do
|
28
|
+
expect(ActiveRecord::Base.connection).to receive(:reconnect!)
|
29
|
+
report_error(PG_UNABLE_TO_SEND_ERROR)
|
30
|
+
end
|
37
31
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
connection.should_receive(:reset!).and_return(true)
|
42
|
-
runner.on_error({message: 'somethig has gone very wrong'}, PG::UnableToSend)
|
43
|
-
end
|
32
|
+
it "reconnects ActiveRecord when it gets PG::ConnectionBad" do
|
33
|
+
expect(ActiveRecord::Base.connection).to receive(:reconnect!)
|
34
|
+
report_error(PG_CONNECTION_BAD_ERROR)
|
44
35
|
end
|
45
36
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
runner.on_error({message: 'somethig has gone very wrong'}, PG::ConnectionBad)
|
50
|
-
end
|
37
|
+
it "doesn't reconnect for AR::StatementInvalid with a different message" do
|
38
|
+
expect(ActiveRecord::Base.connection).to_not receive(:reconnect!)
|
39
|
+
report_error(ActiveRecord::StatementInvalid.new("some other message"))
|
51
40
|
end
|
52
41
|
end
|
42
|
+
|
43
|
+
def report_error(exception)
|
44
|
+
runner.on_error({"superbolt_message_payload" => "hello"}, exception)
|
45
|
+
end
|
53
46
|
end
|
data/spec/messenger_spec.rb
CHANGED
@@ -51,17 +51,12 @@ describe Superbolt::Messenger do
|
|
51
51
|
messenger.re('zap')
|
52
52
|
message[:event].should == 'zap'
|
53
53
|
end
|
54
|
-
|
55
|
-
it "passes data to the message" do
|
56
|
-
messenger.data({foo: 'bar'})
|
57
|
-
message[:arguments].should == {foo: 'bar'}
|
58
|
-
end
|
59
54
|
end
|
60
55
|
|
61
56
|
context 'reading' do
|
62
57
|
it '#to returns the name' do
|
63
58
|
messenger.to('transducer')
|
64
|
-
messenger.to.
|
59
|
+
expect(messenger.to).to eq 'transducer'
|
65
60
|
end
|
66
61
|
|
67
62
|
it '#from returns the origin' do
|
@@ -82,8 +77,6 @@ describe Superbolt::Messenger do
|
|
82
77
|
end
|
83
78
|
|
84
79
|
describe 'send!' do
|
85
|
-
let(:image_file) { File.open(File.dirname(__FILE__) + '/support/commodore.jpg')}
|
86
|
-
|
87
80
|
before do
|
88
81
|
messenger
|
89
82
|
.to(name)
|
@@ -99,14 +92,5 @@ describe Superbolt::Messenger do
|
|
99
92
|
'arguments' => 'none'
|
100
93
|
}
|
101
94
|
end
|
102
|
-
|
103
|
-
it "converts any values that have key ending in '_file' with FileMarshal" do
|
104
|
-
messenger.send!({
|
105
|
-
image_file: image_file
|
106
|
-
})
|
107
|
-
|
108
|
-
message = queue.pop
|
109
|
-
message['arguments']['image_file'].should be_a(Tempfile)
|
110
|
-
end
|
111
95
|
end
|
112
96
|
end
|
data/spec/queue_spec.rb
CHANGED
@@ -15,9 +15,9 @@ describe 'Superbolt::Queue' do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "is setup with the right defaults" do
|
18
|
-
queue.exclusive?.should
|
19
|
-
queue.durable?.should
|
20
|
-
queue.auto_delete?.should
|
18
|
+
queue.exclusive?.should eq false
|
19
|
+
queue.durable?.should eq true
|
20
|
+
queue.auto_delete?.should eq false
|
21
21
|
end
|
22
22
|
|
23
23
|
describe 'queue/array operations' do
|
data/superbolt.gemspec
CHANGED
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency "amqp"
|
23
23
|
spec.add_dependency "bunny"
|
24
24
|
spec.add_dependency 'eventmachine'
|
25
|
-
spec.add_dependency 'file_marshal'
|
26
25
|
|
27
26
|
spec.add_development_dependency "bundler", "~> 1.3"
|
28
27
|
spec.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superbolt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- socialchorus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: file_marshal
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: bundler
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,9 +133,6 @@ files:
|
|
147
133
|
- lib/superbolt/error_notifier/airbrake.rb
|
148
134
|
- lib/superbolt/error_notifier/none.rb
|
149
135
|
- lib/superbolt/facade.rb
|
150
|
-
- lib/superbolt/file_manager.rb
|
151
|
-
- lib/superbolt/file_packer.rb
|
152
|
-
- lib/superbolt/file_unpacker.rb
|
153
136
|
- lib/superbolt/incoming_message.rb
|
154
137
|
- lib/superbolt/message_handler.rb
|
155
138
|
- lib/superbolt/messenger.rb
|
@@ -170,8 +153,6 @@ files:
|
|
170
153
|
- spec/app_spec.rb
|
171
154
|
- spec/config_spec.rb
|
172
155
|
- spec/connection_spec.rb
|
173
|
-
- spec/file_packer_spec.rb
|
174
|
-
- spec/file_unpacker_spec.rb
|
175
156
|
- spec/incoming_message_spec.rb
|
176
157
|
- spec/lib/superbolt/error_notifier/airbrake_spec.rb
|
177
158
|
- spec/lib/superbolt/error_notifier/none_spec.rb
|
@@ -181,7 +162,6 @@ files:
|
|
181
162
|
- spec/router_spec.rb
|
182
163
|
- spec/spec_helper.rb
|
183
164
|
- spec/superbolt_spec.rb
|
184
|
-
- spec/support/commodore.jpg
|
185
165
|
- spec/support/em_mocking.rb
|
186
166
|
- spec/support/queue_helpers.rb
|
187
167
|
- superbolt.gemspec
|
@@ -205,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
185
|
version: '0'
|
206
186
|
requirements: []
|
207
187
|
rubyforge_project:
|
208
|
-
rubygems_version: 2.
|
188
|
+
rubygems_version: 2.0.14
|
209
189
|
signing_key:
|
210
190
|
specification_version: 4
|
211
191
|
summary: Superbolt is a gem that makes SOA intra-app communication easy, via RabbitMQ
|
@@ -213,8 +193,6 @@ test_files:
|
|
213
193
|
- spec/app_spec.rb
|
214
194
|
- spec/config_spec.rb
|
215
195
|
- spec/connection_spec.rb
|
216
|
-
- spec/file_packer_spec.rb
|
217
|
-
- spec/file_unpacker_spec.rb
|
218
196
|
- spec/incoming_message_spec.rb
|
219
197
|
- spec/lib/superbolt/error_notifier/airbrake_spec.rb
|
220
198
|
- spec/lib/superbolt/error_notifier/none_spec.rb
|
@@ -224,6 +202,5 @@ test_files:
|
|
224
202
|
- spec/router_spec.rb
|
225
203
|
- spec/spec_helper.rb
|
226
204
|
- spec/superbolt_spec.rb
|
227
|
-
- spec/support/commodore.jpg
|
228
205
|
- spec/support/em_mocking.rb
|
229
206
|
- spec/support/queue_helpers.rb
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Superbolt
|
2
|
-
class FileManager
|
3
|
-
attr_reader :hash
|
4
|
-
|
5
|
-
def initialize(hash)
|
6
|
-
@hash = hash
|
7
|
-
end
|
8
|
-
|
9
|
-
def perform
|
10
|
-
file_keys.each do |key|
|
11
|
-
hash[key] = process_file(hash[key])
|
12
|
-
end
|
13
|
-
hash
|
14
|
-
end
|
15
|
-
|
16
|
-
def file_keys
|
17
|
-
@file_keys ||= hash.keys.find_all { |key| key.to_s.match(Superbolt.file_matcher) }
|
18
|
-
end
|
19
|
-
|
20
|
-
def process_file(arg)
|
21
|
-
raise NotImplementedError
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/spec/file_packer_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Superbolt::FilePacker do
|
4
|
-
let(:packer) { Superbolt::FilePacker.new(hash) }
|
5
|
-
|
6
|
-
let(:hash) {
|
7
|
-
{
|
8
|
-
my_file: file,
|
9
|
-
foo: 'bar'
|
10
|
-
}
|
11
|
-
}
|
12
|
-
|
13
|
-
let(:dumper) { double('dumper', to_hash: {}) }
|
14
|
-
|
15
|
-
let(:file) { double('file') }
|
16
|
-
|
17
|
-
describe '#perform' do
|
18
|
-
it "makes matching keys into a file hash via FileMarshal" do
|
19
|
-
FileMarshal::Dumper.should_receive(:new).with(file).and_return(dumper)
|
20
|
-
dumper.should_receive(:to_hash)
|
21
|
-
packer.perform.should == {
|
22
|
-
foo: 'bar',
|
23
|
-
my_file: {}
|
24
|
-
}
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/spec/file_unpacker_spec.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Superbolt::FileUnpacker do
|
4
|
-
let(:unpacker){ Superbolt::FileUnpacker.new(hash) }
|
5
|
-
let(:file) { File.open(File.dirname(__FILE__) + '/support/commodore.jpg')}
|
6
|
-
let(:file_hash) {
|
7
|
-
# back and forth in JSON required due to Time.parse issues
|
8
|
-
JSON.parse(FileMarshal::Dumper.new(file).to_hash.to_json)
|
9
|
-
}
|
10
|
-
let(:hash) {
|
11
|
-
{
|
12
|
-
my_file: file_hash,
|
13
|
-
foo: 'bar'
|
14
|
-
}
|
15
|
-
}
|
16
|
-
|
17
|
-
describe "#perform" do
|
18
|
-
it "makes the keys matching the Superbolt.file_matcher" do
|
19
|
-
unpacker.perform[:my_file].should be_a Tempfile
|
20
|
-
end
|
21
|
-
|
22
|
-
it "leaves everything else alone" do
|
23
|
-
unpacker.perform[:foo].should == "bar"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/spec/support/commodore.jpg
DELETED
Binary file
|