Module: Frameworks::EnvHelper

Includes:
W3CValidators
Defined in:
lib/frameworks/cucumber.rb

Instance Method Summary collapse

Instance Method Details

#generate_base_urlsObject

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
# File 'lib/frameworks/cucumber.rb', line 19

def generate_base_urls 
  set_scheme
  if(ENV['ENVIRONMENT']=='sandbox')
    @base_url = @sandbox + @bbc_domain 
    @static_base_url = @static_sandbox + @bbc_domain
  elsif (ENV['ENVIRONMENT']=='live' && ENV['WWW_LIVE']=='false')
    @base_url = @www_prefix.chop + @bbc_domain
    @static_base_url = @static_prefix.chop + @bbc_domain
    @open_base_url = @open_prefix.chop + @bbc_domain
  elsif (ENV['ENVIRONMENT'].split('.')[0].include? 'pal') #address specific box
    @base_url = "#{scheme}://#{ENV['ENVIRONMENT']}" 
  else
    @base_url = @www_prefix + ENV['ENVIRONMENT'] + @bbc_domain
    @static_base_url = @static_prefix + ENV['ENVIRONMENT'] + @bbc_domain
    @static_base_url = @static_prefix.chop + @bbc_domain if ENV['ENVIRONMENT'] == 'live'
    @open_base_url = @open_prefix + ENV['ENVIRONMENT'] + @bbc_domain
  end
  proxy = ENV['http_proxy'] || ENV['HTTP_PROXY'] 
  @proxy_host = ENV['http_proxy'].scan(/http:\/\/(.*):80/).to_s if proxy
end

#set_schemeObject



56
57
58
59
60
61
62
63
64
# File 'lib/frameworks/cucumber.rb', line 56

def set_scheme  
  ENV['SCHEME']=='https' ? scheme = 'https' : scheme = 'http'
  @www_prefix = "#{scheme}://www."
  @static_prefix = "#{scheme}://static."
  @open_prefix = "#{scheme}://open."
  @bbc_domain = '.bbc.co.uk'
  @sandbox = "#{scheme}://pal.sandbox.dev"
  @static_sandbox = "#{scheme}://static.sandbox.dev"
end

#validate_online(src) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/frameworks/cucumber.rb', line 40

def validate_online(src)

  @validator = MarkupValidator.new({:proxy_host => @proxy_host,:proxy_port => 80})

  @validator.set_doctype!(:xhtml)
  results = @validator.validate_text(src)

  if results.errors.length > 0
    results.errors.each do |err|
      puts err.to_s
    end
    raise "W3C Validation of " + url + " failed."
  end
end