Sha256: 21dd73fe2470326a4a6005decd6dfe0d5fb5ecafeca85aac09960ba66b7c4df2

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 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'
    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
      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

if(!ENV['CAPYBARA_DISABLED'])
  require 'capybara/cucumber'
  #Set Capybara Driver - using capybara.rb 
  Capybara.default_driver = CapybaraSetup.new.driver
end

#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

5 entries across 5 versions & 1 rubygems

Version Path
frameworks-capybara-0.0.22 lib/frameworks/cucumber.rb
frameworks-capybara-0.0.20 lib/frameworks/cucumber.rb
frameworks-capybara-0.0.19 lib/frameworks/cucumber.rb
frameworks-capybara-0.0.18 lib/frameworks/cucumber.rb
frameworks-capybara-0.0.17 lib/frameworks/cucumber.rb