Skip to content

Commit

Permalink
Fix flaky spec environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
fotinakis committed May 25, 2015
1 parent 1b67ee6 commit 6322f27
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
21 changes: 13 additions & 8 deletions spec/lib/percy/client/environment_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
RSpec.describe Percy::Client::Environment do
before(:each) do
@original_env = {
'TRAVIS_BUILD_ID' => ENV['TRAVIS_BUILD_ID'],
'TRAVIS_COMMIT' => ENV['TRAVIS_COMMIT'],
'TRAVIS_BRANCH' => ENV['TRAVIS_BRANCH'],
'TRAVIS_PULL_REQUEST' => ENV['TRAVIS_PULL_REQUEST'],
'TRAVIS_REPO_SLUG' => ENV['TRAVIS_REPO_SLUG'],
}
def clear_env_vars
# Unset Percy vars.
ENV['PERCY_COMMIT'] = nil
ENV['PERCY_BRANCH'] = nil
Expand Down Expand Up @@ -34,7 +27,19 @@
ENV['CIRCLE_PROJECT_REPONAME'] = nil
ENV['CI_PULL_REQUESTS'] = nil
end

before(:each) do
@original_env = {
'TRAVIS_BUILD_ID' => ENV['TRAVIS_BUILD_ID'],
'TRAVIS_COMMIT' => ENV['TRAVIS_COMMIT'],
'TRAVIS_BRANCH' => ENV['TRAVIS_BRANCH'],
'TRAVIS_PULL_REQUEST' => ENV['TRAVIS_PULL_REQUEST'],
'TRAVIS_REPO_SLUG' => ENV['TRAVIS_REPO_SLUG'],
}
clear_env_vars
end
after(:each) do
clear_env_vars
ENV['TRAVIS_BUILD_ID'] = @original_env['TRAVIS_BUILD_ID']
ENV['TRAVIS_COMMIT'] = @original_env['TRAVIS_COMMIT']
ENV['TRAVIS_BRANCH'] = @original_env['TRAVIS_BRANCH']
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/percy/client/snapshots_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
it 'creates a build' do
build = Percy.create_build('fotinakis/percy-examples')
resources = []
resources << Percy::Client::Resource.new(sha, '/foo/test.html', is_root: true)
resources << Percy::Client::Resource.new(sha, '/css/test.css')
resources << Percy::Client::Resource.new('/foo/test.html', sha: sha, is_root: true)
resources << Percy::Client::Resource.new('/css/test.css', sha: sha)
snapshot = Percy.create_snapshot(build['data']['id'], resources, name: 'homepage')

expect(snapshot['data']).to be
Expand Down

0 comments on commit 6322f27

Please sign in to comment.