Permalink
Browse files

Don't embed SDK into tests.js, load it from external build

  • Loading branch information...
lsegal committed Jan 15, 2014
1 parent 1b32773 commit 941014b1897dd7af0fd7db0b79d6c3970d649b99
Showing with 41 additions and 31 deletions.
  1. +1 −0 dist/tests.html
  2. +6 −2 tasks/browser.rake
  3. +28 −28 test/credentials.spec.coffee
  4. +6 −1 test/helpers.coffee
View
@@ -90,6 +90,7 @@
<script type="text/javascript" src="js/jasmine-1.3.1.js"></script>
<script type="text/javascript" src="js/jasmine-html.js"></script>
<script src="/testem.js"></script>
+ <script type="text/javascript" src="aws-sdk-all.js"></script>
<script type="text/javascript" src="tests.js" charset="UTF-8"></script>
<script type="text/javascript" charset="UTF-8">
window.addEventListener('load', function() {
View
@@ -37,6 +37,10 @@ namespace :browser do
cp $BROWSERIFY_DIST, $BROWSERIFY_DIST_LATEST
end
+ task :build_all => :dist_path do
+ sh "MINIFY='' #{$BUILDER} all > dist/aws-sdk-all.js"
+ end
+
task :build_server do
pkg_file = File.dirname(__FILE__) + '/dist-tools/package.json'
json = JSON.parse(File.read(pkg_file))
@@ -59,11 +63,11 @@ namespace :browser do
end
desc 'Builds browser test harness and runner'
- task :test => :dist_path do
+ task :test => [:dist_path, :build_all] do
write_configuration
sh "coffee -c test/helpers.coffee"
sh "find test -name '*.coffee' | SERVICES=all xargs #{$BROWSERIFY} " +
- "-t coffeeify #{$BROWSERIFY_ARGS} > #{$BROWSERIFY_TEST}"
+ "-t coffeeify -i domain > #{$BROWSERIFY_TEST}"
rm_f "test/helpers.js"
rm_f "test/configuration.js"
puts "Now run `testem`"
@@ -88,37 +88,37 @@ describe 'AWS.Credentials', ->
expect(spy.argsForCall[0][0]).toEqual(null)
expect(creds.expired).toEqual(false)
-describe 'AWS.EnvironmentCredentials', ->
- beforeEach ->
- process.env = {}
+if AWS.util.isNode()
+ describe 'AWS.EnvironmentCredentials', ->
+ beforeEach ->
+ process.env = {}
- describe 'constructor', ->
- it 'should be able to read credentials from env with a prefix', ->
- process.env.AWS_ACCESS_KEY_ID = 'akid'
- process.env.AWS_SECRET_ACCESS_KEY = 'secret'
- process.env.AWS_SESSION_TOKEN = 'session'
- creds = new AWS.EnvironmentCredentials('AWS')
- validateCredentials(creds)
-
- it 'should be able to read credentials from env without a prefix', ->
- process.env.ACCESS_KEY_ID = 'akid'
- process.env.SECRET_ACCESS_KEY = 'secret'
- process.env.SESSION_TOKEN = 'session'
- creds = new AWS.EnvironmentCredentials()
- validateCredentials(creds)
+ describe 'constructor', ->
+ it 'should be able to read credentials from env with a prefix', ->
+ process.env.AWS_ACCESS_KEY_ID = 'akid'
+ process.env.AWS_SECRET_ACCESS_KEY = 'secret'
+ process.env.AWS_SESSION_TOKEN = 'session'
+ creds = new AWS.EnvironmentCredentials('AWS')
+ validateCredentials(creds)
- describe 'refresh', ->
- it 'can refresh credentials', ->
- process.env.AWS_ACCESS_KEY_ID = 'akid'
- process.env.AWS_SECRET_ACCESS_KEY = 'secret'
- creds = new AWS.EnvironmentCredentials('AWS')
- expect(creds.accessKeyId).toEqual('akid')
- creds.accessKeyId = 'not_akid'
- expect(creds.accessKeyId).not.toEqual('akid')
- creds.refresh()
- expect(creds.accessKeyId).toEqual('akid')
+ it 'should be able to read credentials from env without a prefix', ->
+ process.env.ACCESS_KEY_ID = 'akid'
+ process.env.SECRET_ACCESS_KEY = 'secret'
+ process.env.SESSION_TOKEN = 'session'
+ creds = new AWS.EnvironmentCredentials()
+ validateCredentials(creds)
+
+ describe 'refresh', ->
+ it 'can refresh credentials', ->
+ process.env.AWS_ACCESS_KEY_ID = 'akid'
+ process.env.AWS_SECRET_ACCESS_KEY = 'secret'
+ creds = new AWS.EnvironmentCredentials('AWS')
+ expect(creds.accessKeyId).toEqual('akid')
+ creds.accessKeyId = 'not_akid'
+ expect(creds.accessKeyId).not.toEqual('akid')
+ creds.refresh()
+ expect(creds.accessKeyId).toEqual('akid')
-if AWS.util.isNode()
describe 'AWS.FileSystemCredentials', ->
describe 'constructor', ->
it 'should accept filename and load credentials from root doc', ->
View
@@ -1,4 +1,9 @@
-AWS = require('../lib/aws')
+AWS = null
+if typeof window == 'undefined'
+ AWS = require('../lib/aws')
+else
+ AWS = window.AWS
+
EventEmitter = require('events').EventEmitter
Buffer = require('buffer').Buffer
semver = require('semver')

0 comments on commit 941014b

Please sign in to comment.