class Smokes::TestParser

Parses individual test and runs it using selenium

Public Class Methods

new(filename, selenium_browser, selenium_wait) click to toggle source
# File lib/smokes/test_parser.rb, line 4
def initialize(filename, selenium_browser, selenium_wait)
  @filename = filename
  @test = YAML.load_file(filename)
  @selenium_browser = selenium_browser
  @selenium_wait = selenium_wait
end

Public Instance Methods

run() click to toggle source
# File lib/smokes/test_parser.rb, line 11
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 Instance Methods

document_test(test) click to toggle source
# File lib/smokes/test_parser.rb, line 24
 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