spec/open311_spec.rb in open311-0.1.2 vs spec/open311_spec.rb in open311-0.2.0

- old
+ new

@@ -1,7 +1,25 @@ require 'helper' +describe Open311 do + after do + Open311.reset + end + + describe ".respond_to?" do + it "should return true if method exists" do + Open311.respond_to?(:new, true).should be_true + end + end + + describe ".new" do + it "should be a Open311::Client" do + Open311.new.should be_a Open311::Client + end + end +end + describe Open311, ".service_list" do before do Open311.configure do |config| config.endpoint = 'http://api.dc.org/open311/v2_dev/' config.jurisdiction = 'dc.gov' @@ -106,30 +124,29 @@ config.endpoint = 'http://blasius.ws:3003/open311/' config.jurisdiction = 'dc.gov' config.api_key = 'xyz' end - @service_request_params = { + stub_request(:post, 'blasius.ws:3003/open311/requests.xml'). + to_return(:body => fixture('post_service_request.xml'), :headers => {'Content-Type' => 'text/xml; charset=utf-8'}) + end + + it "should return the correct results" do + service_request_params = { :service_code => '001', :address_string => '1234 5th street', :email => 'smit222@sfgov.edu', :device_id => 'tt222111', :account_id => '12345', :first_name => 'john', :last_name => 'smith', :phone => '111111111', :description => 'A large sinkhole is destroying the street', - :media_url => 'http://farm3.static.flickr.com/2002/2212426634_5ed477a060.jpg', + :media_url => 'http://farm5.static.flickr.com/4057/4660699337_9aa4541ce1_o.jpg', :lat => '38.888486', :long => '-77.020179', } - stub_request(:post, 'blasius.ws:3003/open311/requests.xml'). - with(:body => {:jurisdiction_id => 'dc.gov', :api_key => 'xyz'}.merge(@service_request_params)). - to_return(:body => fixture('post_service_request.xml'), :headers => {'Content-Type' => 'text/xml; charset=utf-8'}) - end - - it "should return the correct results" do - service_request_response = Open311.post_service_request(@service_request_params) + service_request_response = Open311.post_service_request(service_request_params) service_request_response.service_request_id.should == '293944' end end describe Open311, ".request_id_from_token" do