test.rb in mirage-3.0.0.alpha.6 vs test.rb in mirage-3.0.0.alpha.7
- old
+ new
@@ -1,50 +1,19 @@
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'})
-
-require 'ostruct'
-class UserServiceProfile
+class UserProfile
extend Mirage::Template::Model
- endpoint 'Users'
+ endpoint '/users'
+ http_method :get
+ status 200
+ content_type 'application/json'
+ required_body_content %w(leon davis)
- def initialize persona
- super
- required_parameters[:token] = persona.token
- @persona = persona
- end
+ builder_methods :firstname, :lastname, :age
- def value
- {name: @persona.name}.to_json
+ def body
+ {firstname: firstname, lastname: lastname, age: age}.to_json
end
end
-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
+mirage = Mirage.start
+mirage.put UserProfile.new.firstname('leon').lastname('davis').age(30)
\ No newline at end of file