spreewald 1.11.1 → 1.11.2

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
  SHA256:
3
- metadata.gz: bfdc79fd11e503ee95441067b8512739f163c9e9215fe0c2cfa619a032cb5cc8
4
- data.tar.gz: fe32fb4537956bf8d0853fb35a51027e1c044c8928055a62d4d26f3c0216958a
3
+ metadata.gz: 832e19b87b9d9d63a8074bb73bf98bc49953a7dfc8b7d656c5193f88760bd643
4
+ data.tar.gz: 547826cf456d15f228b9fe15e9f7a31dbd3345e31b7bbf0586b9d8a47571cb3a
5
5
  SHA512:
6
- metadata.gz: 0fe4f50cdfa4a3d14209e82844b7f8b6471cb31a5d3f2007ae643a5efe1bf756c7cc93858e9a2310ffa298635a85c2bc601a759b4b2ce0d7373e42ba284f361d
7
- data.tar.gz: 15376abcf33575c2601cff104cbff187381d5a475ef73d9a997051db8f07eb7f232a5fc132325c34bb2f232c961e36a2ff6b566660642e5adcf972604ba6a11c
6
+ metadata.gz: 9b7e7a8c2113bc2f813c0415872791248dcea1fe234256c4a0c1424e7fd90c9468300945bf1e222f5d0ccd9f6fa3693cfbd3249d33e9032d5c535cd33fa62d77
7
+ data.tar.gz: 17e7049f1552e788fd1784f396e43cd188258bd17ff62c49139da4ce794d8b2824b0e7b5743a1f80b42e085b6c0836e4fb5d238fa9f28f35cad758cf58f4fdc7
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rspec'
@@ -0,0 +1,26 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.3)
5
+ rspec (3.4.0)
6
+ rspec-core (~> 3.4.0)
7
+ rspec-expectations (~> 3.4.0)
8
+ rspec-mocks (~> 3.4.0)
9
+ rspec-core (3.4.4)
10
+ rspec-support (~> 3.4.0)
11
+ rspec-expectations (3.4.0)
12
+ diff-lcs (>= 1.2.0, < 2.0)
13
+ rspec-support (~> 3.4.0)
14
+ rspec-mocks (3.4.1)
15
+ diff-lcs (>= 1.2.0, < 2.0)
16
+ rspec-support (~> 3.4.0)
17
+ rspec-support (3.4.1)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ rspec
24
+
25
+ BUNDLED WITH
26
+ 1.16.1
data/Rakefile CHANGED
@@ -4,6 +4,12 @@ require "bundler/gem_tasks"
4
4
  desc 'Default: Run all tests.'
5
5
  task :default => 'all:rubies'
6
6
 
7
+ begin
8
+ require 'rspec/core/rake_task'
9
+ RSpec::Core::RakeTask.new(:spec)
10
+ rescue LoadError
11
+ end
12
+
7
13
  desc 'Update the "Steps" section of the README'
8
14
  task :update_readme do
9
15
  readme_path = 'README.md'
@@ -78,7 +84,8 @@ def run_for_all_rubies(version_manager)
78
84
  current_version = `#{execute} ruby -v`.match(/^ruby (\d\.\d\.\d)/)[1]
79
85
  if current_version == ruby_version
80
86
  puts "Currently active Ruby is #{current_version}"
81
- system "#{execute} rake all:bundle all:features"
87
+ system "#{execute} bundle"
88
+ system "#{execute} rake all:bundle spec all:features"
82
89
  else
83
90
  fail "Failed to set Ruby #{ruby_version} (#{current_version} active!)"
84
91
  end
@@ -42,6 +42,12 @@ require 'cgi'
42
42
  #
43
43
  # Then I should see "some text" within ".page_body"
44
44
  When /^(.*) within (.*[^:])$/ do |nested_step, parent|
45
+ selector = _selector_for(parent)
46
+ if selector.is_a?(String) # could also be a Capybara::Node::Element
47
+ patiently do
48
+ page.should have_css(selector)
49
+ end
50
+ end
45
51
  patiently do
46
52
  with_scope(parent) { step(nested_step) }
47
53
  end
@@ -34,82 +34,38 @@ module ToleranceForSeleniumSyncIssues
34
34
  end
35
35
  end
36
36
 
37
- class PatientStack
38
-
39
- def initialize
40
- @stack ||= []
41
- end
42
-
43
- def add_segment(max_seconds)
44
- index = @stack.length
45
- segment = PatientStackSegment.new(@stack, index, max_seconds)
46
- @stack[index] = segment
47
- segment
48
- end
37
+ class Patiently
38
+ WAIT_PERIOD = 0.05
49
39
 
50
40
  def patiently(seconds, &block)
51
- segment = add_segment(seconds)
52
-
41
+ started = Time.now
42
+ tries = 0
53
43
  begin
44
+ tries += 1
54
45
  block.call
55
46
  rescue Exception => e
56
- raise e unless RETRY_ERRORS.include?(e.class.name)
57
- raise e unless segment.seconds_left?
58
- sleep(0.05)
59
- raise Capybara::FrozenInTime, "time appears to be frozen, Capybara does not work with libraries which freeze time, consider using time travelling instead" if segment.frozen_time?
47
+ raise e unless retryable_error?(e)
48
+ raise e if (Time.now - started > seconds && tries >= 2)
49
+ sleep(WAIT_PERIOD)
50
+ raise Capybara::FrozenInTime, "time appears to be frozen, Capybara does not work with libraries which freeze time, consider using time travelling instead" if Time.now == started
60
51
  retry
61
- ensure
62
- segment.done!
63
52
  end
64
-
65
53
  end
66
54
 
67
- end
68
-
69
- class PatientStackSegment
70
-
71
- def initialize(stack, index, max_seconds)
72
- @stack = stack
73
- @index = index
74
- @started_at = Time.now
75
- @max_seconds = max_seconds
76
- end
77
-
78
- attr_reader :max_seconds
79
-
80
- def seconds_elapsed
81
- Time.now - @started_at
82
- end
55
+ private
83
56
 
84
- def seconds_left
85
- max_seconds - seconds_elapsed
57
+ def retryable_error?(e)
58
+ RETRY_ERRORS.include?(e.class.name)
86
59
  end
87
-
88
- def seconds_left?
89
- seconds_left > 0
90
- end
91
-
92
- def frozen_time?
93
- Time.now == @started_at
94
- end
95
-
96
- def extend_seconds(additional_seconds)
97
- @max_seconds += additional_seconds
98
- end
99
-
100
- def done!
101
- if @index > 0
102
- @stack[@index - 1].extend_seconds(seconds_elapsed)
103
- @stack.pop
104
- end
105
- end
106
-
107
60
  end
108
61
 
62
+
109
63
  def patiently(seconds = CapybaraWrapper.default_max_wait_time, &block)
110
- return block.call unless page.driver.wait?
111
- @wait_stack ||= PatientStack.new
112
- @wait_stack.patiently(seconds, &block)
64
+ if page.driver.wait?
65
+ Patiently.new.patiently(seconds, &block)
66
+ else
67
+ block.call
68
+ end
113
69
  end
114
70
  end
115
71
 
@@ -1,3 +1,3 @@
1
1
  module Spreewald
2
- VERSION = '1.11.1'
2
+ VERSION = '1.11.2'
3
3
  end
@@ -0,0 +1,104 @@
1
+ require 'bundler'
2
+ Bundler.setup
3
+
4
+ require 'pathname'
5
+
6
+ Dir[Pathname.new(__FILE__).join('..', 'support', '**', '*.rb')].each { |f| require f }
7
+
8
+
9
+ # This file was generated by the `rspec --init` command. Conventionally, all
10
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
11
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
12
+ # this file to always be loaded, without a need to explicitly require it in any
13
+ # files.
14
+ #
15
+ # Given that it is always loaded, you are encouraged to keep this file as
16
+ # light-weight as possible. Requiring heavyweight dependencies from this file
17
+ # will add to the boot time of your test suite on EVERY test run, even for an
18
+ # individual file that may not need all of that loaded. Instead, consider making
19
+ # a separate helper file that requires the additional dependencies and performs
20
+ # the additional setup, and require it from the spec files that actually need
21
+ # it.
22
+ #
23
+ # The `.rspec` file also contains a few flags that are not defaults but that
24
+ # users commonly want.
25
+ #
26
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
27
+ RSpec.configure do |config|
28
+ # rspec-expectations config goes here. You can use an alternate
29
+ # assertion/expectation library such as wrong or the stdlib/minitest
30
+ # assertions if you prefer.
31
+ config.expect_with :rspec do |expectations|
32
+ # This option will default to `true` in RSpec 4. It makes the `description`
33
+ # and `failure_message` of custom matchers include text for helper methods
34
+ # defined using `chain`, e.g.:
35
+ # be_bigger_than(2).and_smaller_than(4).description
36
+ # # => "be bigger than 2 and smaller than 4"
37
+ # ...rather than:
38
+ # # => "be bigger than 2"
39
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
40
+ end
41
+
42
+ # rspec-mocks config goes here. You can use an alternate test double
43
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
44
+ config.mock_with :rspec do |mocks|
45
+ # Prevents you from mocking or stubbing a method that does not exist on
46
+ # a real object. This is generally recommended, and will default to
47
+ # `true` in RSpec 4.
48
+ mocks.verify_partial_doubles = true
49
+ end
50
+
51
+ # The settings below are suggested to provide a good initial experience
52
+ # with RSpec, but feel free to customize to your heart's content.
53
+ =begin
54
+ # These two settings work together to allow you to limit a spec run
55
+ # to individual examples or groups you care about by tagging them with
56
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
57
+ # get run.
58
+ config.filter_run :focus
59
+ config.run_all_when_everything_filtered = true
60
+
61
+ # Allows RSpec to persist some state between runs in order to support
62
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
63
+ # you configure your source control system to ignore this file.
64
+ config.example_status_persistence_file_path = "spec/examples.txt"
65
+
66
+ # Limits the available syntax to the non-monkey patched syntax that is
67
+ # recommended. For more details, see:
68
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
69
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
70
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
71
+ config.disable_monkey_patching!
72
+
73
+ # This setting enables warnings. It's recommended, but in some cases may
74
+ # be too noisy due to issues in dependencies.
75
+ config.warnings = true
76
+
77
+ # Many RSpec users commonly either run the entire suite or an individual
78
+ # file, and it's useful to allow more verbose output when running an
79
+ # individual spec file.
80
+ if config.files_to_run.one?
81
+ # Use the documentation formatter for detailed output,
82
+ # unless a formatter has already been configured
83
+ # (e.g. via a command-line flag).
84
+ config.default_formatter = 'doc'
85
+ end
86
+
87
+ # Print the 10 slowest examples and example groups at the
88
+ # end of the spec run, to help surface which specs are running
89
+ # particularly slow.
90
+ config.profile_examples = 10
91
+
92
+ # Run specs in random order to surface order dependencies. If you find an
93
+ # order dependency and want to debug it, you can fix the order by providing
94
+ # the seed, which is printed after each run.
95
+ # --seed 1234
96
+ config.order = :random
97
+
98
+ # Seed global randomization in this process using the `--seed` CLI option.
99
+ # Setting this allows you to use `--seed` to deterministically reproduce
100
+ # test failures related to randomization by passing the same `--seed` value
101
+ # as the one that triggered the failure.
102
+ Kernel.srand config.seed
103
+ =end
104
+ end
@@ -0,0 +1,122 @@
1
+ require 'spreewald_support/tolerance_for_selenium_sync_issues'
2
+
3
+ module Capybara
4
+ class ElementNotFound < StandardError; end
5
+
6
+ class << self
7
+ attr_accessor :default_max_wait_time
8
+ end
9
+ end
10
+
11
+ describe ToleranceForSeleniumSyncIssues do
12
+ subject { World.new }
13
+ let(:wait_time) { 0.2 }
14
+
15
+ before do
16
+ Capybara.default_max_wait_time = wait_time
17
+ allow(subject.page.driver).to receive(:wait?).and_return(true)
18
+ end
19
+
20
+ describe '#patiently' do
21
+ it 'calls the block' do
22
+ reached = false
23
+ subject.patiently do
24
+ reached = true
25
+ end
26
+ expect(reached).to eq true
27
+ end
28
+
29
+ it 'fails if the block raises an unknown error' do
30
+ reached = false
31
+ expect {
32
+ subject.patiently do
33
+ raise 'some unknown error'
34
+ reached = true
35
+ end
36
+ }.to raise_error(/some unknown error/)
37
+ expect(reached).to eq false
38
+ end
39
+
40
+ it 'retries the block if it raises a whitelisted error, but eventually raises it' do
41
+ count = 0
42
+ expect {
43
+ subject.patiently do
44
+ count += 1
45
+ raise Capybara::ElementNotFound
46
+ end
47
+ }.to raise_error(Capybara::ElementNotFound)
48
+ expect(count).to be > 2
49
+ end
50
+
51
+ it 'retries the block if it fails an expectation' do
52
+ count = 0
53
+ expect {
54
+ subject.patiently do
55
+ count += 1
56
+ expect(true).to eq false
57
+ end
58
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
59
+ expect(count).to be > 2
60
+ end
61
+
62
+ it 'does not retry the block if page.driver.wait? is false' do
63
+ allow(subject.page.driver).to receive(:wait?).and_return(false)
64
+ count = 0
65
+ expect {
66
+ subject.patiently do
67
+ count += 1
68
+ raise Capybara::ElementNotFound
69
+ end
70
+ }.to raise_error(Capybara::ElementNotFound)
71
+ expect(count).to eq 1
72
+ end
73
+
74
+ it 'will not raise an error if the block eventually succeeds' do
75
+ count = 0
76
+ expect {
77
+ subject.patiently do
78
+ count += 1
79
+ if count < 3
80
+ raise Capybara::ElementNotFound
81
+ end
82
+ end
83
+ }.not_to raise_error
84
+ end
85
+
86
+ it 'will retry the block until a specified amount of time has passed' do
87
+ started = Time.now
88
+ expect {
89
+ subject.patiently do
90
+ raise Capybara::ElementNotFound
91
+ end
92
+ }.to raise_error(Capybara::ElementNotFound)
93
+ expect(Time.now - started).to be > wait_time
94
+ end
95
+
96
+ it 'retries the block at least twice even if the given time has passed' do
97
+ count = 0
98
+ expect {
99
+ subject.patiently do
100
+ count += 1
101
+ sleep wait_time
102
+ raise Capybara::ElementNotFound
103
+ end
104
+ }.to raise_error(Capybara::ElementNotFound)
105
+ expect(count).to be > 1
106
+ end
107
+
108
+ it 'will retry an outer patiently block if an inner patiently block took up all the time' do
109
+ try = 0
110
+ expect {
111
+ subject.patiently do
112
+ try += 1
113
+ correct_element_found = try > 1
114
+ subject.patiently do
115
+ raise Capybara::ElementNotFound unless correct_element_found
116
+ end
117
+ end
118
+ }.not_to raise_error
119
+ end
120
+
121
+ end
122
+ end
@@ -0,0 +1,23 @@
1
+ class World
2
+ class Driver
3
+ def wait?
4
+ true
5
+ end
6
+ end
7
+
8
+ class Page
9
+ def driver
10
+ @driver ||= Driver.new
11
+ end
12
+ end
13
+
14
+ def page
15
+ @page ||= Page.new
16
+ end
17
+ end
18
+
19
+ def World(mod)
20
+ World.class_eval do
21
+ include mod
22
+ end
23
+ end
@@ -27,6 +27,5 @@ Gem::Specification.new do |gem|
27
27
 
28
28
  # Testing
29
29
  gem.add_development_dependency 'aruba', '~> 0.10.2'
30
- gem.add_development_dependency 'guard-cucumber'
31
30
  gem.add_development_dependency 'rspec', '~> 3.4.0'
32
31
  end
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- spreewald (1.11.0)
4
+ spreewald (1.11.2)
5
5
  cucumber
6
- cucumber_priority
6
+ cucumber_priority (>= 0.3.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -36,7 +36,7 @@ GEM
36
36
  term-ansicolor (>= 1.0.6)
37
37
  cucumber-rails (0.3.2)
38
38
  cucumber (>= 0.8.0)
39
- cucumber_priority (0.2.0)
39
+ cucumber_priority (0.3.1)
40
40
  cucumber
41
41
  database_cleaner (1.0.1)
42
42
  diff-lcs (1.2.4)
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: ../../..
3
3
  specs:
4
- spreewald (1.11.0)
4
+ spreewald (1.11.2)
5
5
  cucumber
6
- cucumber_priority
6
+ cucumber_priority (>= 0.3.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -57,7 +57,7 @@ GEM
57
57
  cucumber (>= 1.2.0)
58
58
  nokogiri (>= 1.5.0)
59
59
  rails (>= 3.0.0)
60
- cucumber_priority (0.2.0)
60
+ cucumber_priority (0.3.1)
61
61
  cucumber
62
62
  database_cleaner (1.0.1)
63
63
  diff-lcs (1.3)
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: ../../..
3
3
  specs:
4
- spreewald (1.11.0)
4
+ spreewald (1.11.2)
5
5
  cucumber
6
- cucumber_priority
6
+ cucumber_priority (>= 0.3.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -58,7 +58,7 @@ GEM
58
58
  cucumber (>= 1.2.0)
59
59
  nokogiri (>= 1.5.0)
60
60
  rails (>= 3.0.0)
61
- cucumber_priority (0.2.0)
61
+ cucumber_priority (0.3.1)
62
62
  cucumber
63
63
  database_cleaner (1.0.1)
64
64
  diff-lcs (1.3)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spreewald
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.1
4
+ version: 1.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Kraze
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-28 00:00:00.000000000 Z
11
+ date: 2018-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -94,20 +94,6 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.10.2
97
- - !ruby/object:Gem::Dependency
98
- name: guard-cucumber
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: rspec
113
99
  requirement: !ruby/object:Gem::Requirement
@@ -132,7 +118,10 @@ extensions: []
132
118
  extra_rdoc_files: []
133
119
  files:
134
120
  - ".gitignore"
121
+ - ".rspec"
135
122
  - ".ruby-version"
123
+ - Gemfile
124
+ - Gemfile.lock
136
125
  - LICENSE
137
126
  - README.md
138
127
  - Rakefile
@@ -157,6 +146,9 @@ files:
157
146
  - lib/spreewald_support/tolerance_for_selenium_sync_issues.rb
158
147
  - lib/spreewald_support/version.rb
159
148
  - lib/spreewald_support/web_steps_helpers.rb
149
+ - spec/spec_helper.rb
150
+ - spec/spreewald_support/tolerance_for_selenium_sync_issues_spec.rb
151
+ - spec/support/world.rb
160
152
  - spreewald.gemspec
161
153
  - support/parser.rb
162
154
  - support/paths_manager.rb
@@ -280,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
280
272
  version: '0'
281
273
  requirements: []
282
274
  rubyforge_project:
283
- rubygems_version: 2.7.3
275
+ rubygems_version: 2.7.6
284
276
  signing_key:
285
277
  specification_version: 4
286
278
  summary: Collection of useful cucumber steps.