waterpig 0.3.0 → 0.4.0

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: e20640440d771664f5460b57a1178345f9ad5ac1
4
- data.tar.gz: cb422e922758a986a040ca543e5a8de6e694f851
3
+ metadata.gz: 2a2a5a3dc8d067e31bd44da7641251085c79f8a9
4
+ data.tar.gz: e9bf6eb922f230797d4281a5aab4151fed8a0d64
5
5
  SHA512:
6
- metadata.gz: bf1486128af018b73e88021e0eeef68ee6ad1c339970e4317c70216c6c358f5b03cfde112c2ebd8015f52f3d97563d8017f2b1f623eee87a742ea5377ea812ca
7
- data.tar.gz: a3bf55677893c493e49715fc42df9eb810822a3da1a720f47cc9fe274a66d6da2dae8afbfce0095c73a27c0b0d8737b042e32d63b4a80a87ac8185ccf8df31cd
6
+ metadata.gz: 319ea313489f5e5d6df14637712d008e03dfe120a35f50152b5cfb1657541ae2cc3cf332bea0f80cbc7df027facc790a42b6065e806cbf6d99a58b186a73a66d
7
+ data.tar.gz: d57ad2069c0d90fdd5274d4969cf02edfab660af5925df482655ea84c6b4f7597c6d36db29dd83ca7e68d122588587e6cdd6d36cf63ae1698919af96e6782930
@@ -9,6 +9,7 @@ require 'waterpig/save-and-open-on-fail'
9
9
  require 'waterpig/ckeditor-tools'
10
10
  require 'waterpig/tinymce-tools'
11
11
  require 'waterpig/browser-tools'
12
+ require 'waterpig/browser-size'
12
13
  require 'waterpig/snap-step'
13
14
 
14
15
  module Waterpig
@@ -22,10 +23,19 @@ end
22
23
 
23
24
  RSpec.configure do |config|
24
25
  config.add_setting :waterpig_browser_types, :default => [:feature]
26
+ config.add_setting :waterpig_browser_size_types, :default => [:feature]
27
+
25
28
  config.add_setting :waterpig_autosnap, :default => ENV['WATERPIG_AUTOSNAP']
26
29
  config.add_setting :waterpig_driver, :default => ENV['CAPYBARA_DRIVER']
27
30
  config.add_setting :waterpig_js_driver, :default => ENV['CAPYBARA_JS_DRIVER']
28
31
 
32
+ config.add_setting :waterpig_browser_sizes, :default => {
33
+ :mobile => { :width => 320, :height => 480 },
34
+ :small => { :width => 550, :height => 700 },
35
+ :medium => { :width => 800, :height => 900 },
36
+ :desktop => { :width => 1024, :height => 1024 }
37
+ }
38
+
29
39
 
30
40
  config.before(:suite) do
31
41
  Capybara.default_driver = Waterpig.pick_capybara_driver(config.waterpig_driver)
@@ -45,4 +55,8 @@ RSpec.configure do |config|
45
55
  config.waterpig_autosnap? && config.waterpig_browser_types.include?(value)
46
56
  }
47
57
  config.include Waterpig::SnapStep, :snapshots_into => proc{|v| v.is_a? String}
58
+
59
+ config.include Waterpig::BrowserSize, :type => proc{|value|
60
+ config.waterpig_browser_size_types && config.waterpig_browser_size_types.include?(value)
61
+ }
48
62
  end
@@ -0,0 +1,18 @@
1
+ module Waterpig
2
+ module BrowserSize
3
+ def self.included(group)
4
+ group.before(:each) do |example|
5
+ sizes = RSpec.configuration.waterpig_browser_sizes
6
+ BrowserSize.resize_browser_window(sizes[BrowserSize.current_size(example)])
7
+ end
8
+ end
9
+
10
+ def self.resize_browser_window(size)
11
+ Capybara.current_session.driver.browser.manage.window.resize_to(size[:width], size[:height])
12
+ end
13
+
14
+ def self.current_size(example)
15
+ (example.metadata[:size] || ENV['BROWSER_SIZE'] || :desktop).to_sym
16
+ end
17
+ end
18
+ end
@@ -9,20 +9,38 @@ RSpec.configure do |config|
9
9
  config.add_setting :waterpig_database_truncation_config, :default => {:except => %w[spatial_ref_sys]}
10
10
  config.add_setting :waterpig_db_seeds, :default => 'db/seeds.rb'
11
11
 
12
+ def with_showing(show, detailed)
13
+ begin
14
+ old_show, old_show_detailed =
15
+ Rails.application.config.action_dispatch.show_exceptions,
16
+ Rails.application.config.action_dispatch.show_detailed_exceptions
17
+ Rails.application.config.action_dispatch.show_exceptions = show
18
+ Rails.application.config.action_dispatch.show_detailed_exceptions = detailed
19
+ yield
20
+ ensure
21
+ Rails.application.config.action_dispatch.show_exceptions = old_show
22
+ Rails.application.config.action_dispatch.show_detailed_exceptions = old_show_detailed
23
+ end
24
+ end
25
+
12
26
  config.before :all, :type => proc{ |value| config.waterpig_truncation_types.include?(value)} do
13
- Rails.application.config.action_dispatch.show_exceptions = true
14
- DatabaseCleaner.clean_with :truncation, config.waterpig_database_truncation_config
15
- unless config.waterpig_exclude_seeds_types.include?(self.class.metadata[:type])
16
- if config.waterpig_db_seeds?
17
- load config.waterpig_db_seeds
27
+ with_showing(true, false) do
28
+ DatabaseCleaner.clean_with :truncation, config.waterpig_database_truncation_config
29
+ unless config.waterpig_exclude_seeds_types.include?(self.class.metadata[:type])
30
+ if config.waterpig_db_seeds?
31
+ load config.waterpig_db_seeds
32
+ end
18
33
  end
19
34
  end
20
35
  end
21
36
 
22
37
  config.after :all, :type => proc{ |value| config.waterpig_truncation_types.include?(value)} do
23
- DatabaseCleaner.clean_with :truncation, config.waterpig_database_truncation_config
24
- if config.waterpig_db_seeds?
25
- load config.waterpig_db_seeds
38
+ with_showing(true, true) do
39
+ Rails.application.config.action_dispatch.show_detailed_exceptions = true
40
+ DatabaseCleaner.clean_with :truncation, config.waterpig_database_truncation_config
41
+ if config.waterpig_db_seeds?
42
+ load config.waterpig_db_seeds
43
+ end
26
44
  end
27
45
  end
28
46
 
@@ -0,0 +1,32 @@
1
+ module Waterpig
2
+ class DeadbeatConnectionRelease
3
+ def initialize(app)
4
+ @app = app
5
+ end
6
+
7
+ #This is a brittle hack for what appears to be a bug in ActiveRecord 4:
8
+ #connections aren't being properly released after their owning threads die
9
+ def call(env)
10
+ response = @app.call(env)
11
+ response[2] = ::Rack::BodyProxy.new(response[2]) do
12
+ ActiveRecord::Base.connection_handler.connection_pool_list.each do |pool|
13
+ reservers = pool.instance_variable_get("@reserved_connections").keys
14
+ deadbeats = reservers - Thread.list.map(&:object_id)
15
+ Rails.logger.info{ "Releasing connections held by these no-longer-living Threads: #{deadbeats}" } unless deadbeats.empty?
16
+ deadbeats.each do |deadbeat_id|
17
+ pool.release_connection(deadbeat_id)
18
+ end
19
+ end
20
+ end
21
+
22
+ response
23
+ rescue Object => ex
24
+ require 'pp'
25
+ Rails.logger.fatal "Problem responding to request in test"
26
+ Rails.logger.fatal [ex.class, ex.message, ex.backtrace].join("\n")
27
+ Rails.logger.fatal env.pretty_inspect
28
+ Rails.logger.fatal response.pretty_inspect
29
+ raise
30
+ end
31
+ end
32
+ end
data/spec/embarrassing.rb CHANGED
@@ -2,6 +2,7 @@ require 'sequel'
2
2
  Sequel.sqlite
3
3
 
4
4
  require 'waterpig'
5
+ require 'waterpig/deadbeat-connections'
5
6
 
6
7
  describe "Nothing" do
7
8
  it "should do more" do
@@ -1,9 +1,14 @@
1
1
  require 'rspec'
2
2
  require 'rspec/core/formatters/base_formatter'
3
- require 'cadre/rspec'
3
+ require 'cadre/rspec3'
4
4
 
5
5
  RSpec.configure do |config|
6
6
  config.run_all_when_everything_filtered = true
7
- config.add_formatter(Cadre::RSpec::NotifyOnCompleteFormatter)
8
- config.add_formatter(Cadre::RSpec::QuickfixFormatter)
7
+ if config.formatters.empty?
8
+ config.add_formatter(:progress)
9
+ #but do consider:
10
+ #config.add_formatter(Cadre::RSpec3::TrueFeelingsFormatter)
11
+ end
12
+ config.add_formatter(Cadre::RSpec3::NotifyOnCompleteFormatter)
13
+ config.add_formatter(Cadre::RSpec3::QuickfixFormatter)
9
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waterpig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Judson Lester
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-09 00:00:00.000000000 Z
11
+ date: 2014-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -65,12 +65,14 @@ files:
65
65
  - lib/waterpig/ckeditor-tools.rb
66
66
  - lib/waterpig/selenium_chrome.rb
67
67
  - lib/waterpig/database-cleaner.rb
68
+ - lib/waterpig/deadbeat-connections.rb
68
69
  - lib/waterpig/tinymce-tools.rb
69
70
  - lib/waterpig/browser-integration.rb
70
71
  - lib/waterpig/poltergeist.rb
71
72
  - lib/waterpig/warning-suppressor.rb
72
73
  - lib/waterpig/snap-step.rb
73
74
  - lib/waterpig/browser-tools.rb
75
+ - lib/waterpig/browser-size.rb
74
76
  - spec/embarrassing.rb
75
77
  - spec_help/spec_helper.rb
76
78
  - spec_help/gem_test_suite.rb
@@ -84,7 +86,7 @@ rdoc_options:
84
86
  - --main
85
87
  - doc/README
86
88
  - --title
87
- - waterpig-0.3.0 Documentation
89
+ - waterpig-0.4.0 Documentation
88
90
  require_paths:
89
91
  - lib/
90
92
  required_ruby_version: !ruby/object:Gem::Requirement