Sha256: ba110312dcf6781c2e44e90af2639ca0ec8118b5c321c5136f90bca6c37c6251

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

require 'frameworks/capybara'
require 'monkey-patches/cucumber-patches'

module Frameworks
  module EnvHelper
    
    WWW_PREFIX = 'http://www.'
    STATIC_PREFIX = 'http://static.'
    OPEN_PREFIX = 'http://open.'
    BBC_DOMAIN = '.bbc.co.uk'
    STATIC_BBC_DOMAIN = '.bbc.co.uk'
    SANDBOX = 'http://pal.sandbox.dev'
    STATIC_SANDBOX = 'http://static.sandbox.dev'

    #Generate base urls to use in Cucumber step defs
    def generate_base_urls 
      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 + BBC_DOMAIN
        @static_base_url = STATIC_PREFIX + BBC_DOMAIN
        @open_base_url = OPEN_PREFIX + BBC_DOMAIN
      elsif (ENV['ENVIRONMENT'].split('.')[0].include? 'pal') #address specific box
        @base_url = "http://#{ENV['ENVIRONMENT']}" 
      else
        @base_url = WWW_PREFIX + ENV['ENVIRONMENT'] + BBC_DOMAIN
        @static_base_url = STATIC_PREFIX + ENV['ENVIRONMENT'] + BBC_DOMAIN
        @open_base_url = OPEN_PREFIX + ENV['ENVIRONMENT'] + BBC_DOMAIN
      end
    end

  end #EnvHelper
end #Frameworks

CapybaraSetup.new unless ENV['CAPYBARA_DISABLED']

#Add module into world to ensure visibility of instance variables within Cucumber
World(Frameworks::EnvHelper)

#Call generate method in Before hook
Before do
  generate_base_urls
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
frameworks-capybara-0.0.31 lib/frameworks/cucumber.rb
frameworks-capybara-0.0.30 lib/frameworks/cucumber.rb