module EnvBranch::TestHelper
Test helper for branch with environment variables
Public Instance Methods
restore_env_branch()
click to toggle source
Restore original environment variables for branch.
@example with test-unit
require 'env_branch/test_helper' class TestExample < Test::Unit::TestCase extend ::EnvBranch::TestHelper def self.shutdown restore_env_branch end end
@return [void]
# File lib/env_branch/test_helper.rb, line 52 def restore_env_branch original_travis_branch = (defined?(@original_travis_branch) && @original_travis_branch) || nil original_circle_branch = (defined?(@original_circle_branch) && @original_circle_branch) || nil original_bitrise_branch = (defined?(@original_bitrise_branch) && @original_bitrise_branch) || nil original_github_pull_request_builder_plugin_branch = (defined?(@original_github_pull_request_builder_plugin_branch) && @original_github_pull_request_builder_plugin_branch) || nil original_git_plugin_branch = (defined?(@original_git_plugin_branch) && @original_git_plugin_branch) || nil ENV['TRAVIS_BRANCH'] = original_travis_branch ENV['CIRCLE_BRANCH'] = original_circle_branch ENV['BITRISE_GIT_BRANCH'] = original_bitrise_branch ENV['ghprbSourceBranch'] = original_github_pull_request_builder_plugin_branch ENV['GIT_BRANCH'] = original_git_plugin_branch end
stash_env_branch()
click to toggle source
Stash original environment variables for branch. And delete for testing.
@example with test-unit
require 'env_branch/test_helper' class TestExample < Test::Unit::TestCase extend ::EnvBranch::TestHelper def self.startup stash_env_branch end end
@return [void]
# File lib/env_branch/test_helper.rb, line 23 def stash_env_branch @original_travis_branch = ENV['TRAVIS_BRANCH'] @original_circle_branch = ENV['CIRCLE_BRANCH'] @original_bitrise_branch = ENV['BITRISE_GIT_BRANCH'] @original_github_pull_request_builder_plugin_branch = ENV['ghprbSourceBranch'] @original_git_plugin_branch = ENV['GIT_BRANCH'] ENV.delete 'TRAVIS_BRANCH' ENV.delete 'CIRCLE_BRANCH' ENV.delete 'BITRISE_GIT_BRANCH' ENV.delete 'ghprbSourceBranch' ENV.delete 'GIT_BRANCH' end