teaspoon 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ class Teaspoon.Fixture
2
2
 
3
3
  @cache: {}
4
4
  @el: null
5
- @$el: null # will only be defined if window.$ is defined.
5
+ @$el: null # will only be defined if window.jQuery is defined.
6
6
  @json: []
7
7
 
8
8
  # Public API
@@ -70,7 +70,7 @@ class Teaspoon.Fixture
70
70
  create() unless window.fixture.el
71
71
 
72
72
  if jQueryAvailable()
73
- parsed = $($.parseHTML(content, document, true))
73
+ parsed = jQuery(jQuery.parseHTML(content, document, true))
74
74
  window.fixture.el.appendChild(parsed[i]) for i in [0...parsed.length]
75
75
  else
76
76
  window.fixture.el.innerHTML += content
@@ -78,7 +78,7 @@ class Teaspoon.Fixture
78
78
 
79
79
  create = =>
80
80
  window.fixture.el = document.createElement("div")
81
- window.fixture.$el = $(window.fixture.el) if jQueryAvailable()
81
+ window.fixture.$el = jQuery(window.fixture.el) if jQueryAvailable()
82
82
  window.fixture.el.id = "teaspoon-fixtures"
83
83
  document.body?.appendChild(window.fixture.el)
84
84
 
@@ -105,4 +105,4 @@ class Teaspoon.Fixture
105
105
 
106
106
 
107
107
  jQueryAvailable = ->
108
- typeof(window.$) == 'function'
108
+ typeof(window.jQuery) == 'function'
@@ -1,4 +1,4 @@
1
- <%= javascript_include_tag *@suite.spec_assets, debug: @suite.config.expand_assets %>
1
+ <%= javascript_include_tag *@suite.spec_assets, debug: @suite.config.expand_assets, allow_non_precompiled: true %>
2
2
  <script type="text/javascript">
3
3
  Teaspoon.onWindowLoad(Teaspoon.execute);
4
4
  </script>
@@ -113,6 +113,9 @@ Teaspoon.configure do |config|
113
113
  # Specify a server to use with Rack (e.g. thin, mongrel). If nil is provided Rack::Server is used.
114
114
  #config.server = nil
115
115
 
116
+ # Specify a host to run on a specific host, otherwise Teaspoon will use 127.0.0.1.
117
+ #config.server_host = nil
118
+
116
119
  # Specify a port to run on a specific port, otherwise Teaspoon will use a random available port.
117
120
  #config.server_port = nil
118
121
 
@@ -69,6 +69,14 @@ module Teaspoon
69
69
  end
70
70
  end
71
71
 
72
+ if !loaded_from_teaspoon_root?
73
+ Rake::Task["release"].clear
74
+ end
75
+
76
+ desc "Build and push teaspoon-#{framework} to Rubygems\n"
77
+ task "release" => ["build", "release:guard_clean", "release:rubygem_push"] do
78
+ end
79
+
72
80
  if !loaded_from_teaspoon_root?
73
81
  Rake::Task["default"].prerequisites.clear
74
82
  Rake::Task["default"].clear
@@ -56,6 +56,9 @@ module Teaspoon
56
56
  "Sets server to use with Rack.",
57
57
  " e.g. webrick, thin"
58
58
 
59
+ opt :server_host, "--server-host HOST",
60
+ "Sets the server to use a specific host."
61
+
59
62
  opt :server_port, "--server-port PORT",
60
63
  "Sets the server to use a specific port."
61
64
 
@@ -25,13 +25,14 @@ module Teaspoon
25
25
 
26
26
  # console runner specific
27
27
 
28
- cattr_accessor :driver, :driver_options, :driver_timeout, :server, :server_port, :server_timeout, :fail_fast,
28
+ cattr_accessor :driver, :driver_options, :driver_timeout, :server, :server_host, :server_port, :server_timeout, :fail_fast,
29
29
  :formatters, :color, :suppress_log,
30
30
  :use_coverage
31
31
  @@driver = Teaspoon::Driver.default
32
32
  @@driver_options = nil
33
33
  @@driver_timeout = 180
34
34
  @@server = nil
35
+ @@server_host = nil
35
36
  @@server_port = nil
36
37
  @@server_timeout = 20
37
38
  @@fail_fast = true
@@ -13,9 +13,12 @@ module Teaspoon
13
13
  @data = data
14
14
  @executable = Teaspoon::Instrumentation.executable
15
15
  @config = self.class.configuration
16
+
17
+ raise Teaspoon::CoverageResultsNotFoundError unless @data
16
18
  end
17
19
 
18
20
  def generate_reports(&block)
21
+
19
22
  input_path do |input|
20
23
  results = []
21
24
  @config.reports.each do |format|
@@ -95,3 +95,24 @@ module Teaspoon
95
95
  end
96
96
  end
97
97
  end
98
+
99
+ begin
100
+ require 'action_view'
101
+ if ActionView::VERSION::STRING == '4.2.5'
102
+ require 'action_view/helpers/asset_tag_helper'
103
+ module ActionView::Helpers::AssetTagHelper
104
+ def javascript_include_tag(*sources)
105
+ options = sources.extract_options!.stringify_keys
106
+ path_options = options.extract!('protocol', 'extname').symbolize_keys
107
+ path_options[:debug] = options['allow_non_precompiled']
108
+ sources.uniq.map { |source|
109
+ tag_options = {
110
+ "src" => path_to_javascript(source, path_options)
111
+ }.merge!(options)
112
+ content_tag(:script, "", tag_options)
113
+ }.join("\n").html_safe
114
+ end
115
+ end
116
+ end
117
+ rescue
118
+ end
@@ -151,4 +151,11 @@ module Teaspoon
151
151
  super(msg)
152
152
  end
153
153
  end
154
+
155
+ class CoverageResultsNotFoundError < Teaspoon::Error
156
+ def initialize(msg = nil)
157
+ msg ||= "You requested coverage reports, but no results were found. Are all files being ignored in your coverage config? If you have expand_assets set to false, you will need to remove spec_helper from the ignore list."
158
+ super(msg)
159
+ end
160
+ end
154
161
  end
@@ -145,7 +145,8 @@ module Teaspoon
145
145
 
146
146
  def filename(file)
147
147
  uri = URI(file)
148
- params = uri.query.split("&").reject do |param|
148
+
149
+ params = String(uri.query).split("&").reject do |param|
149
150
  RESERVED_PARAMS.include?(param.split("=").first)
150
151
  end
151
152
 
@@ -4,9 +4,10 @@ require "webrick"
4
4
 
5
5
  module Teaspoon
6
6
  class Server
7
- attr_accessor :port
7
+ attr_accessor :port, :host
8
8
 
9
9
  def initialize
10
+ @host = Teaspoon.configuration.server_host || "127.0.0.1"
10
11
  @port = Teaspoon.configuration.server_port || find_available_port
11
12
  end
12
13
 
@@ -24,14 +25,14 @@ module Teaspoon
24
25
  end
25
26
 
26
27
  def responsive?
27
- TCPSocket.new("127.0.0.1", port).close
28
+ TCPSocket.new(host, port).close
28
29
  true
29
30
  rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
30
31
  false
31
32
  end
32
33
 
33
34
  def url
34
- "http://127.0.0.1:#{port}"
35
+ "http://#{host}:#{port}"
35
36
  end
36
37
 
37
38
  protected
@@ -54,6 +55,7 @@ module Teaspoon
54
55
  def rack_options
55
56
  {
56
57
  app: Rails.application,
58
+ Host: host,
57
59
  Port: port,
58
60
  environment: "test",
59
61
  AccessLog: [],
@@ -63,7 +65,7 @@ module Teaspoon
63
65
  end
64
66
 
65
67
  def find_available_port
66
- server = TCPServer.new("127.0.0.1", 0)
68
+ server = TCPServer.new(host, 0)
67
69
  server.addr[1]
68
70
  ensure
69
71
  server.close if server
@@ -1,3 +1,3 @@
1
1
  module Teaspoon
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teaspoon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - jejacks0n
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-10-09 00:00:00.000000000 Z
14
+ date: 2016-01-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: railties
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  requirements: []
151
151
  rubyforge_project:
152
- rubygems_version: 2.4.6
152
+ rubygems_version: 2.4.5
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: 'Teaspoon: A Javascript test runner built on top of Rails'