Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6044265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:59:31+00:00 2026-05-23T06:59:31+00:00

In the comments to the solution for How do I find an image on

  • 0

In the comments to the solution for How do I find an image on a page with Cucumber/Capybara, somebody asked:

I can’t seem to figure how to get this
to work with URLs generated by
Dragonfly. They look like this:
/media/BAh_some_long_string_AwIw/12_11_52_810_5x5.jpg?s=7e360000, where 5×5.jpg is my file name. I’ve
tried something like:
//img[@src=”/media//#{image}?s=*”]
but it doesn’t work. Got any tips? – Ramon Tayag Feb 25 at 4:18

I have a similar problem, only worse – in my case, the generated image paths don’t even include a (jpg|png|gif) file name, they only have these really long ids:

<img src="/media/BAhbB1sHOgZmSSIdNGQ4MTEyOGU3ZjViZmQwZTQ4MDAwMDAyBjoGRVRbCDoGcDoKdGh1bWJJIg0yMDB4MjAwIwY7BlQ" />

(Using dragonfly with mongo/gridfs)

These paths get rendered alright, but I can’t figure out how to find them in a Cucumber/Capybara step 😛

Any ideas? I looked at the Dragonfly’s features, but they only test the rendering of the image itself, without detecting it’s existence within an html page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:59:32+00:00Added an answer on May 23, 2026 at 6:59 am

    Answering my own question, after talking to Dragonfly’s author (he’s working on making this easier):

    #route
    match '/media/:dragonfly/:file_name', :to => Dragonfly[:images]  
    
    #model
    class Store
      include MongoMapper::Document
      key :photo_uid, String
      key :photo_name, String
      image_accessor :photo
    end
    
    #view
    <%= image_tag @store.photo.thumb('274x207#').url(:suffix => "/#{@store.photo_name}") if @store.photo %>
    
    #cucumber
    Then I should see the image "my_photo.png"
    
    Then /^I should see the image "(.+)"$/ do |image|  
      page.should have_xpath("//img[contains(@src, \"#{image}\")]")
    end
    

    The key is adding an [attachment]_name field to the model, which Dragonfly populates automatically, and then passing it on as a suffix to url(). And the routes needs to allow for a :file_name param besides the generated dragonfly identifier.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a wierd problem that I can't seem to find the solution, probably
I can't seem to find anything that comments on the behaviour I am having
Our solution has a lot of todo comments, but unfortunately it seems the only
I'm trying to create a Comments section in my wiki. There's one solution on
Can I use comments inside a JSON file? If so, how?
Update after Bounty was awarded A new solution is coming up to this problem.
I have been looking for a way to get the comments from a Blogger
I've researched related questions on the site but failed to find a solution. What
I am beginning work on a large Visual Studio solution, and have come across
In Visual Studio, xml comments can be added to methods/classes to provide documentation. See

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.