Sha256: 8186beeca8c95c5a7e652c11c6bfe2cd9c91bff6ed54888c3ad39d2d8b704e8e

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Pages
  class Operations
    attr_accessor :page

    def initialize(page)
      @page = page
    end

    def have_title?(title)
      page.has_xpath?('//h1', text: title)
    end

    def table_rows
      page.all('table#operations tbody tr')
    end

    def operation_row(title)
      table_rows.find { |row| row.all('td')[0].has_link?(title) }
    end

    def have_operation?(options)
      row = operation_row(options[:title])

      row.present? &&
        check_status(row, options) &&
        check_assignment(row, options) &&
        check_button(row, options)
    end

    def check_status(row, options)
      (options[:status].blank? || row.all('td')[1].text == options[:status])
    end

    def check_assignment(row, options)
      (options[:assignment].blank? ||
        row.all('td')[2].text == options[:assignment])
    end

    def check_button(row, options)
      (options[:button_text].blank? || has_button?(row, options[:button_text]))
    end

    def has_button?(row, button_text)
      form = row.all('td')[4].find('form')
      form.has_button?(button_text)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails_workflow-0.7.3 spec/support/pages/operations.rb
rails_workflow-0.7.2 spec/support/pages/operations.rb
rails_workflow-0.7.1 spec/support/pages/operations.rb
rails_workflow-0.7.0 spec/support/pages/operations.rb
rails_workflow-0.4.4 spec/support/pages/operations.rb
rails_workflow-0.4.3 spec/support/pages/operations.rb
rails_workflow-0.4.2 spec/support/pages/operations.rb
rails_workflow-0.4.1 spec/support/pages/operations.rb
rails_workflow-0.4.0 spec/support/pages/operations.rb