Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require_relative 'Craigdroid.rb'
- require 'test/unit'
- require 'rack/test'
- ENV['RACK_ENV'] = 'test'
- class PostTest < Test::Unit::TestCase
- include Rack::Test::Methods
- def app
- Sinatra::Application
- end
- def test_post
- testHash = {:bar => 'baz'}
- post '/testpost', testHash.to_json, "CONTENT_TYPE" => "application/json"
- # validate response here
- assert last_response.ok?
- expectHash = {:bar => 'baz'}.to_json
- assert_equal expectHash, last_response.body
- end
- def test_addcat
- testHash = {:foo => 'baz'}
- post '/addcat', testHash.to_json, "CONTENT_TYPE" => "application/json"
- # validate response here
- assert last_response.ok?
- expectHash = {:foo => 'baz'}.to_json
- assert_equal expectHash, last_response.body
- end
- def test_addpost
- testHash = {:dateCreated => 1309508060474,:dateModified => 1309508065331,:description => 'second hand book for sale',:id => 0,:location => 'makati',:price => 0,:subcategory => [{:category => [{:id => 1,:name => 'Community',:postDisclaimer => nil,:priceAware => false,:searchDisclaimer => nil }],:id => 1,:name => 'subcategory Community - 1' }], :title => 'lord of the rings', :user => [{ :emailAddress => nil, :msisdn => '639194447777', :password => 'password' }]}
- post '/addpost',testHash.to_json, "CONTENT_TYPE" => "application/json"
- # validate response here
- assert last_response.ok?
- expectHash = {:dateCreated => 1309508060474,:dateModified => 1309508065331,:description => 'second hand book for sale',:id => 0,:location => 'makati',:price => 0,:subcategory => [{:category => [{:id => 1,:name => 'Community',:postDisclaimer => nil,:priceAware => false,:searchDisclaimer => nil }],:id => 1,:name => 'subcategory Community - 1' }], :title => 'lord of the rings', :user => [{ :emailAddress => nil, :msisdn => '639194447777', :password => 'password' }]}.to_json
- assert_equal expectHash, last_response.body
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement