alephant 0.0.9.9.1-java → 0.1.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/alephant.gemspec +8 -2
  4. data/lib/alephant.rb +40 -56
  5. data/lib/alephant/models/jsonpath_lookup.rb +16 -0
  6. data/lib/alephant/models/parser.rb +20 -2
  7. data/lib/alephant/models/queue.rb +6 -5
  8. data/lib/alephant/models/render_mapper.rb +56 -0
  9. data/lib/alephant/models/writer.rb +44 -0
  10. data/lib/alephant/version.rb +1 -1
  11. data/lib/env.rb +0 -2
  12. data/spec/alephant_spec.rb +51 -197
  13. data/spec/fixtures/components/foo/models/bar.rb +7 -0
  14. data/spec/fixtures/components/foo/models/foo.rb +1 -1
  15. data/spec/parser_spec.rb +17 -9
  16. data/spec/render_mapper_spec.rb +63 -0
  17. data/spec/spec_helper.rb +1 -0
  18. data/spec/writer_spec.rb +52 -0
  19. metadata +97 -34
  20. data/bin/alephant +0 -37
  21. data/lib/alephant/errors.rb +0 -6
  22. data/lib/alephant/errors/invalid_view_path.rb +0 -6
  23. data/lib/alephant/errors/view_model_not_found.rb +0 -6
  24. data/lib/alephant/errors/view_template_not_found.rb +0 -6
  25. data/lib/alephant/models/cache.rb +0 -28
  26. data/lib/alephant/models/logger.rb +0 -22
  27. data/lib/alephant/models/multi_renderer.rb +0 -84
  28. data/lib/alephant/models/renderer.rb +0 -34
  29. data/lib/alephant/models/sequence_table.rb +0 -99
  30. data/lib/alephant/models/sequencer.rb +0 -61
  31. data/lib/alephant/preview/server.rb +0 -75
  32. data/lib/alephant/preview/template.rb +0 -63
  33. data/lib/alephant/tasks.rb +0 -8
  34. data/lib/alephant/util/string.rb +0 -9
  35. data/lib/alephant/views.rb +0 -15
  36. data/lib/alephant/views/base.rb +0 -16
  37. data/lib/alephant/views/preview.rb +0 -44
  38. data/lib/tasks/preview.rake +0 -16
  39. data/spec/cache_spec.rb +0 -63
  40. data/spec/logger_spec.rb +0 -40
  41. data/spec/multi_renderer_spec.rb +0 -92
  42. data/spec/renderer_spec.rb +0 -62
  43. data/spec/sequencer_spec.rb +0 -107
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f69ea72533208eadc0bfa7a753e1cda142ab50b2
4
- data.tar.gz: b493462c0cfa05a935b3e09b152b12521cb64909
3
+ metadata.gz: e380898fbfc1de04d24909fbd8cc82f82c338c4d
4
+ data.tar.gz: 8d82eb8ad5ec19279c9547092e74d04aabc61ac1
5
5
  SHA512:
6
- metadata.gz: 9b140cb3277fef033e6abf154690f9df92ef07936c9df636a19b9ef3d6e885f375a3697cac5568f476a34cf3fe8e82cb3a51351de05143916636c1541d74043b
7
- data.tar.gz: e5fd40d103db18f36253518ce061c27460fdee0812827131ffbd266b9c6d06c377fdcc71ce69e5b370e820eed182b515a56452cd568842befef5477e6ed0d299
6
+ metadata.gz: 3ca79920b31f43796118ff510eea1735ff2fdfc396357dd867e5711ddc918b70de9d9774dd9380c320476f70ad373d8ad0ac58b7a548e3f14b4f874dec1af91a
7
+ data.tar.gz: 5d48de598a04829e0ed2a1fbddd909cad847cf79fc10fc2f9846ffcdd0a5521139ee5be51d2dc072531cb1aa19f473c10d109543f1dadc5ca46003d850d26003
data/.gitignore CHANGED
@@ -8,3 +8,4 @@ Gemfile.lock
8
8
  /tmp
9
9
  /components
10
10
 
11
+ *.swp
data/alephant.gemspec CHANGED
@@ -8,14 +8,13 @@ Gem::Specification.new do |s|
8
8
  s.name = 'alephant'
9
9
  s.version = Alephant::VERSION
10
10
  s.date = Time.now.strftime "%Y-%m-%d"
11
- s.summary = "Static Publishing in the Cloud"
11
+ s.summary = "Static publishing in the cloud"
12
12
  s.description = "Static publishing to S3 based on SQS messages"
13
13
  s.authors = ["Robert Kenny"]
14
14
  s.email = 'kenoir@gmail.com'
15
15
  s.license = 'GPLv3'
16
16
 
17
17
  s.files = `git ls-files`.split($/)
18
- s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
18
  s.platform = "java"
20
19
  s.homepage = 'https://github.com/BBC-News/alephant'
21
20
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
@@ -36,5 +35,12 @@ Gem::Specification.new do |s|
36
35
  s.add_runtime_dependency 'aws-sdk', '~> 1.0'
37
36
  s.add_runtime_dependency 'mustache', '>= 0.99.5'
38
37
  s.add_runtime_dependency 'jsonpath'
38
+
39
+ s.add_runtime_dependency 'alephant-sequencer'
40
+ s.add_runtime_dependency 'alephant-logger'
41
+ s.add_runtime_dependency 'alephant-cache'
42
+ s.add_runtime_dependency 'alephant-renderer'
43
+ s.add_runtime_dependency 'alephant-lookup'
44
+ s.add_runtime_dependency 'alephant-preview'
39
45
  end
40
46
 
data/lib/alephant.rb CHANGED
@@ -1,63 +1,48 @@
1
1
  require_relative 'env'
2
2
 
3
- require 'alephant/models/logger'
4
- require 'alephant/models/queue'
5
- require 'alephant/models/cache'
6
- require 'alephant/models/renderer'
7
- require 'alephant/models/multi_renderer'
8
- require 'alephant/models/sequence_table'
9
- require 'alephant/models/sequencer'
3
+ require 'alephant/models/render_mapper'
10
4
  require 'alephant/models/parser'
5
+ require 'alephant/models/writer'
6
+ require 'alephant/models/queue'
11
7
 
12
- require 'alephant/errors'
8
+ require 'alephant/sequencer'
9
+ require 'alephant/cache'
10
+ require 'alephant/logger'
13
11
  require 'alephant/views'
12
+ require 'alephant/renderer'
13
+ require 'alephant/lookup'
14
14
 
15
15
  module Alephant
16
16
  class Alephant
17
- attr_reader :sequencer, :queue, :cache, :renderer
17
+ include ::Alephant::Logger
18
18
 
19
- VALID_OPTS = [
20
- :s3_bucket_id,
21
- :s3_object_path,
22
- :s3_object_id,
23
- :table_name,
24
- :sqs_queue_id,
25
- :view_path,
26
- :component_id,
27
- :sequence_id
28
- ]
19
+ attr_reader :sequencer, :queue, :writer, :parser
29
20
 
30
21
  def initialize(opts = {}, logger = nil)
31
- set_logger(logger)
32
- set_opts(opts)
33
-
34
- @logger = ::Alephant.logger
35
- @sequencer = Sequencer.create(@table_name, @sqs_queue_id, @sequence_id)
36
- @queue = Queue.new(@sqs_queue_id)
37
- @cache = Cache.new(@s3_bucket_id, @s3_object_path)
38
- @multi_renderer = MultiRenderer.new(@component_id, @view_path)
39
- @parser = Parser.new
40
- end
41
-
42
- def set_logger(logger)
43
- ::Alephant.logger = logger
44
- end
45
-
46
- def write(data)
47
- @multi_renderer.render(data).each do |id, item|
48
- @cache.put(id, item)
49
- end
50
- end
22
+ ::Alephant::Logger.set_logger(logger) unless logger.nil?
51
23
 
52
- def receive(msg)
53
- @logger.info("Alephant.receive: with id #{msg.id} and body digest: #{msg.md5}")
54
-
55
- if @sequencer.sequential?(msg)
56
- write @parser.parse msg.body
57
- @sequencer.set_last_seen(msg)
58
- else
59
- @logger.warn("Alephant.receive: out of sequence message received #{msg.id} (discarded)")
60
- end
24
+ @parser = Parser.new(
25
+ opts[:msg_vary_id_path]
26
+ )
27
+ @sequencer = Sequencer.create(
28
+ opts[:sequencer_table_name],
29
+ opts[:sqs_queue_url],
30
+ opts[:sequence_id_path]
31
+ )
32
+ @queue = Queue.new(
33
+ opts[:sqs_queue_url]
34
+ )
35
+ @writer = Writer.new(
36
+ opts.select do |k,v|
37
+ [
38
+ :renderer_id,
39
+ :s3_bucket_id,
40
+ :s3_object_path,
41
+ :view_path,
42
+ :lookup_table_name
43
+ ].include? k
44
+ end
45
+ )
61
46
  end
62
47
 
63
48
  def run!
@@ -66,15 +51,14 @@ module Alephant
66
51
  end
67
52
  end
68
53
 
54
+ def receive(msg)
55
+ write msg if sequencer.sequential?(msg)
56
+ end
57
+
69
58
  private
70
- def set_opts(opts)
71
- VALID_OPTS.each do | k |
72
- v = opts.has_key?(k) ? opts[k] : nil
73
- singleton_class.class_eval do
74
- attr_accessor k
75
- end
76
- send("#{k}=", v)
77
- end
59
+ def write(msg)
60
+ writer.write(parser.parse(msg), sequencer.sequence_id_from(msg))
61
+ sequencer.set_last_seen(msg)
78
62
  end
79
63
 
80
64
  end
@@ -0,0 +1,16 @@
1
+ require 'jsonpath'
2
+ require 'json'
3
+
4
+ module Alephant
5
+ class JsonPathLookup
6
+ attr_reader :path
7
+ def initialize(path)
8
+ @path = path
9
+ @jsonpath = JsonPath.new(path)
10
+ end
11
+
12
+ def lookup(msg)
13
+ @jsonpath.on(JSON.parse(msg)).first
14
+ end
15
+ end
16
+ end
@@ -2,8 +2,26 @@ require 'json'
2
2
 
3
3
  module Alephant
4
4
  class Parser
5
- def parse data
5
+ attr_reader :vary_lookup
6
+
7
+ def initialize(vary_jsonpath = nil)
8
+ @vary_lookup = vary_jsonpath ? JsonPathLookup.new(vary_jsonpath) : nil
9
+ end
10
+
11
+ def parse(msg)
12
+ symbolize(msg.body).tap { |o| o[:options] = options_for msg }
13
+ end
14
+
15
+ private
16
+ def symbolize(data)
6
17
  JSON.parse(data, :symbolize_names => true)
7
18
  end
19
+
20
+ def options_for(msg)
21
+ {}.tap do |o|
22
+ o[:variant] = vary_lookup.lookup(msg.body) if not vary_lookup.nil?
23
+ end
24
+ end
8
25
  end
9
- end
26
+ end
27
+
@@ -1,22 +1,23 @@
1
1
  require 'aws-sdk'
2
+ require 'alephant/logger'
2
3
 
3
4
  module Alephant
4
5
  class Queue
6
+ include ::Alephant::Logger
7
+
5
8
  attr_accessor :q
6
9
 
7
10
  def initialize(id)
8
- @logger = ::Alephant.logger
9
-
10
11
  @sqs = AWS::SQS.new
11
12
  @q = @sqs.queues[id]
12
13
 
13
14
  unless @q.exists?
14
15
  @q = @sqs.queues.create(id)
15
16
  sleep_until_queue_exists
16
- @logger.info("Queue.initialize: created queue with id #{id}")
17
+ logger.info("Queue.initialize: created queue with id #{id}")
17
18
  end
18
19
 
19
- @logger.info("Queue.initialize: ended with id #{id}")
20
+ logger.info("Queue.initialize: ended with id #{id}")
20
21
  end
21
22
 
22
23
  def sleep_until_queue_exists
@@ -24,7 +25,7 @@ module Alephant
24
25
  end
25
26
 
26
27
  def poll(*args, &block)
27
- @logger.info("Queue.poll: polling with arguments #{args}")
28
+ logger.info("Queue.poll: polling with arguments #{args}")
28
29
  @q.poll(*args, &block)
29
30
  end
30
31
  end
@@ -0,0 +1,56 @@
1
+ require 'alephant/logger'
2
+
3
+ module Alephant
4
+ class RenderMapper
5
+ include ::Alephant::Logger
6
+ DEFAULT_LOCATION = 'components'
7
+
8
+ def initialize(component_id, view_base_path=nil)
9
+ self.base_path = "#{view_base_path}/#{component_id}" unless view_base_path.nil?
10
+ @component_id = component_id
11
+ end
12
+
13
+ def base_path
14
+ @base_path || DEFAULT_LOCATION
15
+ end
16
+
17
+ def base_path=(path)
18
+ @base_path = File.directory?(path) ? path : (raise "Invalid path")
19
+ end
20
+
21
+ def generate(data)
22
+ template_locations.reduce({}) do |obj, file|
23
+ template_id = template_id_for file
24
+ obj.tap { |o| o[template_id] = create_renderer(template_id, data) }
25
+ end
26
+ end
27
+
28
+ def create_renderer(template_file, data)
29
+ model = instantiate_model(template_file, data)
30
+ Renderer.create(template_file, base_path, model)
31
+ end
32
+
33
+ private
34
+ def instantiate_model(view_id, data)
35
+ require model_location_for view_id
36
+ Views.get_registered_class(view_id).new(data)
37
+ end
38
+
39
+ def model_location_for(template_file)
40
+ File.join(base_path, 'models', "#{template_file}.rb")
41
+ end
42
+
43
+ def template_locations
44
+ Dir[template_base_path]
45
+ end
46
+
47
+ def template_base_path
48
+ "#{base_path}/templates/*"
49
+ end
50
+
51
+ def template_id_for(template_location)
52
+ template_location.split('/').last.sub(/\.mustache/, '')
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,44 @@
1
+ require 'alephant/models/jsonpath_lookup'
2
+
3
+ module Alephant
4
+ class Writer
5
+ attr_reader :mapper, :cache
6
+
7
+ def initialize(opts)
8
+ @renderer_id =
9
+ opts[:renderer_id]
10
+ @cache = Cache.new(
11
+ opts[:s3_bucket_id],
12
+ opts[:s3_object_path]
13
+ )
14
+ @mapper = RenderMapper.new(
15
+ opts[:renderer_id],
16
+ opts[:view_path]
17
+ )
18
+ @lookup_table_name =
19
+ opts[:lookup_table_name]
20
+ end
21
+
22
+ def write(data, version = nil)
23
+ mapper.generate(data).each do |id, r|
24
+ store(id, r.render, location_for(id, version), data[:options])
25
+ end
26
+ end
27
+
28
+ private
29
+ def store(id, content, location, options)
30
+ cache.put(location, content)
31
+ lookup(id).write(options, location)
32
+ end
33
+
34
+ def lookup(component_id)
35
+ Lookup.create(@lookup_table_name, component_id)
36
+ end
37
+
38
+ def location_for(component_id, version = nil)
39
+ base_name = "#{@renderer_id}_#{component_id}"
40
+ version ? "#{base_name}_#{version}" : base_name
41
+ end
42
+
43
+ end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module Alephant
2
- VERSION = "0.0.9.9.1"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/env.rb CHANGED
@@ -3,8 +3,6 @@ $LOAD_PATH << File.dirname(__FILE__)
3
3
  require 'aws-sdk'
4
4
  require 'yaml'
5
5
 
6
- require 'alephant/util/string'
7
-
8
6
  config_file = File.join('config', 'aws.yaml')
9
7
 
10
8
  if File.exists? config_file
@@ -1,229 +1,83 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Alephant::Alephant do
4
- subject { Alephant::Alephant }
5
4
 
6
- describe "initialize(opts = {})" do
7
- before(:each) do
8
- sequencer = double()
9
- queue = double()
10
- cache = double()
11
- multi_renderer = double()
12
-
13
- Alephant::Sequencer.stub(:create).and_return(sequencer)
14
- Alephant::Queue.any_instance.stub(:initialize).and_return(queue)
15
- Alephant::Cache.any_instance.stub(:initialize).and_return(cache)
16
- Alephant::MultiRenderer.any_instance.stub(:initialize).and_return(multi_renderer)
17
- end
18
-
19
- it "sets specified options" do
20
- instance = subject.new({
21
- :s3_bucket_id => :s3_bucket_id,
22
- :s3_object_path => :s3_object_path,
23
- :s3_object_id => :s3_object_id,
24
- :table_name => :table_name,
25
- :sqs_queue_id => :sqs_queue_id,
26
- :component_id => :component_id,
27
- :sequence_id => :sequence_id
28
- })
29
-
30
- expect(instance.s3_bucket_id).to eq(:s3_bucket_id);
31
- expect(instance.s3_object_path).to eq(:s3_object_path);
32
- expect(instance.s3_object_id).to eq(:s3_object_id);
33
- expect(instance.table_name).to eq(:table_name);
34
- expect(instance.sqs_queue_id).to eq(:sqs_queue_id);
35
- expect(instance.component_id).to eq(:component_id);
36
- expect(instance.sequence_id).to eq(:sequence_id);
37
- end
38
-
39
- it "sets unspecified options to nil" do
40
- instance = subject.new
41
-
42
- expect(instance.s3_bucket_id).to eq(nil);
43
- expect(instance.s3_object_path).to eq(nil);
44
- expect(instance.s3_object_id).to eq(nil);
45
- expect(instance.table_name).to eq(nil);
46
- expect(instance.sqs_queue_id).to eq(nil);
47
- expect(instance.component_id).to eq(nil);
48
- expect(instance.sequence_id).to eq(nil);
49
- end
50
-
51
- context "initializes @sequencer" do
52
- it "with Sequencer.create(:table_name, @sqs_queue_id)" do
53
- Alephant::Sequencer
54
- .should_receive(:create)
55
- .with(:table_name, :sqs_queue_id, :sequence_id)
56
-
57
- instance = subject.new({
58
- :table_name => :table_name,
59
- :sqs_queue_id => :sqs_queue_id,
60
- :sequence_id => :sequence_id
61
- })
62
- end
63
- end
64
-
65
- context "initializes @queue" do
66
- it "with Queue.new(@sqs_queue_id)" do
67
- Alephant::Queue
68
- .should_receive(:new)
69
- .with(:sqs_queue_id)
70
-
71
- instance = subject.new({
72
- :sqs_queue_id => :sqs_queue_id
73
- })
74
- end
75
- end
76
-
77
- context "initializes @cache" do
78
- it "with Cache.new(@s3_bucket_id, @s3_object_path)" do
79
- Alephant::Cache
80
- .should_receive(:new)
81
- .with(:s3_bucket_id, :s3_object_path)
82
-
83
- instance = subject.new({
84
- :s3_bucket_id => :s3_bucket_id,
85
- :s3_object_path => :s3_object_path
86
- })
87
- end
88
- end
89
-
90
- context "initializes @multi_renderer" do
91
- it "MultiRenderer class to be initialized" do
92
- Alephant::MultiRenderer
93
- .should_receive(:new)
94
- .with('foo', 'components')
95
-
96
- instance = subject.new({
97
- :view_path => 'components',
98
- :component_id => 'foo'
99
- })
100
- end
101
- end
5
+ before(:each) do
6
+ Alephant::Writer.any_instance.stub(:initialize)
7
+ Alephant::Queue.any_instance.stub(:initialize)
8
+ Alephant::Parser.any_instance.stub(:initialize)
9
+ Alephant::Sequencer::Sequencer.any_instance.stub(:initialize)
102
10
  end
103
11
 
104
- describe "run!" do
105
- before(:each) do
106
- sequencer = double()
107
- queue = double()
108
- cache = double()
109
- multi_renderer = double()
110
-
111
- Alephant::Sequencer.stub(:create).and_return(sequencer)
112
- Alephant::Queue.any_instance.stub(:initialize).and_return(queue)
113
- Alephant::Cache.any_instance.stub(:initialize).and_return(cache)
114
- Alephant::MultiRenderer.any_instance.stub(:initialize).and_return(multi_renderer)
12
+ describe "#initialize(opts = {}, logger)" do
13
+ it "sets parser, sequencer, queue and writer" do
14
+ expect(subject.writer).to be_a Alephant::Writer
15
+ expect(subject.queue).to be_a Alephant::Queue
16
+ expect(subject.parser).to be_a Alephant::Parser
17
+ expect(subject.sequencer).to be_a Alephant::Sequencer::Sequencer
115
18
  end
19
+ end
116
20
 
21
+ describe "#run!" do
117
22
  it "returns a Thread" do
118
- instance = subject.new({
119
- :sqs_queue_id => :sqs_queue_id
120
- })
121
-
122
- expect(instance.run!).to be_a(Thread)
23
+ expect(subject.run!).to be_a(Thread)
123
24
  end
124
25
 
125
26
  it "calls @queue.poll" do
126
- instance = subject.new({
127
- :sqs_queue_id => :sqs_queue_id
128
- })
129
-
130
- instance.should_receive(:receive).with(:msg)
27
+ subject.should_receive(:receive).with(:msg)
131
28
 
132
29
  expect_any_instance_of(Alephant::Queue)
133
- .to receive(:poll)
134
- .and_yield(:msg)
30
+ .to receive(:poll)
31
+ .and_yield(:msg)
135
32
 
136
- t = instance.run!
33
+ t = subject.run!
137
34
  t.join
138
35
  end
139
36
  end
140
37
 
141
- describe "receive(msg)" do
142
- before(:each) do
143
- sequencer = double()
144
- queue = double()
145
- cache = double()
146
- multi_renderer = double()
147
-
148
- Alephant::Queue.any_instance.stub(:initialize).and_return(queue)
149
- Alephant::Cache.any_instance.stub(:initialize).and_return(cache)
150
- Alephant::MultiRenderer.any_instance.stub(:initialize).and_return(multi_renderer)
151
- end
152
-
153
- it "writes data to cache if sequential order is true" do
154
- data = "{ \"foo\":\"bar\" }"
155
-
156
- msg = double()
157
- msg.stub(:id).and_return(:id)
158
- msg.stub(:md5).and_return(:md5)
159
- msg.stub(:body).and_return(data)
160
-
161
-
162
- Alephant::Sequencer::Sequencer
163
- .any_instance
164
- .stub(:sequential?)
165
- .and_return(true)
166
-
167
- Alephant::Sequencer::SequenceTable
168
- .any_instance
169
- .stub(:create)
170
-
171
- Alephant::Sequencer::Sequencer
172
- .any_instance
173
- .stub(:set_last_seen)
174
-
175
- instance = subject.new
38
+ describe "#receive(msg)" do
39
+ subject { Alephant::Alephant.new }
176
40
 
177
- instance
178
- .should_receive(:write)
179
- .with(JSON.parse(data, :symbolize_names => true))
180
-
181
- instance.receive(msg)
182
- end
183
- end
184
-
185
- describe "write(data)" do
186
41
  before(:each) do
187
- sequencer = double()
188
- queue = double()
189
-
42
+ Alephant::Parser.any_instance
43
+ .stub(:parse)
44
+ .and_return(:parsed_msg)
45
+ Alephant::Sequencer::Sequencer
46
+ .any_instance.stub(:sequence_id_from)
47
+ .and_return(:sequence_id)
190
48
  Alephant::Sequencer::Sequencer
191
- .any_instance
192
- .stub(:initialize)
193
- .and_return(sequencer)
194
-
195
- Alephant::Queue
196
- .any_instance
197
- .stub(:initialize)
198
- .and_return(queue)
49
+ .any_instance.stub(:set_last_seen)
199
50
  end
200
51
 
201
- it "puts rendered data into the S3 Cache" do
202
- templates = {
203
- :foo => 'content',
204
- :bar => 'content'
205
- }
52
+ context "message is nonsequential" do
53
+ before(:each) do
54
+ Alephant::Sequencer::Sequencer
55
+ .any_instance.stub(:sequential?)
56
+ .and_return(false)
57
+ end
206
58
 
207
- Alephant::Cache
208
- .any_instance
209
- .should_receive(:put)
210
- .with(:foo, templates[:foo])
59
+ it "should not call write" do
60
+ Alephant::Writer.any_instance
61
+ .should_not_receive(:write)
211
62
 
212
- Alephant::Cache
213
- .any_instance
214
- .should_receive(:put)
215
- .with(:bar, templates[:bar])
63
+ subject.receive(:msg)
64
+ end
65
+ end
216
66
 
217
- Alephant::MultiRenderer
218
- .any_instance
219
- .stub(:render)
220
- .and_return(templates)
67
+ context "message is sequential" do
68
+ before(:each) do
69
+ Alephant::Sequencer::Sequencer
70
+ .any_instance.stub(:sequential?)
71
+ .and_return(true)
72
+ end
221
73
 
222
- instance = subject.new({
223
- :s3_object_id => :s3_object_id
224
- })
74
+ it "calls writer with a parsed message and sequence_id" do
75
+ Alephant::Writer.any_instance
76
+ .should_receive(:write).with(:parsed_msg, :sequence_id)
225
77
 
226
- instance.write(:content)
78
+ subject.receive(:msg)
79
+ end
227
80
  end
228
81
  end
82
+
229
83
  end