hyper-spec 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5dff8e22965b2eef2cfb535372e0b97b254d6702
4
- data.tar.gz: 2b526b9b3c5d733b41402f91b7e77d43af9563b9
3
+ metadata.gz: 2934f3c0c220b8178be5364c372de4474fba2b74
4
+ data.tar.gz: add452cd5e700a0540b8c97253176f55ff9eecfc
5
5
  SHA512:
6
- metadata.gz: 9e129992df21aa2acd291f13b039abbda6bf0781240704eca270aec710780d6c7bfbf960aa00e931e565cd6f1e26170092b918e33c115e112aa1213ed56810d8
7
- data.tar.gz: 799728c7cdc07def807d85c495fad8d809f51f45cb117b282a0db8c22db1d042a99f8585cf411327c5a9ad6389b60443db609cbb6700dd941468abd1b8374a44
6
+ metadata.gz: 0793765d331c7070e355331de5528ed2333d98a48900569877a4a10c7e198a214ff5150db6eddf9ec6d4956b41f39b268a43573669f4e3500615abee86a9253e
7
+ data.tar.gz: 528748ad43262c8bb341306c3308be71054f81f152d96bb6cec3ef17059dcc86796b518a6e46b13b7ec08e5594a9dba22ca8e8e0cadd085131f4034ba3b65626
data/.gitignore CHANGED
@@ -8,6 +8,8 @@ capybara-*.html
8
8
  /public/system
9
9
  /coverage/
10
10
  /spec/tmp
11
+ /spec/test_app/log
12
+ /spec/test_app/tmp
11
13
  **.orig
12
14
  rerun.txt
13
15
  pickle-email-*.html
@@ -40,10 +42,3 @@ bower.json
40
42
 
41
43
  # Ignore Byebug command history file.
42
44
  .byebug_history
43
-
44
- # Ignore test app files
45
- /spec/test_app/log/
46
- /spec/test_app/tmp/
47
-
48
- # Ignore built gem
49
- *.gem
data/Gemfile.lock CHANGED
@@ -2,15 +2,8 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  hyper-spec (0.1.0)
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)
5
+ hyper-react (>= 0.10.0)
6
+ rails
14
7
 
15
8
  GEM
16
9
  remote: https://rubygems.org/
@@ -67,7 +60,7 @@ GEM
67
60
  babel-source (>= 4.0, < 6)
68
61
  execjs (~> 2.0)
69
62
  builder (3.2.3)
70
- capybara (2.12.0)
63
+ capybara (2.10.1)
71
64
  addressable
72
65
  mime-types (>= 1.16)
73
66
  nokogiri (>= 1.3.3)
@@ -149,18 +142,17 @@ GEM
149
142
  paggio (0.2.6)
150
143
  parser (2.3.3.1)
151
144
  ast (~> 2.2)
152
- poltergeist (1.13.0)
145
+ poltergeist (1.11.0)
153
146
  capybara (~> 2.1)
154
147
  cliver (~> 0.3.1)
155
148
  websocket-driver (>= 0.2.0)
156
- powerpack (0.1.1)
157
149
  procto (0.0.3)
158
150
  pry (0.10.4)
159
151
  coderay (~> 1.1.0)
160
152
  method_source (~> 0.8.1)
161
153
  slop (~> 3.4)
162
154
  public_suffix (2.0.5)
163
- puma (3.7.0)
155
+ puma (3.6.2)
164
156
  rack (2.0.1)
165
157
  rack-test (0.6.3)
166
158
  rack (>= 1.0)
@@ -187,7 +179,6 @@ GEM
187
179
  method_source
188
180
  rake (>= 0.8.7)
189
181
  thor (>= 0.18.1, < 2.0)
190
- rainbow (2.2.1)
191
182
  rake (10.5.0)
192
183
  react-rails (1.4.2)
193
184
  babel-transpiler (>= 0.7.0)
@@ -201,7 +192,7 @@ GEM
201
192
  rspec-core (~> 3.5.0)
202
193
  rspec-expectations (~> 3.5.0)
203
194
  rspec-mocks (~> 3.5.0)
204
- rspec-collection_matchers (1.1.3)
195
+ rspec-collection_matchers (1.1.2)
205
196
  rspec-expectations (>= 2.99.0.beta1)
206
197
  rspec-core (3.5.4)
207
198
  rspec-support (~> 3.5.0)
@@ -225,13 +216,6 @@ GEM
225
216
  rspec-steps (2.1.1)
226
217
  rspec (>= 3.0, < 3.99)
227
218
  rspec-support (3.5.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
219
  rubyzip (1.2.0)
236
220
  selenium-webdriver (2.53.4)
237
221
  childprocess (~> 0.5)
@@ -240,7 +224,7 @@ GEM
240
224
  shoulda (3.5.0)
241
225
  shoulda-context (~> 1.0, >= 1.0.1)
242
226
  shoulda-matchers (>= 1.4.1, < 3.0)
243
- shoulda-context (1.2.2)
227
+ shoulda-context (1.2.1)
244
228
  shoulda-matchers (2.8.0)
245
229
  activesupport (>= 3.0.0)
246
230
  slop (3.6.0)
@@ -265,7 +249,6 @@ GEM
265
249
  timecop (0.8.1)
266
250
  tzinfo (1.2.2)
267
251
  thread_safe (~> 0.1)
268
- unicode-display_width (1.1.3)
269
252
  unparser (0.2.5)
270
253
  abstract_type (~> 0.0.7)
271
254
  adamantium (~> 0.2.0)
@@ -286,26 +269,32 @@ PLATFORMS
286
269
 
287
270
  DEPENDENCIES
288
271
  bundler (~> 1.12)
272
+ capybara
289
273
  chromedriver-helper
290
- hyper-react (>= 0.10.0)
291
274
  hyper-spec!
292
275
  method_source
293
276
  opal-browser
294
277
  opal-rails
278
+ parser
279
+ poltergeist
280
+ pry
295
281
  puma
296
282
  rails (~> 5.0.0)
297
283
  rake (~> 10.0)
298
- react-rails (< 1.10.0)
284
+ react-rails (~> 1.4.0)
299
285
  rspec-collection_matchers
300
286
  rspec-expectations
301
287
  rspec-its
302
288
  rspec-mocks
289
+ rspec-rails
303
290
  rspec-steps
304
- rubocop
291
+ selenium-webdriver (= 2.53.4)
305
292
  shoulda
306
293
  shoulda-matchers
307
294
  spring-commands-rspec
308
295
  therubyracer (= 0.12.2)
296
+ timecop
297
+ unparser (= 0.2.5)
309
298
 
310
299
  BUNDLED WITH
311
300
  1.12.5
data/README.md CHANGED
@@ -350,11 +350,6 @@ 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
-
358
353
  ## Development
359
354
 
360
355
  After checking out the repo, run bundle install and you should be good to go.
data/hyper-spec.gemspec CHANGED
@@ -1,72 +1,68 @@
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| # rubocop:disable Metrics/BlockLength
7
- spec.name = 'hyper-spec'
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hyper-spec"
8
8
  spec.version = HyperSpec::VERSION
9
- spec.authors = ['catmando', 'adamcreekroad']
10
- spec.email = ['mitch@catprint.com']
9
+ spec.authors = ["catmando"]
10
+ spec.email = ["mitch@catprint.com"]
11
11
 
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'
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"
20
17
 
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'
24
-
25
- spec.files =
26
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
- spec.bindir = 'exe'
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
28
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
- spec.require_paths = ['lib']
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.12"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+
26
+ spec.add_dependency 'hyper-react', '>= 0.10.0'
30
27
 
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'
28
+ spec.add_development_dependency 'rspec-rails'
37
29
 
38
- # Keep linter-rubocop happy
39
- spec.add_development_dependency 'rubocop'
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'
40
39
 
41
40
  if RUBY_PLATFORM == 'java'
42
41
  spec.add_development_dependency 'therubyrhino'
43
42
  else
44
43
  spec.add_development_dependency 'therubyracer', '0.12.2'
45
44
 
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'
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'
56
48
 
57
- # Test app dependencies
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'
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'
59
62
  spec.add_development_dependency 'method_source'
60
63
  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'
67
64
  spec.add_development_dependency 'rspec-steps'
68
- spec.add_development_dependency 'shoulda'
69
- spec.add_development_dependency 'shoulda-matchers'
70
- spec.add_development_dependency 'spring-commands-rspec'
65
+ spec.add_dependency "rails"
66
+ spec.add_development_dependency 'timecop'
71
67
  end
72
68
  end
data/lib/hyper-spec.rb CHANGED
@@ -1,88 +1,286 @@
1
- require 'capybara/rspec'
2
- require 'capybara/poltergeist'
1
+ require "hyper-spec/version"
2
+ require "hyper-spec/engine"
3
+
3
4
  require 'opal'
4
- require 'selenium-webdriver'
5
5
 
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'
6
+ require 'hyper-spec/component_helpers'
12
7
 
13
- RSpec.configure do |config|
14
- config.include HyperSpec::ComponentTestHelpers
15
- config.include HyperSpec::WaitForAjax
16
- config.include Capybara::DSL
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 }
17
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!
18
26
  config.mock_with :rspec
27
+ # DELETE config.raise_errors_for_deprecations!
19
28
 
20
- if defined?(HyperMesh)
21
- config.before(:each) do
22
- HyperMesh.class_eval do
23
- def self.on_server?
24
- true
25
- end
26
- end
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
27
47
  end
28
48
  end
29
49
 
30
- config.before(:each, js: true) do
31
- size_window
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
+ require 'capybara/rspec'
67
+ #hmmm.... where should this go???? require 'capybara/rails'
68
+ require 'capybara/poltergeist'
69
+ require 'selenium-webdriver'
70
+
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
32
76
  end
77
+ end
78
+
79
+ # DELETE #Capybara.default_max_wait_time = 4.seconds
80
+
81
+ Capybara.server = :puma
82
+
83
+ module WaitForAjax
33
84
 
34
- config.after(:each, js: true) do
35
- page.instance_variable_set('@hyper_spec_mounted', false)
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
36
91
  end
37
92
 
38
- config.after(:each) do |example|
39
- unless example.exception
40
- PusherFake::Channel.reset if defined? PusherFake
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?
41
104
  end
105
+ rescue Capybara::NotSupportedByDriverError
106
+ true
107
+ rescue Exception => e
108
+ e.message == "jQuery is not defined"
42
109
  end
110
+
43
111
  end
44
112
 
45
- # Capybara config
46
- RSpec.configure do |_config|
113
+ RSpec.configure do |config|
114
+ config.include WaitForAjax
115
+ end
116
+
117
+ RSpec.configure do |config|
118
+
47
119
  Capybara.default_max_wait_time = 10
48
120
 
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
121
+ config.before(:each) do |x|
122
+ HyperMesh.class_eval do
123
+ def self.on_server?
124
+ true
125
+ end
126
+ end
127
+ end if defined? HyperMesh
57
128
 
58
- Capybara.register_driver :poltergeist do |app|
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
129
+ config.before(:each, :js => true) do
130
+ size_window
131
+ end
132
+
133
+ config.after(:each, :js => true) do
134
+ page.instance_variable_set("@hyper_spec_mounted", false)
135
+ end
136
+
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
66
188
  end
67
189
  end
190
+ end
68
191
 
192
+
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
200
+
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
+ Capybara.register_driver :poltergeist do |app|
69
209
  Capybara::Poltergeist::Driver.new(app, options)
70
210
  end
71
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
250
+ 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
+ end
261
+ end
262
+
72
263
  Capybara.register_driver :selenium_with_firebug do |app|
73
264
  profile = Selenium::WebDriver::Firefox::Profile.new
74
265
  profile.frame_position = ENV['DRIVER'] && ENV['DRIVER'][2]
75
266
  profile.enable_firebug
267
+ Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
268
+ end
269
+
270
+ Capybara.javascript_driver = :poltergeist
76
271
 
77
- Capybara::Selenium::Driver.new(app, browser: :firefox, profile: profile)
272
+ Capybara.register_driver :chrome do |app|
273
+ Capybara::Selenium::Driver.new(app, :browser => :chrome)
78
274
  end
79
275
 
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
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
282
+ end
283
+
284
+ include ComponentTestHelpers
285
+
88
286
  end