Skip to content

Commit

Permalink
Revert to original environment after each cucumber test
Browse files Browse the repository at this point in the history
Some test manipulate the env so we need to revert to the original
one after each scenario.
  • Loading branch information
orenbm committed Jun 7, 2020
1 parent 9a6e7be commit 6dded0d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cucumber/_authenticators_common/features/support/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,17 @@
# share this code, and to it the api way (probably)
creds.password = 'SEcret12!!!!'
creds.save(raise_on_save_failure: true)

# Save env to revert to it after the test
@env = {}
ENV.each do |key, value|
@env[key] = value
end
end

After do
# Revert to original env
@env.each do |key, value|
ENV[key] = value
end
end
11 changes: 11 additions & 0 deletions cucumber/api/features/support/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,21 @@
Account.find_or_create_accounts_resource
admin_role = Role.create(role_id: "cucumber:user:admin")
Credentials.new(role: admin_role).save(raise_on_save_failure: true)

# Save env to revert to it after the test
@env = {}
ENV.each do |key, value|
@env[key] = value
end
end

After do
FileUtils.remove_dir('cuke_export') if Dir.exists?('cuke_export')

# Revert to original env
@env.each do |key, value|
ENV[key] = value
end
end

Before("@logged-in") do
Expand Down
13 changes: 13 additions & 0 deletions cucumber/authenticators/features/support/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,17 @@
# this code, and to it the api way (probably)
creds.password = 'SEcret12!!!!'
creds.save(raise_on_save_failure: true)

# Save env to revert to it after the test
@env = {}
ENV.each do |key, value|
@env[key] = value
end
end

After do
# Revert to original env
@env.each do |key, value|
ENV[key] = value
end
end
13 changes: 13 additions & 0 deletions cucumber/policy/features/support/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,17 @@
# this code, and to it the api way (probably)
creds.password = 'SEcret12!!!!'
creds.save(raise_on_save_failure: true)

# Save env to revert to it after the test
@env = {}
ENV.each do |key, value|
@env[key] = value
end
end

After do
# Revert to original env
@env.each do |key, value|
ENV[key] = value
end
end

0 comments on commit 6dded0d

Please sign in to comment.