Skip to content

Instantly share code, notes, and snippets.

Run options: --seed 40919
# Running tests:
EE.E.E.E..E.......E
Fabulous tests in 2.850542s, 6.6654 tests/s, 7.3670 assertions/s.
1) Error:
test_0001_crawls, parses, and returns array with data of journeys(DeBahnApi::.find):
@ordinaryzelig
ordinaryzelig / gist:4709056
Created February 4, 2013 19:41
Booking url process
  • user clicks purchase
  • fare_id is sent to SearchService
  • SS queues BotQueen with fare_id
  • BQ gets job
  • BQ uses SearchClient to request data from SS (segment, fare, etc.)
  • SS handles this request, queries db, responds to BQ with results
  • BQ sends info to bot
  • bot constructs HTML, making requests to agency if necessary
  • bot returns HTML to BQ
  • BQ sends HTML to be stored in Redis

(TLDR: http://railscasts.com/episodes/327-minitest-with-rails)

I just started a new Rails 3.1 project. I decided to use MiniTest::Spec for all my testing. I also wanted to use my typical testing tools: Capybara, Spork, etc. I didn't find much support for MiniTest, and even less for MiniTest::Spec. Here's some documentation on what I ended up with.

I'm starting a JavaScript project using the Jasmine Ruby gem for testing, and I only want to use CoffeeScript. After looking around to see how other projects did it, I didn't find any project with a "pure" CoffeeScript solution. The projects I saw only had the source code written in CoffeeScript but tests written in JavaScript. I wanted all my code including tests to be written in CoffeeScript.

This is what the basic directory tree looks like in my project:

~models
 file1.coffee

I ran into this problem today using RSpec with Webrat. I had this piece of code:

it 'should redirect to somewhere' do
  visit page_that_redirects_somewhere_path
  response.should redirect_to(somewhere_else_path)
end

I know that the controller is redirecting, but for some reason, in the test, the response was not showing a redirect.

If you're using AJAX in Rails 3 with jQuery, there's a little gotcha you may want to know about, especially if your'e at the laundromat.

I was working at the laundromat and getting this really weird error. Every remote link was broken. Whenever I clicked on a link that was supposed to do some AJAX magic, I would get a routing error that the url wasn't being matched. Looking at the log, it was requesting with GET instead of PUT, POST, etc. I looked at the HTML source and everything looked fine:

data-remote="true" "data-method="put"

I'm in the process of adding AJAX to a Rails app. One obstacle I have is updating the flash. I need all my AJAX requests to update the flash if my controller sets the flash with a message that I want shown on my page. So far I've converted 4 actions to AJAX, but there are at least 10 more. Customizing each action to update the flash message gets very tedious. So I need a way of DRYing it up.

For my templates, I'm using js.erb extensions (e.g. a request to /articles/create.js would render the app/views/articles/create.js.erb template). At the top of each template, I put some javascript code with some helper code:

I used to host my dev blog on Posterous. Twitter bought them out, and they were shutting down shop. I had to move my blog, but I didn't know where. I knew I didn't want much hassle which made me lean towards finding a hosted solution like wordpress. But I also knew I wanted something that would be good for sharing code snippets. At one time, Posterous had support for code snippets and markdown, which was great. Their support of it...not so much. I got so tired of their lack of support that I started just writing markdown in Github gists and pointed people to it. And then I started wondering if I could somehow strike a balance between a no-hassle solution and using gists.

<!DOCTYPE html>
<html>
<head>
<title>AtoB</title>
<link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/jquery.ui.core.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/jquery.ui.theme.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/jquery.ui.autocomplete.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/jquery.ui.datepicker.css?body=1" media="all" rel="stylesheet" type="text/css" />
{
"agency_node_details": [
{
"details": {
},
"meta_details": {
}
},
{
"details": {