Sha256: 13b0d2c95e47643ee885383ab65c560cd59bf71800c233f7e7f0c9be7d77e0f2

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

module Smokes
  # Parses individual test and runs it using selenium
  class TestParser
    def initialize(filename, selenium_browser, selenium_wait)
      @filename = filename
      @test = YAML.load_file(filename)
      @selenium_browser = selenium_browser
      @selenium_wait = selenium_wait
    end

    def run
      @test.each do |test|
        if test.key?('test')
          document_test(test) if test['test']['document']
        else
          say("your test is missing the test attribute: #{filename}")
          abort
        end
      end
    end

    private

    def document_test(test)
      if test['name'] && test['test']['document']['title'] && test['test']['document']['title']['should_be']
        assertion = @selenium_browser.title == test['test']['document']['title']['should_be']
        if assertion
          puts("#{test['name']}. PASSED".colorize(:green))
        else
          puts("#{test['name']}. FAILED".colorize(:red))
          puts("=====> Expected: #{test['test']['document']['title']['should_be']}".colorize(:yellow))
          puts("=====> Found: #{@selenium_browser.title}".colorize(:yellow))
        end
      else
        puts('Your test is missing value'.colorize(:red))
        puts test
        abort
      end
   end
 end
end

# {
# :class => 'ClassName',
# :class_name => 'ClassName',
# :css => 'CssSelector',
# :id => 'Id',
# :link => 'LinkText',
# :link_text => 'LinkText',
# :name => 'Name',
# :partial_link_text => 'PartialLinkText',
# :tag_name => 'TagName',
# :xpath => 'Xpath',
# }

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smokes-0.1.2 lib/smokes/test_parser.rb