<?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>Hungry Machine &#187; mock</title>
	<atom:link href="http://blog.hungrymachine.com/tag/mock/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hungrymachine.com</link>
	<description>The guys behind LivingSocial</description>
	<lastBuildDate>Sun, 25 Oct 2009 15:08:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using mocks at the early stage of FB app development</title>
		<link>http://blog.hungrymachine.com/2007/08/15/using-mocks-at-the-early-stage-of-fb-app-development/</link>
		<comments>http://blog.hungrymachine.com/2007/08/15/using-mocks-at-the-early-stage-of-fb-app-development/#comments</comments>
		<pubDate>Wed, 15 Aug 2007 12:50:00 +0000</pubDate>
		<dc:creator>val</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[mock]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">blog.hungrymachine.com/2007/08/23/using-mocks-at-the-early-stage-of-fb-app-development</guid>
		<description><![CDATA[Developing applications for Facebook is a pain. The tunnel approach helps a lot to ease that pain but even then I prefer to start a FB app as a regular application, polish the logic, and then convert it to the Facebook one by adding FBML and such. At the early stages of the development I [...]]]></description>
			<content:encoded><![CDATA[<p>Developing applications for Facebook is a pain. <a href="http://rfacebook.rubyforge.org/tunnel.html">The tunnel approach</a> helps a lot to ease that pain but even then I prefer to start a FB app as a regular application, polish the logic, and then convert it to the Facebook one by adding <span class="caps">FBML</span> and such. At the early stages of the development I have the <em>mocked</em> parameter in <em>config/facebook.yml</em> set to <strong>true</strong> and keep this code in <em>config/initializers/facebook.rb</em>:</p>
<div class="CodeRay">
<div class="code">
<pre><span style="color:#036; font-weight:bold">PERSON_PROFILE_URL</span> = <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">http://www.facebook.com/profile.php</span><span style="color:#710">&quot;</span></span>

<span style="color:#036; font-weight:bold">FACEBOOK_CONFIG</span> = <span style="color:#036; font-weight:bold">YAML</span>.load_file(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="background-color:#fff0f0"><span style="color:#710">#{</span><span style="color:#036; font-weight:bold">RAILS_ROOT</span><span style="color:#710">}</span></span><span style="color:#D20">/config/facebook.yml</span><span style="color:#710">&quot;</span></span>)[<span style="color:#036; font-weight:bold">RAILS_ENV</span>] || {}

<span style="color:#080; font-weight:bold">if</span> <span style="color:#036; font-weight:bold">FACEBOOK_CONFIG</span>[<span style="background-color:#fff0f0"><span style="color:#710">'</span><span style="color:#D20">mocked</span><span style="color:#710">'</span></span>]

  <span style="color:#080; font-weight:bold">class</span> <span style="color:#B06; font-weight:bold">Facebook::FBMLController</span>

    require <span style="background-color:#fff0f0"><span style="color:#710">'</span><span style="color:#D20">ostruct</span><span style="color:#710">'</span></span>
    <span style="color:#036; font-weight:bold">FB_SESSION</span> = <span style="color:#036; font-weight:bold">OpenStruct</span>.new(<span style="color:#A60">:session_user_id</span> =&gt; <span style="color:#00D; font-weight:bold">1</span>, <span style="color:#A60">:session_key</span> =&gt; <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">12345</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:is_valid?</span> =&gt; <span style="color:#038; font-weight:bold">true</span>)

    <span style="color:#080; font-weight:bold">def</span> <span style="color:#06B; font-weight:bold">fbsession</span>; <span style="color:#036; font-weight:bold">FB_SESSION</span>; <span style="color:#080; font-weight:bold">end</span>

    <span style="color:#080; font-weight:bold">def</span> <span style="color:#06B; font-weight:bold">require_facebook_install</span>; <span style="color:#038; font-weight:bold">true</span>; <span style="color:#080; font-weight:bold">end</span>

    <span style="color:#080; font-weight:bold">def</span> <span style="color:#06B; font-weight:bold">redirect_to</span>(url); <span style="color:#080; font-weight:bold">super</span>; <span style="color:#080; font-weight:bold">end</span>

    <span style="color:#080; font-weight:bold">def</span> <span style="color:#06B; font-weight:bold">url_for</span>(*params); <span style="color:#080; font-weight:bold">super</span>; <span style="color:#080; font-weight:bold">end</span>

  <span style="color:#080; font-weight:bold">end</span>

  <span style="color:#080; font-weight:bold">module</span> <span style="color:#B06; font-weight:bold">Facebook::Acts::FbUser</span>
    <span style="color:#080; font-weight:bold">module</span> <span style="color:#B06; font-weight:bold">InstanceMethods</span>
      <span style="color:#080; font-weight:bold">def</span> <span style="color:#06B; font-weight:bold">friends</span>
        (<span style="color:#038; font-weight:bold">self</span>.class.find(<span style="color:#A60">:all</span>) - [ <span style="color:#038; font-weight:bold">self</span> ]).collect(&amp;<span style="color:#A60">:uid</span>)
      <span style="color:#080; font-weight:bold">end</span>
    <span style="color:#080; font-weight:bold">end</span>
  <span style="color:#080; font-weight:bold">end</span>

<span style="color:#080; font-weight:bold">end</span></pre>
</div>
</div>
<p>It mocks out just enough of <a href="http://code.google.com/p/facebook-rails/">Facebook on Rails</a> functionality to use <em>FBMLController</em> and <em>acts_as_fb_user</em> from the beginning without Facebook backend.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hungrymachine.com/2007/08/15/using-mocks-at-the-early-stage-of-fb-app-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
