Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a test about modules inclusion

  • Loading branch information...
commit d111420a6509a04e293e0e39ab7624ef082ac487 1 parent 4ace812
@jhchabran jhchabran authored
Showing with 39 additions and 0 deletions.
  1. +39 −0 spec/vintner/representer_spec.rb
View
39 spec/vintner/representer_spec.rb
@@ -177,6 +177,45 @@ class Dummy
end
end
+ describe "Including a module" do
+ before :each do
+ @hash = {:meta=>{:title => "test", :stuff => "stuff"}}
+ @model = Struct.new(:formatted_title, :stuff).new("test", "stuff")
+
+ module Stuff
+ def stuff
+ "stuff"
+ end
+ end
+
+ class Dummy
+ include Vintner::Representer
+ extend Stuff
+
+ property :title do
+ get do |model|
+ model.formatted_title
+ end
+
+ set do |model, value|
+ model.formatted_title = value
+ end
+ end
+
+ representation do |json|
+ json.meta do |meta|
+ meta.property :title
+ meta.stuff stuff
+ end
+ end
+ end
+ end
+
+ it "should call stuff" do
+ Dummy.new(@model).to_json.should include("stuff")
+ end
+ end
+
describe "Nested collections" do
before :each do
class Dummy
Please sign in to comment.
Something went wrong with that request. Please try again.