Skip to content

Instantly share code, notes, and snippets.

@steveklabnik
Created January 9, 2012 18:40
Embed
What would you like to do?
I think this spec implies that I should commit myself into some kind of rehab.
it "lists them in reverse chronological order" do
recent_titles = Article.for_dashboard.map(&:title).map{|t| Regexp.quote(t) }
title_regex = Regexp.new(recent_titles.join(".*?"), Regexp::MULTILINE)
page.html.should match(title_regex)
end
@steveklabnik
Copy link
Author

... Yeah. Not totally happy, but it's the best thing I could think of.

I miss my mocks in request specs.

@justinko
Copy link

justinko commented Jan 9, 2012

I think all you should care about is diffing an array (or string via join):

it "lists them in reverse chronological order" do
  recent_titles_in_db = Article.for_dashboard.map(&:title)
  recent_ttiles_on_page = page.all('#articles li').map(&:text)
  recent_titles_in_db.should eq(recent_titles_on_page)
end

@steveklabnik
Copy link
Author

Ahhh, that's much nicer. Thanks so much!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment