Sha256: d91922b25dc41fac57a06efc5eead098fe812fa2757b171cd8d88b7c02606c69

Contents?: true

Size: 1.11 KB

Versions: 26

Compression:

Stored size: 1.11 KB

Contents

module CommonHelpers
  def delete_cookies
    browser = Capybara.current_session.driver.browser
    if browser.respond_to?(:clear_cookies)
      # Rack::MockSession
      browser.clear_cookies
    elsif browser.respond_to?(:manage) and browser.manage.respond_to?(:delete_all_cookies)
      # Selenium::WebDriver
      browser.manage.delete_all_cookies
    else
      raise "Don't know how to clear cookies. Weird driver?"
    end
  end

  def update_value_attr_for sel
    page.execute_script "$('#{sel}').attr('value', $('#{sel}').val());"
  end

  def create_comment_for_article name, opts = {}
    author = opts[:author] || 'Ryan'
    text = opts[:text] || 'Some nice thoughts dude'
    comment = articles(name).comments.create! author: author, text: text
    emit comment, :created, data: {article_id: comment.article_id}
    comment
  end

  def destroy_comment comment
    comment.destroy
    emit comment, :destroyed, data: {article_id: comment.article_id}
  end

  def update_comment comment
    comment.text = "#{comment.text} (edited)"
    comment.save!
    emit comment, :updated, data: {article_id: comment.article_id}
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
loco-rails-3.0.3 test/support/common_helpers.rb
loco-rails-2.5.3 test/support/common_helpers.rb
loco-rails-2.5.2 test/support/common_helpers.rb
loco-rails-3.0.2 test/support/common_helpers.rb
loco-rails-3.0.1 test/support/common_helpers.rb
loco-rails-2.5.1 test/support/common_helpers.rb
loco-rails-2.5.0 test/support/common_helpers.rb
loco-rails-2.4.0 test/support/common_helpers.rb
loco-rails-2.3.0 test/support/common_helpers.rb
loco-rails-3.0.0 test/support/common_helpers.rb
loco-rails-2.2.2 test/support/common_helpers.rb
loco-rails-2.2.1 test/support/common_helpers.rb
loco-rails-2.2.0 test/support/common_helpers.rb
loco-rails-2.1.0 test/support/common_helpers.rb
loco-rails-2.0.0 test/support/common_helpers.rb
loco-rails-1.5.2 test/support/common_helpers.rb
loco-rails-1.5.1 test/support/common_helpers.rb
loco-rails-1.5.0 test/support/common_helpers.rb
loco-rails-1.4.0 test/support/common_helpers.rb
loco-rails-1.3.3 test/support/common_helpers.rb