Module: AttachmentMagickTestHelper

Defined in:
lib/attachment_magick/test/attachment_magick_test_helper.rb

Instance Method Summary collapse

Instance Method Details

#assert_element_in(target, match) ⇒ Object



2
3
4
5
# File 'lib/attachment_magick/test/attachment_magick_test_helper.rb', line 2

def assert_element_in(target, match)
  target = Nokogiri::HTML(target)
  target.xpath("//#{match}").present?
end

#assert_element_value(target, match, field) ⇒ Object



7
8
9
10
# File 'lib/attachment_magick/test/attachment_magick_test_helper.rb', line 7

def assert_element_value(target, match, field)
  target = Nokogiri::HTML(target)
  target.xpath("//#{match}").first["#{field}"]
end

#create_artist(options = {}) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/attachment_magick/test/attachment_magick_test_helper.rb', line 12

def create_artist(options={})
  default_options = {:name => "Johnny", :lastname => "Depp"}
  default_options.merge!(options)

  @artist = Artist.create(default_options)
  @artist.images.create(:photo => example_file)
  return @artist
end

#create_place(options = {}) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/attachment_magick/test/attachment_magick_test_helper.rb', line 21

def create_place(options={})
  default_options = {:name => "Las Vegas"}
  default_options.merge!(options)

  @place = Place.create(default_options)
  @place.images.create(:photo => example_file)
  return @place
end

#create_work(artist) ⇒ Object



30
31
32
33
34
# File 'lib/attachment_magick/test/attachment_magick_test_helper.rb', line 30

def create_work(artist)
  default_options = {:name => "movie", :local => "Hollywood"}
  artist.works.create(default_options)
  artist.works.last.images.create(:photo => example_file)
end

#example_fileObject



36
37
38
# File 'lib/attachment_magick/test/attachment_magick_test_helper.rb', line 36

def example_file
  fixture_file_upload('little_girl.jpg', 'image/jpg')
end

#example_partialObject



48
49
50
# File 'lib/attachment_magick/test/attachment_magick_test_helper.rb', line 48

def example_partial
  "layouts/custom_images_list"
end

#example_vimeoObject



44
45
46
# File 'lib/attachment_magick/test/attachment_magick_test_helper.rb', line 44

def example_vimeo
  'http://vimeo.com/14051767'
end

#example_youtubeObject



40
41
42
# File 'lib/attachment_magick/test/attachment_magick_test_helper.rb', line 40

def example_youtube
  'http://www.youtube.com/watch?v=FUe83k3t_0s'
end