Sha256: 21de979c93ea2b45eb4fad95e9be8e0b908a3f97bd57217831db9cff1423ffcc

Contents?: true

Size: 1.32 KB

Versions: 26

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module LeapSalesforce
  # A test user used to execute tests
  class User
    # @return [String] Name to identify user by
    attr_accessor :key
    # @return [String] Username of User interpreted by ERB (in email address format). Use ERB to define users that can vary
    #   according to environment
    attr_writer :username
    # @return [String] Long form description of user. Could be used to reference them in a Cucumber test
    attr_accessor :description

    # @param [String, Symbol] key Key used to identify a test user
    # @param [String] username Name used to login with user. In email address format.
    def initialize(key, username, description: nil)
      self.key = key
      self.username = username
      self.description = description
    end

    # @return [String] Email address of User
    def username
      ERB.new(@username).result(binding)
    end

    # @param [Symbol, String] field Field to check
    # @param [Object, Regex] criteria Either object with same value or regex that has a match anywhere in string
    # @return [Boolean] Whether key and criteria match current user
    def match?(field, criteria)
      actual_value = send(field.to_s)
      case criteria
      when Regexp then !actual_value[criteria].nil?
      else
        actual_value == criteria
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
leap_salesforce-0.2.9 lib/leap_salesforce/users/user.rb
leap_salesforce-0.2.8 lib/leap_salesforce/users/user.rb
leap_salesforce-0.2.7 lib/leap_salesforce/users/user.rb
leap_salesforce-0.2.6 lib/leap_salesforce/users/user.rb
leap_salesforce-0.2.5 lib/leap_salesforce/users/user.rb
leap_salesforce-0.2.4 lib/leap_salesforce/users/user.rb
leap_salesforce-0.2.3 lib/leap_salesforce/users/user.rb
leap_salesforce-0.2.2 lib/leap_salesforce/users/user.rb
leap_salesforce-0.2.1 lib/leap_salesforce/users/user.rb
leap_salesforce-0.2.0 lib/leap_salesforce/users/user.rb
leap_salesforce-0.1.18 lib/leap_salesforce/users/user.rb
leap_salesforce-0.1.17 lib/leap_salesforce/users/user.rb
leap_salesforce-0.1.16 lib/leap_salesforce/users/user.rb
leap_salesforce-0.1.15 lib/leap_salesforce/users/user.rb
leap_salesforce-0.1.13 lib/leap_salesforce/users/user.rb
leap_salesforce-0.1.12 lib/leap_salesforce/users/user.rb
leap_salesforce-0.1.11 lib/leap_salesforce/users/user.rb
leap_salesforce-0.1.9 lib/leap_salesforce/users/user.rb
leap_salesforce-0.1.8 lib/leap_salesforce/users/user.rb
leap_salesforce-0.1.7 lib/leap_salesforce/users/user.rb