-
Notifications
You must be signed in to change notification settings - Fork 3
/
spec_helper.rb
45 lines (36 loc) · 941 Bytes
/
spec_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'rspec'
require 'feedx'
require 'google/protobuf'
Google::Protobuf::DescriptorPool.generated_pool.build do
add_message 'com.blacksquaremedia.feedx.testcase.Message' do
optional :title, :string, 1
end
end
module Feedx
module TestCase
Message = Google::Protobuf::DescriptorPool.generated_pool.lookup('com.blacksquaremedia.feedx.testcase.Message').msgclass
class Model
attr_reader :title
def initialize(title)
@title = title
end
def to_pb(*)
Feedx::TestCase::Message.new title: @title
end
def ==(other)
title == other.title
end
alias eql? ==
def updated_at
Time.at(1515151515).utc
end
def from_json(data, *)
hash = ::JSON.parse(data)
@title = hash['title'] if hash.is_a?(Hash)
end
def to_json(*)
::JSON.dump(title: @title, updated_at: updated_at)
end
end
end
end