test.rb in mirage-3.0.0.alpha.4 vs test.rb in mirage-3.0.0.alpha.5
- old
+ new
@@ -1,18 +1,50 @@
require './lib/mirage/client'
+#
+#class ServiceNowResponse
+# extend Mirage::Template::Model
+#
+# endpoint 'service_now'
+#
+# builder_methods :this,:that
+#
+# def value
+# "my value : #{this}, #{that}"
+# end
+#end
+#
+Mirage.stop
+mirage = Mirage.start
+#mirage.put ServiceNowResponse.new.this('foo').that('bar')
+#mirage.put ServiceNowResponse.new.this('foo').that('bar').required_body_content(%w(hello world))
+#mirage.put ServiceNowResponse.new.this('foo').that('bar').required_parameters({:name => 'leon'})
-class ServiceNowResponse
+require 'ostruct'
+class UserServiceProfile
extend Mirage::Template::Model
- endpoint 'service_now'
+ endpoint 'Users'
- builder_methods :this,:that
+ def initialize persona
+ super
+ required_parameters[:token] = persona.token
+ @persona = persona
+ end
def value
- "my value : #{this}, #{that}"
+ {name: @persona.name}.to_json
end
end
-Mirage.stop
-mirage = Mirage.start
-mirage.put ServiceNowResponse.new.this('foo').that('bar')
-mirage.put ServiceNowResponse.new.this('foo').that('bar').required_body_content(%w(hello world))
+leon = OpenStruct.new(
+ :name => 'leon',
+ :token => '1234'
+)
+
+mirage.clear
+
+
+leons_user_profile = UserServiceProfile.new leon
+mirage.put leons_user_profile do
+ status 404
+ method :get
+end