Module: Frameworks::EnvHelper
- Includes:
- W3CValidators
- Defined in:
- lib/frameworks/cucumber.rb
Instance Method Summary collapse
-
#generate_base_urls ⇒ Object
Generate base urls to use in Cucumber step defs.
- #set_scheme ⇒ Object
- #validate_online(src) ⇒ Object
Instance Method Details
#generate_base_urls ⇒ Object
Generate base urls to use in Cucumber step defs
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/frameworks/cucumber.rb', line 19 def generate_base_urls environment = ENV['ENVIRONMENT'].downcase #be defensive set_scheme if(environment =='sandbox') @base_url = @sandbox + @bbc_domain @ssl_base_url = @sslsandbox + @bbc_domain @static_base_url = @static_sandbox + @bbc_domain elsif (environment =='live' && ENV['WWW_LIVE']=='false') @base_url = @www_prefix.chop + @bbc_domain @ssl_base_url = @ssl_prefix.chop + @bbc_domain @static_base_url = @static_prefix.chop + @bbci_domain @open_base_url = @open_prefix.chop + @bbc_domain elsif (environment.split('.')[0].include? 'pal') #address specific box @base_url = "#{scheme}://#{ENV['ENVIRONMENT']}" else @base_url = @www_prefix + environment + @bbc_domain @ssl_base_url = @ssl_prefix + environment + @bbc_domain @static_base_url = @static_prefix + environment + @bbci_domain @static_base_url = @static_prefix.chop + @bbci_domain if environment == 'live' @open_base_url = @open_prefix + environment + @bbc_domain end proxy = ENV['http_proxy'] || ENV['HTTP_PROXY'] @proxy_host = proxy.scan(/http:\/\/(.*):80/)[0][0] if proxy end |
#set_scheme ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/frameworks/cucumber.rb', line 68 def set_scheme ENV['SCHEME']=='https' ? scheme = 'https' : scheme = 'http' @www_prefix = "#{scheme}://www." @ssl_prefix = "https://ssl." @static_prefix = "#{scheme}://static." @open_prefix = "#{scheme}://open." @bbc_domain = '.bbc.co.uk' @bbci_domain = '.bbci.co.uk' @sandbox = "#{scheme}://pal.sandbox.dev" @sslsandbox = "https://ssl.sandbox.dev" @static_sandbox = "#{scheme}://static.sandbox.dev" end |
#validate_online(src) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/frameworks/cucumber.rb', line 47 def validate_online(src) @validator = MarkupValidator.new({:proxy_host => @proxy_host,:proxy_port => 80}) @validator.set_doctype!(:xhtml) begin results = @validator.validate_text(src) if results.errors.length > 0 results.errors.each do |err| puts err.to_s end raise "W3C Validation of " + current_url + " failed." end rescue Net::HTTPFatalError => e puts "WARNING - OUTGOING NETWORK ERROR FROM FORGE TO W3C - Validation Not Performed" end end |