<?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>Slash Dot Dash &#187; Ruby</title> <atom:link href="http://www.slashdotdash.net/category/ruby/feed/" rel="self" type="application/rss+xml" /><link>http://www.slashdotdash.net</link> <description>Rolling on Rails</description> <lastBuildDate>Tue, 28 Sep 2010 15:49:37 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.2.1</generator> <item><title>Rails 3, RSpec and Cucumber setup</title><link>http://www.slashdotdash.net/2010/09/27/rails-3-rspec-and-cucumber-setup/</link> <comments>http://www.slashdotdash.net/2010/09/27/rails-3-rspec-and-cucumber-setup/#comments</comments> <pubDate>Mon, 27 Sep 2010 19:53:07 +0000</pubDate> <dc:creator>Ben</dc:creator> <category><![CDATA[Ruby]]></category> <category><![CDATA[Ruby on Rails]]></category> <guid
isPermaLink="false">http://www.slashdotdash.net/?p=1247</guid> <description><![CDATA[This quick how-to runs through creating a new Rails 3 application with both RSpec and Cucumber for testing (rather than Test::Unit). Rails 3 requires (the somewhat confusingly versioned) RSpec 2 and rspec-rails. Similarly, Cucumber uses cucumber-rails for bootstrapping your Rails app and provides generators for creating features. Install RSpec 2 sudo gem install rspec-rails --pre [...]]]></description> <content:encoded><![CDATA[<p>This quick how-to runs through creating a new Rails 3 application with both RSpec and Cucumber for testing (rather than Test::Unit).</p><p>Rails 3 requires (the somewhat confusingly versioned) <a
href="http://rspec.info/">RSpec 2</a> and <a
href="http://github.com/rspec/rspec-rails">rspec-rails</a>. Similarly, Cucumber uses <a
href="http://github.com/aslakhellesoy/cucumber-rails">cucumber-rails</a> for bootstrapping your Rails app and provides generators for creating features.</p><h2>Install RSpec 2</h2><pre><code>sudo gem install rspec-rails --pre</code></pre><h2>Install Cucumber</h2><pre><code>sudo gem install cucumber-rails</code></pre><h2>Create a new Rails 3 application</h2><p>Ensure you have the latest version of Rails 3 installed then create a new application, skipping creation of the test directory since we&#8217;ll be using RSpec and Cucumber (with spec and features) instead.</p><pre><code>rails new <app-name> --skip-testunit</code></pre><p>Add <code>rspec-rails</code> to the <code>:test</code> and <code>:development</code> groups to the Gemfile.</p><pre><code>group :test, :development do
    gem 'rspec-rails', '>= 2.0.0.beta.22'
end</code></pre><p>Add <code>cucumber-rails</code> and dependencies to the <code>:cucumber</code> group in the Gemfile:</p><pre><code>group :cucumber do
    gem 'capybara'
    gem 'database_cleaner'
    gem 'cucumber-rails'
    gem 'cucumber'
    gem 'spork'
    gem 'launchy'
end</code></pre><p>Ensure all gems are installed by using Bundler:</p><pre><code>sudo bundle install</code></pre><p>Then install the RSpec extensions (creates the <code>spec</code> directory and creates a rake task):</p><pre><code>rails generate rspec:install</code></pre><p>Now we can specify that Rails itself uses RSpec when running generators by adding the following inside config/applicaton.rb:</p><pre><code>config.generators do |g|
  g.test_framework :rspec
end</code></pre><p>Next, bootstrap your Rails app, for Cucumber:</p><pre><code>rails generate cucumber:install --rspec --capybara</code></pre><p>That&#8217;s it! Now the following rake tasks exist to execute your specs or cucumber features (by default <code>rake</code> will execute both).</p><pre><code>rake spec
rake cucumber</code></pre>]]></content:encoded> <wfw:commentRss>http://www.slashdotdash.net/2010/09/27/rails-3-rspec-and-cucumber-setup/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Ruby Tidbit: Timeout code execution</title><link>http://www.slashdotdash.net/2008/02/15/ruby-tidbit-timeout-code-execution/</link> <comments>http://www.slashdotdash.net/2008/02/15/ruby-tidbit-timeout-code-execution/#comments</comments> <pubDate>Fri, 15 Feb 2008 00:39:00 +0000</pubDate> <dc:creator>Ben</dc:creator> <category><![CDATA[Ruby]]></category> <category><![CDATA[Ruby on Rails]]></category> <guid
isPermaLink="false"></guid> <description><![CDATA[Just a small tip, if you wish to ensure a snippet of Ruby code doesn&#8217;t run for too long you can use the timeout function. You might want to do this when making a request to a remote server with net/http for example. timeout.rb A way of performing a potentially long-running operation in a thread, [...]]]></description> <content:encoded><![CDATA[<p>Just a small tip, if you wish to ensure a snippet of Ruby code doesn&#8217;t run for too long you can use the timeout function. You might want to do this when making a request to a remote server with <code>net/http</code> for example.</p><p><a
href="http://www.ruby-doc.org/stdlib/libdoc/timeout/rdoc/index.html">timeout.rb</a></p><blockquote><p>A way of performing a potentially long-running operation in a thread, and terminating it‘s execution if it hasn‘t finished within fixed amount of time.</p></blockquote><p>Here&#8217;s a quick example using the excellent <a
href="http://rfeedparser.rubyforge.org/">rFeedParser</a> (Universal Feed Parser in Ruby) to fetch an <span
class="caps">RSS</span> feed.</p><pre>
require 'timeout'
require 'zlib'
require 'rubygems'
require 'rfeedparser'
fp = nil
begin
  # Don't take longer than 20 seconds to retrieve &#38; parse an RSS feed
  Timeout::timeout(20) do
    fp = FeedParser.parse("http://feeds.feedburner.com/slashdotdash")
  end
rescue Timeout::Error
  # Too slow!!
end
</pre>]]></content:encoded> <wfw:commentRss>http://www.slashdotdash.net/2008/02/15/ruby-tidbit-timeout-code-execution/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
