mirror of
https://github.com/samsonjs/grape-active_model_serializers.git
synced 2026-03-25 08:45:55 +00:00
Seperates out spec_fakes.rb into support directory"
This commit is contained in:
parent
251144d257
commit
57335b7bd9
6 changed files with 30 additions and 31 deletions
|
|
@ -1,5 +1,8 @@
|
|||
require 'spec_helper'
|
||||
require 'spec_fakes'
|
||||
require 'support/models/user'
|
||||
require 'support/models/blog_post'
|
||||
require 'support/serializers/user_serializer'
|
||||
require 'support/serializers/blog_post_serializer'
|
||||
require "grape-active_model_serializers"
|
||||
|
||||
describe Grape::ActiveModelSerializers do
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
|
||||
class User
|
||||
include ActiveModel::SerializerSupport
|
||||
attr_accessor :first_name, :last_name, :password, :email
|
||||
|
||||
def initialize(params={})
|
||||
params.each do |k,v|
|
||||
instance_variable_set("@#{k}", v) unless v.nil?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class UserSerializer < ActiveModel::Serializer
|
||||
attributes :first_name, :last_name
|
||||
end
|
||||
|
||||
class BlogPost
|
||||
include ActiveModel::SerializerSupport
|
||||
attr_accessor :title, :body
|
||||
|
||||
def initialize(params={})
|
||||
params.each do |k,v|
|
||||
instance_variable_set("@#{k}", v) unless v.nil?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class BlogPostSerializer < ActiveModel::Serializer
|
||||
attributes :title, :body
|
||||
end
|
||||
10
spec/support/models/blog_post.rb
Normal file
10
spec/support/models/blog_post.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
class BlogPost
|
||||
include ActiveModel::SerializerSupport
|
||||
attr_accessor :title, :body
|
||||
|
||||
def initialize(params={})
|
||||
params.each do |k,v|
|
||||
instance_variable_set("@#{k}", v) unless v.nil?
|
||||
end
|
||||
end
|
||||
end
|
||||
10
spec/support/models/user.rb
Normal file
10
spec/support/models/user.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
class User
|
||||
include ActiveModel::SerializerSupport
|
||||
attr_accessor :first_name, :last_name, :password, :email
|
||||
|
||||
def initialize(params={})
|
||||
params.each do |k,v|
|
||||
instance_variable_set("@#{k}", v) unless v.nil?
|
||||
end
|
||||
end
|
||||
end
|
||||
3
spec/support/serializers/blog_post_serializer.rb
Normal file
3
spec/support/serializers/blog_post_serializer.rb
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
class BlogPostSerializer < ActiveModel::Serializer
|
||||
attributes :title, :body
|
||||
end
|
||||
3
spec/support/serializers/user_serializer.rb
Normal file
3
spec/support/serializers/user_serializer.rb
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
class UserSerializer < ActiveModel::Serializer
|
||||
attributes :first_name, :last_name
|
||||
end
|
||||
Loading…
Reference in a new issue