Merge pull request #274 + fix to use FakeFS to avoid flakey test

This commit is contained in:
Steven Bazyl 2015-08-19 13:57:14 -07:00
commit a5a9b49160
3 changed files with 21 additions and 3 deletions

View File

@ -14,8 +14,8 @@ group :development do
gem 'coveralls', '~> 0.7.11' gem 'coveralls', '~> 0.7.11'
gem 'rubocop', '~> 0.29' gem 'rubocop', '~> 0.29'
gem 'launchy', '~> 2.4' gem 'launchy', '~> 2.4'
gem 'dotenv' gem 'dotenv', '~> 2.0'
gem 'pry-doc' gem 'fakefs', '~> 0.6', require: "fakefs/safe"
end end
platforms :jruby do platforms :jruby do
@ -29,7 +29,8 @@ platforms :ruby do
gem 'yard', '~> 0.8' gem 'yard', '~> 0.8'
gem 'redcarpet', '~> 3.2' gem 'redcarpet', '~> 3.2'
gem 'github-markup', '~> 1.3' gem 'github-markup', '~> 1.3'
gem 'pry-byebug' gem 'pry-doc', '~> 0.8'
gem 'pry-byebug', '~> 3.2'
end end
end end

View File

@ -48,6 +48,13 @@ RSpec.describe Google::APIClient::ClientSecrets do
expect(hash["installed"]["client_secret"]).to be == 'i8YaXdGgiQ4_KrTVNGsB7QP1' expect(hash["installed"]["client_secret"]).to be == 'i8YaXdGgiQ4_KrTVNGsB7QP1'
end end
it 'should remove empty value' do
expect(hash["installed"]["redirect_uris"]).to be nil
end
it 'should remove nil values' do
expect(hash["installed"]["issued_at"]).to be nil
end
end end
end end
@ -72,4 +79,12 @@ RSpec.describe Google::APIClient::ClientSecrets do
expect(secrets.client_id).to be == '898243283568.apps.googleusercontent.com' expect(secrets.client_id).to be == '898243283568.apps.googleusercontent.com'
end end
end end
context 'with folder wihout client_secrets.json' do
it "should raise exception", fakefs: true do
FileUtils.mkdir("/tmp")
expect { Google::APIClient::ClientSecrets.load('/tmp') }.to raise_exception(ArgumentError)
end
end
end end

View File

@ -43,6 +43,7 @@ end
require 'rspec' require 'rspec'
require 'webmock/rspec' require 'webmock/rspec'
require 'fakefs/spec_helpers'
require 'json_spec' require 'json_spec'
require 'logging' require 'logging'
require 'rspec/logging_helper' require 'rspec/logging_helper'
@ -53,6 +54,7 @@ require 'google/apis/core/base_service'
# logs will be stored in the @log_output variable. It is a StringIO instance. # logs will be stored in the @log_output variable. It is a StringIO instance.
RSpec.configure do |config| RSpec.configure do |config|
include RSpec::LoggingHelper include RSpec::LoggingHelper
config.include FakeFS::SpecHelpers, fakefs: true
config.include JsonSpec::Helpers config.include JsonSpec::Helpers
config.include WebMock::API config.include WebMock::API
config.capture_log_messages config.capture_log_messages