<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sean&#039;s Blog &#187; testing</title>
	<atom:link href="http://seanbehan.com/tag/testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanbehan.com</link>
	<description>Web Programming, Ruby on Rails, Wordpress, PHP from Burlington, Vermont</description>
	<lastBuildDate>Wed, 08 Sep 2010 16:10:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Manage Fixtures with Yaml DB Plugin for Rails</title>
		<link>http://seanbehan.com/ruby-on-rails/manage-fixtures-with-yaml-db-plugin-for-rails/</link>
		<comments>http://seanbehan.com/ruby-on-rails/manage-fixtures-with-yaml-db-plugin-for-rails/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 21:20:48 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[fixtures]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[yaml]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=527</guid>
		<description><![CDATA[Get the plugin like so&#8230; script/plugin install git://github.com/adamwiggins/yaml_db.git This command will dump your data rake db:data:dump And load it back rake db:data:load Beautiful More info here http://blog.heroku.com/archives/2007/11/23/yamldb_for_databaseindependent_data_dumps/ and http://stackoverflow.com/questions/490507/best-way-to-export-a-database-table-to-a-yaml-file]]></description>
			<content:encoded><![CDATA[<p>Get the plugin like so&#8230;</p>
<pre>
script/plugin install git://github.com/adamwiggins/yaml_db.git
</pre>
<p>This command will dump your data</p>
<pre>
rake db:data:dump
</pre>
<p>And load it back</p>
<pre>
rake db:data:load
</pre>
<p>Beautiful <img src='http://seanbehan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  More info here</p>
<p>http://blog.heroku.com/archives/2007/11/23/yamldb_for_databaseindependent_data_dumps/</p>
<p>and</p>
<p>http://stackoverflow.com/questions/490507/best-way-to-export-a-database-table-to-a-yaml-file</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/manage-fixtures-with-yaml-db-plugin-for-rails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>paypal ipn simulator</title>
		<link>http://seanbehan.com/business/paypal-ipn-simulator/</link>
		<comments>http://seanbehan.com/business/paypal-ipn-simulator/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 16:17:28 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[ipn]]></category>
		<category><![CDATA[paypal]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://bseanvt.wordpress.com/?p=51</guid>
		<description><![CDATA[If you use the Paypal sandbox you&#8217;ll notice that there is an IPN Simulator test tool. You must be logged to use it. This tool lets you test an IPN handler script for your application. If your script is not correct and you try to send a test IPN transaction the simulator will spit out [...]]]></description>
			<content:encoded><![CDATA[<p>If you use the Paypal sandbox you&#8217;ll notice that there is an IPN Simulator test tool. You must be logged to use it. This tool lets you test an IPN handler script for your application. If your script is not correct and you try to send a test IPN transaction the simulator will spit out a misleading error message. It will report</p>
<p><strong>IPN delivery failed. Unable to connect to the specified URL. Please verify the URL and try again. </strong></p>
<p>What this actually means is that your server was contacted and your script failed! If you&#8217;re using the wrong URL then this error message will apply, however. If you are using the right URL but you have a handler script that fails or is not right in some fashion, it seems logical to report the details of the failure! At the very least, it would be nice to hear</p>
<p><strong>Indeed this URL address is correct, we said hello, but you refused our &#8216;handshake&#8217;. How rude! Link to more info&#8230;<br />
</strong></p>
<p>When I first tried out the simulator I assumed that the problem was with my DNS. I was testing against a subdomain that didn&#8217;t have a cname set up. I wasn&#8217;t too sure though if this was the problem. I could visit the URL I specified in my web browser and ping my domain, etc. I eventually got it working after checking some log files. I had to parse my apache logs to fnd that the IPN parameters were indeed posted to my server. This led me to the error in my code.</p>
<p>I&#8217;m not blaming Paypal 100%. The error was ultimately on my end. Nonetheless, Paypal did not aid in my troubleshooting endeavor. Instead they exacerbated the problem with an error message that made some assumptions about how I was using their tool. The first being that I understood the IPN protocol. The second, that I understood the way the IPN simulator is meant to work and the protocol under which it operates. Not my error because there is no documentation for the test tool.</p>
<p>Having to parse log files was a needless step in this otherwise simple remote request. Another issue that confounded the problem were the Paypal forums. Some people seemed to think that the IPN simulator was not even operational. Could this be because of misleading error messages?</p>
<p>In my opinion the Paypal documentation is thorough, however, very poorly organized. It seems also that a lot of the Paypal core docs are available in multiple/too many places. I&#8217;ve seen the IPN documentation in at least 3 or 4 different areas on the site. Each page adds more information or has a slightly different verbiage to explain the same problem.  Not to mention, there are way too many PDFs available for download! PDFs are great, but the content, organization and display is different from same documentation online.</p>
<p>At any rate, here is a quick Rails controller that will at least get your IPN simulated transactions to return success!</p>
<pre>
require 'uri'
require 'net/http'
require 'net/https'
class PaymentsController &lt; ApplicationController
  #skip this check b/c post comes in from paypal
  protect_from_forgery :except =&gt; [:ipn]
  def ipn
    begin
      if request.post?

      #you need to post back to paypal the name/value string
      #in the same order received w/added cmd=_notify-validate
      from_pp = request.raw_post
      data = from_pp + "&amp;cmd=_notify-validate"
      url = URI.parse 'https://sandbox.paypal.com/cgi-bin/webscr'
      http = Net:HTTP.new url.host, url.port
      http.use_ssl = true

     response, data = http.post url.path, data, {
        'Content-Type' =&gt; 'application/x-www-for-urlencoded' }
      end
     rescue Exception =&gt; e
     logger.info("Error: paypal transaction #{e.message}")
    end
  end
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/business/paypal-ipn-simulator/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>rails fixtures: using the right timestamp</title>
		<link>http://seanbehan.com/programming/rails-fixtures-using-the-right-timestamp/</link>
		<comments>http://seanbehan.com/programming/rails-fixtures-using-the-right-timestamp/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 18:04:40 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://bseanvt.wordpress.com/?p=35</guid>
		<description><![CDATA[Fixtures in Rails allow you to quickly and easily populate a database with sample data. They are great when testing your app and you need to test against a condition that will rely on a certain preexisting data point. Fixtures are located in your RAILS_ROOT/test/fixtures/model.yml where model.yml is the model in question. A sample fixture [...]]]></description>
			<content:encoded><![CDATA[<p>Fixtures in Rails allow you to quickly and easily populate a database with sample data. They are great when testing your app and you need to test against a condition that will rely on a certain preexisting data point.</p>
<p>Fixtures are located in your RAILS_ROOT/test/fixtures/model.yml where model.yml is the model in question.<br />
A sample fixture *note: yml files require consistent indentation!</p>
<pre>one:
  id: 1
  title: my sample fixture
  description: this is an example of a fixture
  created_at: &lt;%= 2.days.from_now.to_s :db %&gt;</pre>
<p>You can load your fixture data like so</p>
<pre>rake db:fixtures:load</pre>
<p>This assumes that you have a schema migration already raked &lt;code&gt;rake db:migrate&lt;/code&gt; and that the attributes in your fixtures map to the correct attributes in your schema. You&#8217;ll get an error otherwise. You can also specify the environment when you run your rakes like so&#8230;</p>
<pre>rake db:fixtures:load RAILS_ENV="production"</pre>
<p>As you may have noticed, you can execute Ruby code in your fixtures if you place your code in the normal erb tags<br />
&lt;%= %&gt;. Furthermore, you have access to the Rails api, which gives you handy methods like 2.days.ago.to_s. When creating your fixtures you might be tempted to use &lt;%= Time.now %&gt; for you created_at, updated_at fields. Don&#8217;t! Instead, use the rails api like so&#8230; &lt;%= 1.month.from_now.to_s :db %&gt; This stores the value in the same way that Rails handles time stamping your models. Otherwise, you might find parts of your application break when running tests against your fixtures because the data types do not correspond.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/programming/rails-fixtures-using-the-right-timestamp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
