Sha256: 59ca07a951ae22f3283e90f4124b881677a3865ec1540e8d4ca1eb344dee3098

Contents?: true

Size: 801 Bytes

Versions: 6

Compression:

Stored size: 801 Bytes

Contents

require 'bbq/test'
require 'bbq/test_user'
require 'support/capybara'

class TestUser < Bbq::TestUser
  include MiniTest::Assertions

  def initialize
    super(:driver => :mechanize)
  end

  def see!(*args)
    msg = "Expected to see %s but not found"
    args.each { |arg| assert has_content?(arg), msg % arg }
  end

  def generate_file
    File.open(@path = "./tmp/#{Time.now.to_i}", "w") do |f|
      f.write SecureRandom.hex(5120)
    end
    file_path
  end

  def attach_first_file(form_id, file_path)
    page.driver.browser.agent.current_page.form_with(id: form_id) do |form|
      form.file_uploads.first.file_name = file_path
    end
  end

  def attach_and_submit_first_file(form_id, file_path)
    attach_first_file(form_id, file_path).submit
  end

  def file_path
    @path
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
m2r-2.1.0 test/support/test_user.rb
m2r-2.1.0.pre test/support/test_user.rb
m2r-2.0.2 test/support/test_user.rb
m2r-2.0.1 test/support/test_user.rb
m2r-2.0.0 test/support/test_user.rb
m2r-1.0.0 test/support/test_user.rb