test/test_helper.rb in eroi-0.0.1 vs test/test_helper.rb in eroi-0.1.0

- old
+ new

@@ -19,60 +19,16 @@ options.merge!({ :status => status }) unless status.nil? FakeWeb.register_uri(:get, url, options) end -def user_token - 'test_user_token' +def fixture(key) + yaml_data = YAML.load(File.read(File.join(File.dirname(__FILE__), 'fixtures.yml'))) + symbolize_keys(yaml_data) + yaml_data[key] end -def api_password - 'test_api_password' -end - -def successful_post_response - <<-EOF -<Compiled>Yes</Compiled> -<DBConnect>OK</DBConnect> -<EditionSuccess>MailingListName_someEditionName</EditionSuccess> -<ImportRecords>1</ImportRecords> -<ExistingRecords>1526</ExistingRecords> -<FinalCompleted>1</FinalCompleted> -<Duplicates>1</Duplicates> -<InvalidLists>0</InvalidLists> -<Triggers></Triggers> -<XMLUpload>Complete</XMLUpload> - EOF -end - -def successful_get_response - <<-EOF -<Retrieve> - <Record> - <rec>523</rec> - <Email>someone@somecompany.com</Email> - <Firstname>Joe</Firstname> - <Lastname>Somebody</Lastname> - <Company>Some Company</Company> - <User1>some data here</User1> - <User2>We'll put more data here</User2> - <Notes>And we'll put more notes here</Notes> - <Edition Name="SomeEdition"> - <Sent Format="YYYYMMDDhhmm">20030913143010</Sent> - <Read>5</Read> - <Click URL="http://www.somelink.com">3</Click> - <Click URL="http://www.anotherlink.com/page.htm">1</Click> - <S2F>2</S2F> - </Edition> - <Event id="1" ListEdition="somelist_someedition" Date="2003-Nov-11">Sent</Event> - </Record> - <UserFieldDefinitions> - <UserField Field="User1" Type="Text">State</UserField> - <UserField Field="User2" Type="Text">City</UserField> - </UserFieldDefinitions> - </Retrieve> - EOF -end - -def unsuccessful_get_response(code = 1) - "<Retrieve><ErrorCode>#{code}</ErrorCode></Retrieve>" +def symbolize_keys(hash) + return unless hash.is_a?(Hash) + hash.symbolize_keys! + hash.each{|k,v| symbolize_keys(v)} end