hyper-spec 0.1.1 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2934f3c0c220b8178be5364c372de4474fba2b74
4
- data.tar.gz: add452cd5e700a0540b8c97253176f55ff9eecfc
3
+ metadata.gz: a644db6a221bc30f343b05e079c705269a90871d
4
+ data.tar.gz: f6c9c28bbb47e6e39c5f7f3b88304da9df0ac8b8
5
5
  SHA512:
6
- metadata.gz: 0793765d331c7070e355331de5528ed2333d98a48900569877a4a10c7e198a214ff5150db6eddf9ec6d4956b41f39b268a43573669f4e3500615abee86a9253e
7
- data.tar.gz: 528748ad43262c8bb341306c3308be71054f81f152d96bb6cec3ef17059dcc86796b518a6e46b13b7ec08e5594a9dba22ca8e8e0cadd085131f4034ba3b65626
6
+ metadata.gz: de46555fb469983fba0b02f24fdd2439826f4dbca419b1e2fe53281fa62ed9512a077ec579900c0638ac1d85ac7d5f4ce130e8168c1b14343cc06775ae4c0872
7
+ data.tar.gz: ac2b3168d21fa3993e0af01f25fc5fe4129532a8f77cf4ff167092355d17be25d0a587286c9188bebee650a3e785c718bf1e39bc943c9227dcdb1503381956f0
data/.gitignore CHANGED
@@ -42,3 +42,10 @@ bower.json
42
42
 
43
43
  # Ignore Byebug command history file.
44
44
  .byebug_history
45
+
46
+ # Ignore test app files
47
+ /spec/test_app/log/
48
+ /spec/test_app/tmp/
49
+
50
+ # Ignore built gem
51
+ *.gem
@@ -0,0 +1,107 @@
1
+ Style/BlockDelimiters:
2
+ EnforcedStyle: line_count_based
3
+ SupportedStyles:
4
+ # The `line_count_based` style enforces braces around single line blocks and
5
+ # do..end around multi-line blocks.
6
+ - line_count_based
7
+ # The `semantic` style enforces braces around functional blocks, where the
8
+ # primary purpose of the block is to return a value and do..end for
9
+ # procedural blocks, where the primary purpose of the block is its
10
+ # side-effects.
11
+ #
12
+ # This looks at the usage of a block's method to determine its type (e.g. is
13
+ # the result of a `map` assigned to a variable or passed to another
14
+ # method) but exceptions are permitted in the `ProceduralMethods`,
15
+ # `FunctionalMethods` and `IgnoredMethods` sections below.
16
+ - semantic
17
+ # The `braces_for_chaining` style enforces braces around single line blocks
18
+ # and do..end around multi-line blocks, except for multi-line blocks whose
19
+ # return value is being chained with another method (in which case braces
20
+ # are enforced).
21
+ - braces_for_chaining
22
+ ProceduralMethods:
23
+ # Methods that are known to be procedural in nature but look functional from
24
+ # their usage, e.g.
25
+ #
26
+ # time = Benchmark.realtime do
27
+ # foo.bar
28
+ # end
29
+ #
30
+ # Here, the return value of the block is discarded but the return value of
31
+ # `Benchmark.realtime` is used.
32
+ - benchmark
33
+ - bm
34
+ - bmbm
35
+ - create
36
+ - each_with_object
37
+ - measure
38
+ - new
39
+ - realtime
40
+ - tap
41
+ - with_object
42
+ FunctionalMethods:
43
+ # Methods that are known to be functional in nature but look procedural from
44
+ # their usage, e.g.
45
+ #
46
+ # let(:foo) { Foo.new }
47
+ #
48
+ # Here, the return value of `Foo.new` is used to define a `foo` helper but
49
+ # doesn't appear to be used from the return value of `let`.
50
+ - let
51
+ - let!
52
+ - subject
53
+ - watch
54
+ IgnoredMethods:
55
+ # Methods that can be either procedural or functional and cannot be
56
+ # categorised from their usage alone, e.g.
57
+ #
58
+ # foo = lambda do |x|
59
+ # puts "Hello, #{x}"
60
+ # end
61
+ #
62
+ # foo = lambda do |x|
63
+ # x * 100
64
+ # end
65
+ #
66
+ # Here, it is impossible to tell from the return value of `lambda` whether
67
+ # the inner block's return value is significant.
68
+ - lambda
69
+ - proc
70
+ - it
71
+
72
+ Style/Documentation:
73
+ Description: 'Document classes and non-namespace modules.'
74
+ Enabled: false
75
+ Exclude:
76
+ - 'spec/**/*'
77
+ - 'test/**/*'
78
+
79
+ # Multi-line method chaining should be done with trailing dots.
80
+ Style/DotPosition:
81
+ EnforcedStyle: leading
82
+ SupportedStyles:
83
+ - leading
84
+ - trailing
85
+
86
+ Style/FrozenStringLiteralComment:
87
+ Description: >-
88
+ Add the frozen_string_literal comment to the top of files
89
+ to help transition from Ruby 2.3.0 to Ruby 3.0.
90
+ Enabled: false
91
+
92
+ Style/MultilineBlockChain:
93
+ Description: 'Avoid multi-line chains of blocks.'
94
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
95
+ Enabled: false
96
+
97
+ Style/MutableConstant:
98
+ Description: 'Do not assign mutable objects to constants.'
99
+ Enabled: false
100
+
101
+ Metrics/AbcSize:
102
+ # The ABC size is a calculated magnitude, so this number can be a Fixnum or
103
+ # a Float.
104
+ Max: 20
105
+
106
+ Metrics/LineLength:
107
+ Max: 100
@@ -1,9 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hyper-spec (0.1.0)
5
- hyper-react (>= 0.10.0)
6
- rails
4
+ hyper-spec (0.1.2)
5
+ capybara
6
+ opal
7
+ parser
8
+ poltergeist
9
+ pry
10
+ rspec-rails
11
+ selenium-webdriver (= 2.53.4)
12
+ timecop
13
+ unparser (= 0.2.5)
7
14
 
8
15
  GEM
9
16
  remote: https://rubygems.org/
@@ -60,14 +67,14 @@ GEM
60
67
  babel-source (>= 4.0, < 6)
61
68
  execjs (~> 2.0)
62
69
  builder (3.2.3)
63
- capybara (2.10.1)
70
+ capybara (2.13.0)
64
71
  addressable
65
72
  mime-types (>= 1.16)
66
73
  nokogiri (>= 1.3.3)
67
74
  rack (>= 1.0.0)
68
75
  rack-test (>= 0.5.4)
69
76
  xpath (~> 2.0)
70
- childprocess (0.6.1)
77
+ childprocess (0.6.2)
71
78
  ffi (~> 1.0, >= 1.0.11)
72
79
  chromedriver-helper (1.0.0)
73
80
  archive-zip (~> 0.7.0)
@@ -84,7 +91,7 @@ GEM
84
91
  equalizer (0.0.11)
85
92
  erubis (2.7.0)
86
93
  execjs (2.7.0)
87
- ffi (1.9.17)
94
+ ffi (1.9.18)
88
95
  globalid (0.3.7)
89
96
  activesupport (>= 4.1.0)
90
97
  hike (1.2.3)
@@ -142,17 +149,18 @@ GEM
142
149
  paggio (0.2.6)
143
150
  parser (2.3.3.1)
144
151
  ast (~> 2.2)
145
- poltergeist (1.11.0)
152
+ poltergeist (1.14.0)
146
153
  capybara (~> 2.1)
147
154
  cliver (~> 0.3.1)
148
155
  websocket-driver (>= 0.2.0)
156
+ powerpack (0.1.1)
149
157
  procto (0.0.3)
150
158
  pry (0.10.4)
151
159
  coderay (~> 1.1.0)
152
160
  method_source (~> 0.8.1)
153
161
  slop (~> 3.4)
154
162
  public_suffix (2.0.5)
155
- puma (3.6.2)
163
+ puma (3.7.0)
156
164
  rack (2.0.1)
157
165
  rack-test (0.6.3)
158
166
  rack (>= 1.0)
@@ -179,6 +187,7 @@ GEM
179
187
  method_source
180
188
  rake (>= 0.8.7)
181
189
  thor (>= 0.18.1, < 2.0)
190
+ rainbow (2.2.1)
182
191
  rake (10.5.0)
183
192
  react-rails (1.4.2)
184
193
  babel-transpiler (>= 0.7.0)
@@ -192,7 +201,7 @@ GEM
192
201
  rspec-core (~> 3.5.0)
193
202
  rspec-expectations (~> 3.5.0)
194
203
  rspec-mocks (~> 3.5.0)
195
- rspec-collection_matchers (1.1.2)
204
+ rspec-collection_matchers (1.1.3)
196
205
  rspec-expectations (>= 2.99.0.beta1)
197
206
  rspec-core (3.5.4)
198
207
  rspec-support (~> 3.5.0)
@@ -216,7 +225,14 @@ GEM
216
225
  rspec-steps (2.1.1)
217
226
  rspec (>= 3.0, < 3.99)
218
227
  rspec-support (3.5.0)
219
- rubyzip (1.2.0)
228
+ rubocop (0.47.1)
229
+ parser (>= 2.3.3.1, < 3.0)
230
+ powerpack (~> 0.1)
231
+ rainbow (>= 1.99.1, < 3.0)
232
+ ruby-progressbar (~> 1.7)
233
+ unicode-display_width (~> 1.0, >= 1.0.1)
234
+ ruby-progressbar (1.8.1)
235
+ rubyzip (1.2.1)
220
236
  selenium-webdriver (2.53.4)
221
237
  childprocess (~> 0.5)
222
238
  rubyzip (~> 1.0)
@@ -224,7 +240,7 @@ GEM
224
240
  shoulda (3.5.0)
225
241
  shoulda-context (~> 1.0, >= 1.0.1)
226
242
  shoulda-matchers (>= 1.4.1, < 3.0)
227
- shoulda-context (1.2.1)
243
+ shoulda-context (1.2.2)
228
244
  shoulda-matchers (2.8.0)
229
245
  activesupport (>= 3.0.0)
230
246
  slop (3.6.0)
@@ -249,6 +265,7 @@ GEM
249
265
  timecop (0.8.1)
250
266
  tzinfo (1.2.2)
251
267
  thread_safe (~> 0.1)
268
+ unicode-display_width (1.1.3)
252
269
  unparser (0.2.5)
253
270
  abstract_type (~> 0.0.7)
254
271
  adamantium (~> 0.2.0)
@@ -269,32 +286,26 @@ PLATFORMS
269
286
 
270
287
  DEPENDENCIES
271
288
  bundler (~> 1.12)
272
- capybara
273
289
  chromedriver-helper
290
+ hyper-react (>= 0.10.0)
274
291
  hyper-spec!
275
292
  method_source
276
293
  opal-browser
277
294
  opal-rails
278
- parser
279
- poltergeist
280
- pry
281
295
  puma
282
296
  rails (~> 5.0.0)
283
297
  rake (~> 10.0)
284
- react-rails (~> 1.4.0)
298
+ react-rails (< 1.10.0)
285
299
  rspec-collection_matchers
286
300
  rspec-expectations
287
301
  rspec-its
288
302
  rspec-mocks
289
- rspec-rails
290
303
  rspec-steps
291
- selenium-webdriver (= 2.53.4)
304
+ rubocop
292
305
  shoulda
293
306
  shoulda-matchers
294
307
  spring-commands-rspec
295
308
  therubyracer (= 0.12.2)
296
- timecop
297
- unparser (= 0.2.5)
298
309
 
299
310
  BUNDLED WITH
300
311
  1.12.5
data/README.md CHANGED
@@ -350,6 +350,11 @@ See the Timecop [README](https://github.com/travisjeffery/timecop/blob/master/RE
350
350
 
351
351
  There is one confusing thing to note: On the server if you `sleep` then you will sleep for the specified number of seconds when viewed *outside* of the test. However inside the test environment if you look at Time.now, you will see it advancing according to the scale factor. Likewise if you have a `after` or `every` block on the client, you will wait according to *simulated* time.
352
352
 
353
+ ## Common Problems
354
+
355
+ If you are getting failures on Poltergeist but not Firefox, make sure you are not requiring `browser` in your components.rb.
356
+ Requiring `browser/interval` or `browser/delay` is okay.
357
+
353
358
  ## Development
354
359
 
355
360
  After checking out the repo, run bundle install and you should be good to go.
@@ -1,68 +1,72 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path('../lib/', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'hyper-spec/version'
5
5
 
6
- Gem::Specification.new do |spec|
7
- spec.name = "hyper-spec"
6
+ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
7
+ spec.name = 'hyper-spec'
8
8
  spec.version = HyperSpec::VERSION
9
- spec.authors = ["catmando"]
10
- spec.email = ["mitch@catprint.com"]
9
+ spec.authors = ['catmando', 'adamcreekroad']
10
+ spec.email = ['mitch@catprint.com']
11
11
 
12
- spec.summary = "Drive your Hyperloop client and server specs from RSpec and Capybara"
13
- spec.description = "A Hyperloop application consists of isomorphic React Components, Active Record Models, Stores, Operations and Policiespec. "\
14
- "Test them all from Rspec, regardless if the code runs on the client or server."
15
- spec.homepage = "https://github.com/ruby-hyperloop/hyper-spec"
16
- spec.license = "MIT"
12
+ spec.summary =
13
+ 'Drive your Hyperloop client and server specs from RSpec and Capybara'
14
+ spec.description =
15
+ 'A Hyperloop application consists of isomorphic React Components, '\
16
+ 'Active Record Models, Stores, Operations and Policiespec. '\
17
+ 'Test them all from Rspec, regardless if the code runs on the client or server.'
18
+ spec.homepage = 'https://github.com/ruby-hyperloop/hyper-spec'
19
+ spec.license = 'MIT'
17
20
 
18
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
- spec.bindir = "exe"
20
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ["lib"]
22
-
23
- spec.add_development_dependency "bundler", "~> 1.12"
24
- spec.add_development_dependency "rake", "~> 10.0"
21
+ # Prevent pushing this gem to RubyGemspec.org. To allow pushes either set the 'allowed_push_host'
22
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
23
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
25
24
 
26
- spec.add_dependency 'hyper-react', '>= 0.10.0'
25
+ spec.files =
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ spec.bindir = 'exe'
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ['lib']
27
30
 
28
- spec.add_development_dependency 'rspec-rails'
31
+ # Test app dependencies
32
+ spec.add_development_dependency 'bundler', '~> 1.12'
33
+ spec.add_development_dependency 'hyper-react', '>= 0.10.0'
34
+ spec.add_development_dependency 'rails', '~>5.0.0'
35
+ spec.add_development_dependency 'rake', '~> 10.0'
36
+ spec.add_development_dependency 'react-rails', '< 1.10.0'
29
37
 
30
- # For Test Rails App
31
- spec.add_development_dependency 'rails', '~>5.0.0' #'4.2.4'
32
- spec.add_development_dependency 'react-rails', '~> 1.4.0'
33
- spec.add_development_dependency 'opal-rails'
34
- # spec.add_development_dependency 'opal-activesupport'
35
- # spec.add_development_dependency 'factory_girl_rails'
36
- # spec.add_development_dependency 'reactrb-rails-generator'
37
- # spec.add_development_dependency 'rspec-wait'
38
- spec.add_development_dependency 'puma'
38
+ # Keep linter-rubocop happy
39
+ spec.add_development_dependency 'rubocop'
39
40
 
40
41
  if RUBY_PLATFORM == 'java'
41
42
  spec.add_development_dependency 'therubyrhino'
42
43
  else
43
44
  spec.add_development_dependency 'therubyracer', '0.12.2'
44
45
 
45
- # The following allow react code to be tested from the server side
46
- spec.add_development_dependency 'rspec-mocks'
47
- spec.add_development_dependency 'rspec-expectations'
46
+ # Actual dependencies
47
+ spec.add_dependency 'capybara'
48
+ spec.add_dependency 'opal'
49
+ spec.add_dependency 'parser'
50
+ spec.add_dependency 'poltergeist'
51
+ spec.add_dependency 'pry'
52
+ spec.add_dependency 'rspec-rails'
53
+ spec.add_dependency 'selenium-webdriver', '2.53.4'
54
+ spec.add_dependency 'timecop'
55
+ spec.add_dependency 'unparser', '0.2.5'
48
56
 
49
- # spec.add_development_dependency 'factory_girl_rails'
50
- spec.add_development_dependency 'shoulda'
51
- spec.add_development_dependency 'shoulda-matchers'
52
- spec.add_development_dependency 'rspec-its'
53
- spec.add_development_dependency 'rspec-collection_matchers'
54
- spec.add_development_dependency 'capybara'
55
- spec.add_development_dependency 'selenium-webdriver', '2.53.4'
56
- spec.add_development_dependency 'poltergeist'
57
- spec.add_development_dependency 'spring-commands-rspec'
57
+ # Test app dependencies
58
58
  spec.add_development_dependency 'chromedriver-helper'
59
- spec.add_development_dependency 'parser'
60
- spec.add_development_dependency 'unparser', '0.2.5'
61
- spec.add_development_dependency 'pry'
62
59
  spec.add_development_dependency 'method_source'
63
60
  spec.add_development_dependency 'opal-browser'
61
+ spec.add_development_dependency 'opal-rails'
62
+ spec.add_development_dependency 'puma'
63
+ spec.add_development_dependency 'rspec-collection_matchers'
64
+ spec.add_development_dependency 'rspec-expectations'
65
+ spec.add_development_dependency 'rspec-its'
66
+ spec.add_development_dependency 'rspec-mocks'
64
67
  spec.add_development_dependency 'rspec-steps'
65
- spec.add_dependency "rails"
66
- spec.add_development_dependency 'timecop'
68
+ spec.add_development_dependency 'shoulda'
69
+ spec.add_development_dependency 'shoulda-matchers'
70
+ spec.add_development_dependency 'spring-commands-rspec'
67
71
  end
68
72
  end
@@ -1,286 +1,88 @@
1
- require "hyper-spec/version"
2
- require "hyper-spec/engine"
3
-
4
- require 'opal'
5
-
6
- require 'hyper-spec/component_helpers'
7
-
8
- # DELETE require 'pry'
9
- # DELETE begin
10
- # DELETE require File.expand_path('../test_app/config/environment', __FILE__)
11
- # DELETE rescue LoadError
12
- # DELETE puts 'Could not load test application. Please ensure you have run `bundle exec rake test_app`'
13
- # DELETE end
14
- # DELETE require 'rspec/rails'
15
- # DELETE require 'timecop'
16
- # DELETE require "rspec/wait"
17
- # DELETE #require 'pusher-fake/support/base'
18
-
19
- # DELETE Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
20
-
21
- RSpec.configure do |config|
22
- # DELETE config.color = true
23
- # DELETE config.fail_fast = ENV['FAIL_FAST'] || false
24
- # DELETE config.fixture_path = File.join(File.expand_path(File.dirname(__FILE__)), "fixtures")
25
- # DELETE config.infer_spec_type_from_file_location!
26
- config.mock_with :rspec
27
- # DELETE config.raise_errors_for_deprecations!
28
-
29
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
30
- # examples within a transaction, comment the following line or assign false
31
- # instead of true.
32
- # DELETE config.use_transactional_fixtures = true
33
-
34
- # config.after :each do
35
- # Rails.cache.clear
36
- # end
37
-
38
- config.after(:each) do |example|
39
- unless example.exception
40
- # DELETE #Object.send(:remove_const, :Application) rescue nil
41
- # DELETE ObjectSpace.each_object(Class).each do |klass|
42
- # DELETE if klass < HyperMesh::Regulation
43
- # DELETE klass.instance_variables.each { |v| klass.instance_variable_set(v, nil) }
44
- # DELETE end
45
- # DELETE end
46
- PusherFake::Channel.reset if defined? PusherFake
47
- end
48
- end
49
-
50
- # DELETE config.filter_run_including focus: true
51
- # DELETE config.filter_run_excluding opal: true
52
- # DELETE config.run_all_when_everything_filtered = true
53
- end
54
-
55
- # DELETE FACTORY_GIRL = false
56
-
57
- # DELETE #require 'rails_helper'
58
- # DELETE require 'rspec'
59
- # DELETE require 'rspec/expectations'
60
- # DELETE begin
61
- # DELETE require 'factory_girl_rails'
62
- # DELETE rescue LoadError
63
- # DELETE end
64
- # DELETE require 'shoulda/matchers'
65
- # DELETE require 'database_cleaner'
66
1
  require 'capybara/rspec'
67
- #hmmm.... where should this go???? require 'capybara/rails'
68
2
  require 'capybara/poltergeist'
3
+ require 'opal'
69
4
  require 'selenium-webdriver'
70
5
 
71
- module React
72
- module IsomorphicHelpers
73
- def self.load_context(ctx, controller, name = nil)
74
- @context = Context.new("#{controller.object_id}-#{Time.now.to_i}", ctx, controller, name)
75
- end
76
- end
77
- end
78
-
79
- # DELETE #Capybara.default_max_wait_time = 4.seconds
80
-
81
- Capybara.server = :puma
82
-
83
- module WaitForAjax
84
-
85
- def wait_for_ajax
86
- Timeout.timeout(Capybara.default_max_wait_time) do
87
- begin
88
- sleep 0.25
89
- end until finished_all_ajax_requests?
90
- end
91
- end
92
-
93
- def running?
94
- result = page.evaluate_script("(function(active) {console.log('jquery is active? '+active); return active})(jQuery.active)")
95
- result && !result.zero?
96
- rescue Exception => e
97
- puts "wait_for_ajax failed while testing state of jQuery.active: #{e}"
98
- end
99
-
100
- def finished_all_ajax_requests?
101
- unless running?
102
- sleep 0.25 # this was 1 second, not sure if its necessary to be so long...
103
- !running?
104
- end
105
- rescue Capybara::NotSupportedByDriverError
106
- true
107
- rescue Exception => e
108
- e.message == "jQuery is not defined"
109
- end
110
-
111
- end
112
-
113
- RSpec.configure do |config|
114
- config.include WaitForAjax
115
- end
6
+ require 'hyper-spec/component_test_helpers'
7
+ require 'hyper-spec/rails/engine'
8
+ require 'hyper-spec/version'
9
+ require 'hyper-spec/wait_for_ajax'
10
+ require 'react/isomorphic_helpers'
11
+ require 'selenium/web_driver/firefox/profile'
116
12
 
117
13
  RSpec.configure do |config|
14
+ config.include HyperSpec::ComponentTestHelpers
15
+ config.include HyperSpec::WaitForAjax
16
+ config.include Capybara::DSL
118
17
 
119
- Capybara.default_max_wait_time = 10
18
+ config.mock_with :rspec
120
19
 
121
- config.before(:each) do |x|
122
- HyperMesh.class_eval do
123
- def self.on_server?
124
- true
20
+ if defined?(HyperMesh)
21
+ config.before(:each) do
22
+ HyperMesh.class_eval do
23
+ def self.on_server?
24
+ true
25
+ end
125
26
  end
126
27
  end
127
- end if defined? HyperMesh
28
+ end
128
29
 
129
- config.before(:each, :js => true) do
30
+ config.before(:each, js: true) do
130
31
  size_window
131
32
  end
132
33
 
133
- config.after(:each, :js => true) do
134
- page.instance_variable_set("@hyper_spec_mounted", false)
34
+ config.after(:each, js: true) do
35
+ page.instance_variable_set('@hyper_spec_mounted', false)
135
36
  end
136
37
 
137
-
138
- if false # delete? THIS BLOCK ????
139
- # rspec-expectations config goes here. You can use an alternate
140
- # assertion/expectation library such as wrong or the stdlib/minitest
141
- # assertions if you prefer.
142
- config.expect_with :rspec do |expectations|
143
- # Enable only the newer, non-monkey-patching expect syntax.
144
- # For more details, see:
145
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
146
- expectations.syntax = [:should, :expect]
147
- end
148
-
149
- # rspec-mocks config goes here. You can use an alternate test double
150
- # library (such as bogus or mocha) by changing the `mock_with` option here.
151
- config.mock_with :rspec do |mocks|
152
- # Enable only the newer, non-monkey-patching expect syntax.
153
- # For more details, see:
154
- # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
155
- mocks.syntax = :expect
156
-
157
- # Prevents you from mocking or stubbing a method that does not exist on
158
- # a real object. This is generally recommended.
159
- mocks.verify_partial_doubles = true
160
- end
161
-
162
- config.include FactoryGirl::Syntax::Methods if defined? FactoryGirl
163
-
164
- config.use_transactional_fixtures = false
165
-
166
- config.before(:suite) do
167
- DatabaseCleaner.clean_with(:truncation)
168
- end
169
-
170
- config.before(:each) do
171
- DatabaseCleaner.strategy = :transaction
172
- end
173
-
174
- config.before(:each, :js => true) do
175
- DatabaseCleaner.strategy = :truncation
176
- end
177
-
178
- config.before(:each) do
179
- DatabaseCleaner.start
180
- end
181
-
182
- config.after(:each) do |example|
183
- unless example.exception
184
- # Clear session data
185
- Capybara.reset_sessions!
186
- # Rollback transaction
187
- DatabaseCleaner.clean
188
- end
38
+ config.after(:each) do |example|
39
+ unless example.exception
40
+ PusherFake::Channel.reset if defined? PusherFake
189
41
  end
190
42
  end
43
+ end
191
44
 
45
+ # Capybara config
46
+ RSpec.configure do |_config|
47
+ Capybara.default_max_wait_time = 10
192
48
 
193
- config.include Capybara::DSL
194
-
195
- Capybara.register_driver :chrome do |app|
196
- #caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"excludeSwitches" => [ "ignore-certificate-errors" ]})
197
- caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"args" => [ "--window-size=200,200" ]})
198
- Capybara::Selenium::Driver.new(app, :browser => :chrome, :desired_capabilities => caps)
199
- end
49
+ # # In case Google ever fixes chromedriver to work with Opal...
50
+ # Capybara.register_driver :chrome do |app|
51
+ # caps = Selenium::WebDriver::Remote::Capabilities.chrome(
52
+ # 'chromeOptions' => { 'args' => ['--window-size=200,200'] }
53
+ # )
54
+ #
55
+ # Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: caps)
56
+ # end
200
57
 
201
- options = {
202
- js_errors: false,
203
- timeout: 180,
204
- inspector: true,
205
- phantomjs_options: ['--load-images=no', '--ignore-ssl-errors=yes']
206
- }
207
- options.merge!({phantomjs_logger: StringIO.new, logger: StringIO.new,}) unless ENV['SHOW_LOGS']
208
58
  Capybara.register_driver :poltergeist do |app|
209
- Capybara::Poltergeist::Driver.new(app, options)
210
- end
211
-
212
- class Selenium::WebDriver::Firefox::Profile
213
-
214
- def self.firebug_version
215
- @firebug_version ||= '2.0.13-fx'
216
- end
217
-
218
- def self.firebug_version=(version)
219
- @firebug_version = version
220
- end
221
-
222
- def frame_position
223
- @frame_position ||= 'detached'
224
- end
225
-
226
- def frame_position=(position)
227
- @frame_position = ["left", "right", "top", "detached"].detect do |side|
228
- position && position[0].downcase == side[0]
229
- end || "detached"
230
- end
231
-
232
- def enable_firebug(version = nil)
233
- version ||= Selenium::WebDriver::Firefox::Profile.firebug_version
234
- add_extension(File.expand_path("../bin/firebug-#{version}.xpi", __FILE__))
235
-
236
- # For some reason, Firebug seems to trigger the Firefox plugin check
237
- # (navigating to https://www.mozilla.org/en-US/plugincheck/ at startup).
238
- # This prevents it. See http://code.google.com/p/selenium/issues/detail?id=4619.
239
- self["extensions.blocklist.enabled"] = false
240
-
241
- # Prevent "Welcome!" tab
242
- self["extensions.firebug.showFirstRunPage"] = false
243
-
244
- # Enable for all sites.
245
- self["extensions.firebug.allPagesActivation"] = "on"
246
-
247
- # Enable all features.
248
- ['console', 'net', 'script'].each do |feature|
249
- self["extensions.firebug.#{feature}.enableSites"] = true
59
+ options = {
60
+ js_errors: false, timeout: 180, inspector: true,
61
+ phantomjs_options: ['--load-images=no', '--ignore-ssl-errors=yes']
62
+ }.tap do |hash|
63
+ unless ENV['SHOW_LOGS']
64
+ hash[:phantomjs_logger] = StringIO.new
65
+ hash[:logger] = StringIO.new
250
66
  end
251
-
252
- # Closed by default, will open detached.
253
- self["extensions.firebug.framePosition"] = frame_position
254
- self["extensions.firebug.previousPlacement"] = 3
255
- self["extensions.firebug.defaultPanelName"] = "console"
256
-
257
- # Disable native "Inspect Element" menu item.
258
- self["devtools.inspector.enabled"] = false
259
- self["extensions.firebug.hideDefaultInspector"] = true
260
67
  end
68
+
69
+ Capybara::Poltergeist::Driver.new(app, options)
261
70
  end
262
71
 
263
72
  Capybara.register_driver :selenium_with_firebug do |app|
264
73
  profile = Selenium::WebDriver::Firefox::Profile.new
265
74
  profile.frame_position = ENV['DRIVER'] && ENV['DRIVER'][2]
266
75
  profile.enable_firebug
267
- Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
268
- end
269
-
270
- Capybara.javascript_driver = :poltergeist
271
-
272
- Capybara.register_driver :chrome do |app|
273
- Capybara::Selenium::Driver.new(app, :browser => :chrome)
274
- end
275
76
 
276
- if ENV['DRIVER'] =~ /^ff/
277
- Capybara.javascript_driver = :selenium_with_firebug
278
- elsif ENV['DRIVER'] == 'chrome'
279
- Capybara.javascript_driver = :chrome
280
- else
281
- Capybara.javascript_driver = :poltergeist
77
+ Capybara::Selenium::Driver.new(app, browser: :firefox, profile: profile)
282
78
  end
283
79
 
284
- include ComponentTestHelpers
285
-
80
+ Capybara.javascript_driver =
81
+ if ENV['DRIVER'] =~ /^ff/
82
+ :selenium_with_firebug
83
+ # elsif ENV['DRIVER'] == 'chrome'
84
+ # Capybara.javascript_driver = :chrome
85
+ else
86
+ :poltergeist
87
+ end
286
88
  end