Skip to content

Instantly share code, notes, and snippets.

View barinek's full-sized avatar

Barinek barinek

  • Initial Capacity
  • Boulder, CO
View GitHub Profile
source 'http://rubygems.org'
gem 'rails', '3.0.0'
gem 'mysql2'
gem "rspec-rails", '2.0.0.beta.22'
gem "rspec", '2.0.0.beta.22'
gem 'capybara', '0.3.9'
gem 'database_cleaner', '0.5.2'
gem 'cucumber-rails', '0.3.2'
gem 'cucumber', '0.9.0'
class AppBuilder < Rails::AppBuilder
include Thor::Actions
include Thor::Shell
def test
append_test_gems
rspec
cucumber
jasmine
end
A benefit of test driving Rails applications, especially underlying
model behaviors, is the documentation that results from test driving.
When I want to quickly ramp up on a new Gem, I always look at the
test suite for insight into how the Gem or subsystem works.
I've been diving into (http://cukes.info/, "Cucumber") recently
and have been a long time user of (http://fitnesse.org/ "FitNesse"),
although with Cucumber I've recently watched developers opt to not
write unit tests and replace their test suite entirely with Cucumber features.
@barinek
barinek / Dependency musings
Created August 27, 2010 17:56
Dependency musings
Recently there has been a lot of discussion around project dependencies. As a result,
it has been pretty hard to decide when and if to include a new gem into a
project.
Overall, I think I tend to weigh in heavier on the side of exclude everything possible
except what is absolutely necessary. That being said, here's the mental check list I
tend to work through when deciding whether or not to include a dependency.
Is it something that I really need? Is it something that I can write myself?
@barinek
barinek / Fast user switching with Devise
Created August 27, 2010 14:46
Fast user switching with Devise
Ever wondered how to login as another user within Devise?
Recently we had a feature request that would provide Admins with the ability
to sign is as another user. You could imagine live demonstrations or even production
support calls where you would like to be signed in as another user, yet not
have to ask for or decrypt their current password. After stewing for a bit, we found a
pretty nice solution with Devise.
Here's the Cucumber feature...
@barinek
barinek / Nesting and authenticating resque-web on ey-cloud
Created August 27, 2010 14:33
Nesting and authenticating resque-web on ey-cloud
Wouldn't it then be nice to include the resque-web interface underneath your current application's url.
Wouldn't it be nice to use the same authentication mechanism that your web application uses?
Here's a solution that we used on a recent Rails 2.3 ey-cloud project that accomplished both goals.
First, we created a simple resque_web.ru file within our Rails 2.3 project. In this example we used the same Warden SSO authentication mechanism and fired up the resque-web server from the new mapping.
<pre>
@barinek
barinek / Cucumber performance improvements with Devise Token Authenticatable
Created August 27, 2010 14:30
Cucumber performance improvements with Devise Token Authenticatable
We're using Devise's token_authenticatable to improve Cucumber test suite performance.
Here's an example feature
Scenario: I would like to edit a user account
Given I am logged in as an admin user
...
And here's the step
@barinek
barinek / Reindexing Solr from Cucumber
Created August 27, 2010 14:27
Reindexing Solr from Cucumber
Here's a quick snippet that we're using to reindex Solr from our Cucumber features.
"And I reindex assets" helps to ensure that we didn't leave any cruft around from previous
tests and that we've properly indexed our Pickle model.
Background:
And I am logged in as an admin user
And an asset with snowboarding tags: "snowboarding" exists with title: "Snowboarding", alt_text: "Snowboarding", summary: "A summary about snowboards"
And I reindex assets
@barinek
barinek / Managing your ey-cloud-recipes
Created August 27, 2010 14:18
Managing your ey-cloud-recipes
If you've recently forked the ey-cloud-recipes on GitHub and then had issues
managing and deploying multiple projects with disparate dependencies using the
single forked gem, then we have a solution that has worked well on a recent project.
We've tucked the cookbooks directory underneath our Rails project. To apply Chef
changes, we installed the 'engineyard' gem and us 'ey recipes upload' and
'ey recipes apply' from within our Rails project.
Upside, everything you need to know about the project is local to the project.
@barinek
barinek / add local gem to load path
Created May 26, 2010 21:01
add local gem to load path
$LOAD_PATH << File.join(File.dirname(__FILE__), "../vendor/redis-rb/lib")
autoload :Redis, "redis"