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 9067007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:50:49+00:00 2026-06-16T16:50:49+00:00

I have a Banner, with an attached file, using paperclip. Paperclip will create derivatives

  • 0

I have a Banner, with an attached file, using paperclip. Paperclip will create “derivatives” for an uploaded image, using the “styles” parameter:

class Banner < ActiveRecord::Base
  has_attached_file :image,
                    :styles => {:medium => "300x300>",
                                :thumb  => "100x100>"}
end

I want to test this attached_file generation, preferably without testing the whole roundtrip to a disk and so on. I could create a Banner, attach a file and then look on the filesystem if a certain file with certain dimensions is created, but that goes against my idea of testing a focused part, without testing the entire stack.

How can I test if the attached file :image has certain styles in Paperclip?

  • 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-06-16T16:50:50+00:00Added an answer on June 16, 2026 at 4:50 pm

    All the has_attached_file method does is add the passed definitions to the model. The generation is done by paperclip and shouldn’t need to be tested.

    Source:
    https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip.rb#L174

    However, you could test that the definitions were created properly using the attachment_definitions method. Something like this:

    it "has correct image style geometry" do
       Banner.attachment_definitions[:data][:styles][:medium][:geometry].should == "300x300>"
       Banner.attachment_definitions[:data][:styles][:thumb][:geometry].should == "100x100>"
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two Flash banner ads, built in CS5.5, using AS2, that will be
So on users profiles I will have banner space where they can upload a
I am using a storyboard and I have added iAd banner to my view.
I have 4 banner images, and I want to cycle through them using a
I have a flash banner that I want to replace with a static image
Is it advice able to have top banner/Logo as a webview instead of Image
I'm using a combination of Jquery and html imagemap to have a banner with
I have a banner that uses an image as the background. The image's size
I would Like to have a banner across an image. Both the image and
I am trying to create a layout as show in the image attached here:

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.