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.
- #prepare_host ⇒ Object
- #validate_online(src) ⇒ Object
Instance Method Details
#generate_base_urls ⇒ Object
Generate base urls to use in Cucumber step defs
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 46 47 48 49 50 51 52 53 |
# File 'lib/frameworks/cucumber.rb', line 20 def generate_base_urls environment = ENV['ENVIRONMENT'].downcase #be defensive prepare_host if(environment =='sandbox') @base_url = @sandbox + @bbc_domain @pal_base_url = @sandbox + @bbc_domain @ssl_base_url = @sslsandbox + @bbc_domain @static_base_url = @static_sandbox + @bbc_domain @mobile_base_url = @mobiledot_prefix + "sandbox.dev.bbc.co.uk" @m_base_url = @mdot_prefix + "sandbox.dev.bbc.co.uk" elsif (environment =='live' && ENV['WWW_LIVE']=='false') @base_url = @www_prefix.chop + @bbc_domain @pal_base_url = @pal_prefix + environment + @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 @mobile_base_url = @mobiledot_prefix.chop + @bbc_domain @m_base_url = @mdot_prefix.chop + @bbc_domain else @base_url = @www_prefix + environment + @bbc_domain @pal_base_url = @pal_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 @mobile_base_url = @mobiledot_prefix + environment + @bbc_domain @m_base_url = @mdot_prefix + environment + @bbc_domain end proxy = ENV['http_proxy'] || ENV['HTTP_PROXY'] @proxy_host = proxy.scan(/http:\/\/(.*):80/)[0][0] if proxy end |
#prepare_host ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/frameworks/cucumber.rb', line 76 def prepare_host ENV['SCHEME']=='https' ? scheme = 'https' : scheme = 'http' @www_prefix = "#{scheme}://www." @pal_prefix = "#{scheme}://pal." @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" @mobiledot_prefix = "#{scheme}://mobile." @mdot_prefix = "#{scheme}://m." @sslsandbox = "https://ssl.sandbox.dev" @static_sandbox = "#{scheme}://static.sandbox.dev" end |
#validate_online(src) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/frameworks/cucumber.rb', line 55 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 |