Skip to content

Instantly share code, notes, and snippets.

@richhollis
Forked from nruth/image_helpers.rb
Created February 28, 2014 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richhollis/9271220 to your computer and use it in GitHub Desktop.
Save richhollis/9271220 to your computer and use it in GitHub Desktop.
# an example, showing how to load for rspec and conditionally load for cucumber
# lives in whichever dir you set the other file to load
module ImageStepHelpers
def page_should_contain_image_link_for(image)
page.should have_xpath(%Q(//img[@src="#{image.url}"]))
end
def image_data_from_file(image)
image_file_path = Rails.root.join image.image.path
File.read(image_file_path)
end
def hash_image(image_data)
require 'md5'
MD5.digest(image_data)
end
end
RSpec.configure do |config|
config.include ImageStepHelpers, :type => :request
end
World(ImageStepHelpers) if respond_to?(:World) #cucumber
#drop into features/support and spec/support -- modify path to helper lib dir as needed
Dir[
File.expand_path(
Rails.root.join 'test_helper_lib', '**', '*.rb'
)
].each {|f| require f}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment