Sha256: bf1a2a5a7932be574b3ec1bd23848d171f109f391d85f0277a1c29be285a4741

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require "testable/errors"

module Testable
  module Situation
    private

    def url_is_empty
      puts "PROBLEM: url_is attribute empty.\n" \
      "The url_is attribute is empty on the definition " \
      "'#{retrieve_class(caller)}'.\n\n"
      raise Testable::Errors::NoUrlForDefinition
    end

    def title_is_empty
      puts "PROBLEM: title_is attribute empty.\n" \
      "The title_is attribute is empty on the definition " \
      "'#{retrieve_class(caller)}'.\n\n"
      raise Testable::Errors::NoTitleForDefinition
    end

    def no_url_provided
      puts "PROBLEM: no url provided.\n" \
      "You called a '#{retrieve_method(caller)}' action but the " \
      "definition '#{self.class}' does not have a url_is attribute.\n" \
      "Either provide the url_is attribute or pass the url as an " \
      "argument to the visit call.\n\n"
      raise Testable::Errors::NoUrlForDefinition
    end

    def no_locator(name)
      puts "PROBLEM: No locator provided.\n" \
      "You are using '#{name}' on '#{retrieve_class(caller)}'. " \
      "But there is no locator provided with it.\n\n"
      raise Testable::Errors::NoLocatorForDefinition
    end

    def retrieve_class(caller)
      caller[1][/`.*'/][8..-3]
    end

    def retrieve_method(caller)
      caller[0][/`.*'/][1..-2]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
testable-0.2.0 lib/testable/situation.rb