Commit 84fedee6

mo <mokha@cisco.com>
2017-05-04 22:45:10
upgrade teaspoon.
1 parent 8fdd315
config/environments/development.rb
@@ -31,7 +31,7 @@ Rails.application.configure do
   # Asset digests allow you to set far-future HTTP expiration dates on all assets,
   # yet still be able to expire them through the digest params.
   config.assets.digest = false
-  config.assets.prefix = 'dev-assets'
+  #config.assets.prefix = 'dev-assets'
 
   # Adds additional error checking when serving assets at runtime.
   # Checks for improperly declared sprockets dependencies.
spec/javascripts/backbone/models/cake_spec.js.coffee
@@ -1,19 +1,19 @@
 describe "CakeSide.Models.Cake", ->
-  createSUT = (attributes) ->
+  subject = (attributes) ->
     new CakeSide.Models.Cake(attributes)
 
   describe "#validate", ->
     it "returns an error when the name is null", ->
       attributes =
         name: null
-      cake = createSUT(attributes)
+      cake = subject(attributes)
       expect(cake.validate(attributes, {})).not.toBe(null)
       expect(cake.isValid()).toBeFalsy()
 
     it "returns an error when the name is blank", ->
       attributes =
         name: ' '
-      cake = createSUT(attributes)
+      cake = subject(attributes)
       expect(cake.validate(attributes, {})).not.toBe(null)
       expect(cake.isValid()).toBeFalsy()
 
@@ -22,7 +22,7 @@ describe "CakeSide.Models.Cake", ->
       attributes = 
         name: 'hi'
         category_id: null
-      cake = createSUT(attributes)
+      cake = subject(attributes)
       expect(cake.validate(attributes)).not.toBe(null)
       expect(cake.isValid()).toBeFalsy()
 
@@ -30,11 +30,11 @@ describe "CakeSide.Models.Cake", ->
       attributes =
         name: 'hi'
         category_id: 1
-      cake = createSUT(attributes)
+      cake = subject(attributes)
       expect(cake.validate(attributes)).toBeUndefined()
       expect(cake.isValid()).toBeTruthy()
 
   describe "#public_url", ->
     it "returns the correct url", ->
-      result = createSUT(slug: '123-cake').public_url()
+      result = subject(slug: '123-cake').public_url()
       expect(result).toMatch(/^http:\/\/.+\/creations\/123-cake$/)
spec/javascripts/backbone/views/cake_view_spec.js.coffee
@@ -2,15 +2,15 @@ describe "CakeSide.Views.Cakes.CakeView", ->
   cake = new CakeSide.Models.Cake
     id: '1'
     name: 'chocolate'
-  view = new CakeSide.Views.Cakes.CakeView
+  subject = new CakeSide.Views.Cakes.CakeView
     model: cake
 
   describe "when there are no photos", ->
     beforeEach ->
-      view.render()
+      subject.render()
 
     it 'renders the cake', ->
-      expect(view.$el.html()).toMatch(/chocolate/)
+      expect(subject.$el.html()).toMatch(/chocolate/)
 
     it 'does not display any photos', ->
-      expect(view.$el.html()).not.toMatch(/img/)
+      expect(subject.$el.html()).not.toMatch(/img/)
spec/javascripts/spec_helper.coffee
@@ -1,12 +1,17 @@
 # Teaspoon includes some support files, but you can use anything from your own support path too.
 # require support/jasmine-jquery-1.7.0
 # require support/jasmine-jquery-2.0.0
+# require support/jasmine-jquery-2.1.0
 # require support/sinon
 # require support/your-support-file
 #
 # PhantomJS (Teaspoons default driver) doesn't have support for Function.prototype.bind, which has caused confusion.
 # Use this polyfill to avoid the confusion.
-#= require support/bind-poly
+#= require support/phantomjs-shims
+#
+# You can require your own javascript files here. By default this will include everything in application, however you
+# may get better load performance if you require the specific files that are being used in the spec that tests them.
+#= require application
 #
 # Deferring execution
 # If you're using CommonJS, RequireJS or some other asynchronous library you can defer execution. Call
@@ -18,14 +23,10 @@
 # Matching files
 # By default Teaspoon will look for files that match _spec.{js,js.coffee,.coffee}. Add a filename_spec.js file in your
 # spec path and it'll be included in the default suite automatically. If you want to customize suites, check out the
-# configuration in config/initializers/teaspoon.rb
+# configuration in teaspoon_env.rb
 #
 # Manifest
 # If you'd rather require your spec files manually (to control order for instance) you can disable the suite matcher in
 # the configuration and use this file as a manifest.
 #
 # For more information: http://github.com/modeset/teaspoon
-#
-# You can require your own javascript files here. By default this will include everything in application, however you
-# may get better load performance if you require the specific files that are being used in the spec that tests them.
-#= require application
spec/javascripts/spec_helper.js
@@ -1,31 +0,0 @@
-// Teaspoon includes some support files, but you can use anything from your own support path too.
-// require support/jasmine-jquery-1.7.0
-// require support/jasmine-jquery-2.0.0
-// require support/sinon
-// require support/your-support-file
-//
-// PhantomJS (Teaspoons default driver) doesn't have support for Function.prototype.bind, which has caused confusion.
-// Use this polyfill to avoid the confusion.
-//= require support/bind-poly
-//
-// Deferring execution
-// If you're using CommonJS, RequireJS or some other asynchronous library you can defer execution. Call
-// Teaspoon.execute() after everything has been loaded. Simple example of a timeout:
-//
-// Teaspoon.defer = true
-// setTimeout(Teaspoon.execute, 1000)
-//
-// Matching files
-// By default Teaspoon will look for files that match _spec.{js,js.coffee,.coffee}. Add a filename_spec.js file in your
-// spec path and it'll be included in the default suite automatically. If you want to customize suites, check out the
-// configuration in config/initializers/teaspoon.rb
-//
-// Manifest
-// If you'd rather require your spec files manually (to control order for instance) you can disable the suite matcher in
-// the configuration and use this file as a manifest.
-//
-// For more information: http://github.com/modeset/teaspoon
-//
-// You can require your own javascript files here. By default this will include everything in application, however you
-// may get better load performance if you require the specific files that are being used in the spec that tests them.
-//= require application
spec/teaspoon_env.rb
@@ -1,28 +1,20 @@
-# Set RAILS_ROOT and load the environment if it's not already loaded.
-unless defined?(Rails)
-  ENV["RAILS_ROOT"] = File.expand_path("../../", __FILE__)
-  require File.expand_path("../../config/environment", __FILE__)
-end
-
-Rails.application.config.assets.precompile += %w( teaspoon.css jasmine/1.3.1.js teaspoon-jasmine.js )
 Teaspoon.configure do |config|
-
   # Determines where the Teaspoon routes will be mounted. Changing this to "/jasmine" would allow you to browse to
   # `http://localhost:3000/jasmine` to run your tests.
-  #config.mount_at = "/teaspoon"
+  config.mount_at = "/teaspoon"
 
   # Specifies the root where Teaspoon will look for files. If you're testing an engine using a dummy application it can
   # be useful to set this to your engines root (e.g. `Teaspoon::Engine.root`).
   # Note: Defaults to `Rails.root` if nil.
-  #config.root = nil
+  config.root = nil
 
   # Paths that will be appended to the Rails assets paths
   # Note: Relative to `config.root`.
-  #config.asset_paths = ["spec/javascripts", "spec/javascripts/stylesheets"]
+  config.asset_paths = ["spec/javascripts", "spec/javascripts/stylesheets"]
 
   # Fixtures are rendered through a controller, which allows using HAML, RABL/JBuilder, etc. Files in these paths will
   # be rendered as fixtures.
-  #config.fixture_paths = ["spec/javascripts/fixtures"]
+  config.fixture_paths = ["spec/javascripts/fixtures"]
 
   # SUITES
   #
@@ -36,57 +28,55 @@ Teaspoon.configure do |config|
   # - with the rake task: rake teaspoon suite=[suite_name]
   # - with the cli: teaspoon --suite=[suite_name]
   config.suite do |suite|
-
     # Specify the framework you would like to use. This allows you to select versions, and will do some basic setup for
     # you -- which you can override with the directives below. This should be specified first, as it can override other
     # directives.
     # Note: If no version is specified, the latest is assumed.
     #
-    # Available: jasmine[1.3.1, 2.0.0], mocha[1.10.0, 1.17.1] qunit[1.12.0, 1.14.0]
-    suite.use_framework :jasmine, "1.3.1"
+    # Versions: 1.3.1, 2.0.3, 2.1.3, 2.2.0, 2.2.1, 2.3.4
+    suite.use_framework :jasmine, "2.3.4"
 
     # Specify a file matcher as a regular expression and all matching files will be loaded when the suite is run. These
     # files need to be within an asset path. You can add asset paths using the `config.asset_paths`.
-    #suite.matcher = "{spec/javascripts,app/assets}/**/*_spec.{js,js.coffee,coffee}"
-
-    # This suites spec helper, which can require additional support files. This file is loaded before any of your test
-    # files are loaded.
-    #suite.helper = "spec_helper"
+    suite.matcher = "{spec/javascripts,app/assets}/**/*_spec.{js,js.coffee,coffee}"
 
-    # The core Teaspoon javascripts. It's recommended to include only the base files here, as you can require support
-    # libraries from your spec helper.
-    # Note: For CoffeeScript files use `"teaspoon/jasmine"` etc.
-    #
-    # Available: teaspoon-jasmine, teaspoon-mocha, teaspoon-qunit
-    #suite.javascripts = ["jasmine/1.3.1", "teaspoon-jasmine"]
+    # Load additional JS files, but requiring them in your spec helper is the preferred way to do this.
+    #suite.javascripts = []
 
     # You can include your own stylesheets if you want to change how Teaspoon looks.
     # Note: Spec related CSS can and should be loaded using fixtures.
     #suite.stylesheets = ["teaspoon"]
 
+    # This suites spec helper, which can require additional support files. This file is loaded before any of your test
+    # files are loaded.
+    suite.helper = "spec_helper"
+
     # Partial to be rendered in the head tag of the runner. You can use the provided ones or define your own by creating
     # a `_boot.html.erb` in your fixtures path, and adjust the config to `"/boot"` for instance.
     #
     # Available: boot, boot_require_js
-    #suite.boot_partial = "boot"
+    suite.boot_partial = "boot"
 
     # Partial to be rendered in the body tag of the runner. You can define your own to create a custom body structure.
-    #suite.body_partial = "body"
-
-    # Assets to be ignored when generating coverage reports. Accepts an array of filenames or regular expressions. The
-    # default excludes assets from vendor, gems and support libraries.<br/><br/>
-    #suite.no_coverage = [%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}]
+    suite.body_partial = "body"
 
     # Hooks allow you to use `Teaspoon.hook("fixtures")` before, after, or during your spec run. This will make a
     # synchronous Ajax request to the server that will call all of the blocks you've defined for that hook name.
-    #suite.hook :fixtures, proc{ }
+    #suite.hook :fixtures, &proc{}
 
+    # Determine whether specs loaded into the test harness should be embedded as individual script tags or concatenated
+    # into a single file. Similar to Rails' asset `debug: true` and `config.assets.debug = true` options. By default, 
+    # Teaspoon expands all assets to provide more valuable stack traces that reference individual source files.
+    #suite.expand_assets = true
+
+    # Non-.js file extensions Teaspoon should consider JavaScript files
+    #suite.js_extensions = [/(\.js)?.coffee/, /(\.js)?.es6/, ".es6.js"]
   end
 
   # Example suite. Since we're just filtering to files already within the root test/javascripts, these files will also
   # be run in the default suite -- but can be focused into a more specific suite.
   #config.suite :targeted do |suite|
-  #  suite.matcher = "test/javascripts/targeted/*_test.{js,js.coffee,coffee}"
+  #  suite.matcher = "spec/javascripts/targeted/*_spec.{js,js.coffee,coffee}"
   #end
 
   # CONSOLE RUNNER SPECIFIC
@@ -101,17 +91,21 @@ Teaspoon.configure do |config|
   # Rake:
   # teaspoon DRIVER=phantomjs SERVER_PORT=31337 FAIL_FAST=true FORMATTERS=junit suite=my_suite
 
-  # Specify which headless driver to use. Supports PhantomJS and Selenium Webdriver.
+  # Specify which headless driver to use. Supports PhantomJS, Selenium Webdriver and BrowserStack Webdriver.
   #
-  # Available: phantomjs, selenium
+  # Available: :phantomjs, :selenium, :browserstack, :capybara_webkit
   # PhantomJS: https://github.com/modeset/teaspoon/wiki/Using-PhantomJS
   # Selenium Webdriver: https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver
-  #config.driver = "phantomjs"
+  # BrowserStack Webdriver: https://github.com/modeset/teaspoon/wiki/Using-BrowserStack-WebDriver
+  # Capybara Webkit: https://github.com/modeset/teaspoon/wiki/Using-Capybara-Webkit
+  #config.driver = :phantomjs
 
   # Specify additional options for the driver.
   #
   # PhantomJS: https://github.com/modeset/teaspoon/wiki/Using-PhantomJS
   # Selenium Webdriver: https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver
+  # BrowserStack Webdriver: https://github.com/modeset/teaspoon/wiki/Using-BrowserStack-WebDriver
+  # Capybara Webkit: https://github.com/modeset/teaspoon/wiki/Using-Capybara-Webkit
   #config.driver_options = nil
 
   # Specify the timeout for the driver. Specs are expected to complete within this time frame or the run will be
@@ -121,6 +115,9 @@ Teaspoon.configure do |config|
   # Specify a server to use with Rack (e.g. thin, mongrel). If nil is provided Rack::Server is used.
   #config.server = nil
 
+  # Specify a host to run on a specific host, otherwise Teaspoon will use 127.0.0.1.
+  #config.server_host = nil
+
   # Specify a port to run on a specific port, otherwise Teaspoon will use a random available port.
   #config.server_port = nil
 
@@ -135,8 +132,8 @@ Teaspoon.configure do |config|
   # Specify the formatters to use when outputting the results.
   # Note: Output files can be specified by using `"junit>/path/to/output.xml"`.
   #
-  # Available: dot, documentation, clean, json, junit, pride, snowday, swayze_or_oprah, tap, tap_y, teamcity
-  #config.formatters = ["dot"]
+  # Available: :dot, :clean, :documentation, :json, :junit, :pride, :rspec_html, :snowday, :swayze_or_oprah, :tap, :tap_y, :teamcity
+  #config.formatters = [:dot]
 
   # Specify if you want color output from the formatters.
   #config.color = true
@@ -157,19 +154,27 @@ Teaspoon.configure do |config|
   # - with the rake task: rake teaspoon USE_COVERAGE=[coverage_name]
   # - with the cli: teaspoon --coverage=[coverage_name]
 
-  # Specify that you always want a coverage configuration to be used.
+  # Specify that you always want a coverage configuration to be used. Otherwise, specify that you want coverage
+  # on the CLI.
+  # Set this to "true" or the name of your coverage config.
   #config.use_coverage = nil
 
+  # You can have multiple coverage configs by passing a name to config.coverage.
+  # e.g. config.coverage :ci do |coverage|
+  # The default coverage config name is :default.
   config.coverage do |coverage|
-
-    # Which coverage reports Instanbul should generate. Correlates directly to what Istanbul supports.
+    # Which coverage reports Istanbul should generate. Correlates directly to what Istanbul supports.
     #
     # Available: text-summary, text, html, lcov, lcovonly, cobertura, teamcity
     #coverage.reports = ["text-summary", "html"]
 
     # The path that the coverage should be written to - when there's an artifact to write to disk.
     # Note: Relative to `config.root`.
-    #coverage.output_dir = "coverage"
+    #coverage.output_path = "coverage"
+
+    # Assets to be ignored when generating coverage reports. Accepts an array of filenames or regular expressions. The
+    # default excludes assets from vendor, gems and support libraries.
+    #coverage.ignore = [%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}]
 
     # Various thresholds requirements can be defined, and those thresholds will be checked at the end of a run. If any
     # aren't met the run will fail with a message. Thresholds can be defined as a percentage (0-100), or nil.
@@ -177,7 +182,5 @@ Teaspoon.configure do |config|
     #coverage.functions = nil
     #coverage.branches = nil
     #coverage.lines = nil
-
   end
-
 end