capybara-vue 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7265fc05cb4aa9e7a9369de690e0ec9180bc01b6
4
+ data.tar.gz: d02f37fdce9e00409613f6a568d24263bb802787
5
+ SHA512:
6
+ metadata.gz: 338de5207056b69ea375de4f718b033a8ae4ae0c5648a23053c5a8d660cb1fdef6d3671ec79e7abda86cf5165d2eed5463169d1fedb88c90199596e64833fe98
7
+ data.tar.gz: 91bc137017a29a64414d45d6681d6a710a7c456fa4c7e423e9cdf4c88e09228a0eec7302669dbdb1c45317220010ccfa1d6b69eaba7f0af99b4c91b7755f7dc2
data/.gitignore ADDED
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capybara-vue.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,6 @@
1
+ capybara-vue
2
+ ============
3
+
4
+ Stable integration tests for Vue.js with Capybara.
5
+
6
+ Influenced by [Capybara::Angular](https://github.com/wrozka/capybara-angular).
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capybara/vue/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capybara-vue"
8
+ spec.version = Capybara::Vue::VERSION
9
+ spec.authors = ["Woowa Brothers"]
10
+ spec.email = ["ahastudio@gmail.com"]
11
+ spec.description = %q{Capybara API that knows how to wait for Vue.js in end to end specs}
12
+ spec.summary = %q{Stable Capybara API for Vue.js applications}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'capybara'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ end
@@ -0,0 +1,4 @@
1
+ require "capybara"
2
+
3
+ require_relative "vue/dsl"
4
+ require_relative "vue/waiter"
@@ -0,0 +1,23 @@
1
+ module Capybara
2
+ module Vue
3
+ module DSL
4
+ include Capybara::DSL
5
+
6
+ Capybara::Session::DSL_METHODS.each do |method|
7
+ define_method(method) do |*args, &block|
8
+ page.send(method, *args, &block)
9
+ end
10
+ end
11
+
12
+ def page
13
+ wait_until_vue_ready
14
+ Capybara.current_session
15
+ end
16
+
17
+ def wait_until_vue_ready
18
+ Waiter.new(Capybara.current_session).wait_until_ready
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,5 @@
1
+ module Capybara
2
+ module Vue
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,59 @@
1
+ module Capybara
2
+ module Vue
3
+ class Waiter
4
+ attr_accessor :page
5
+
6
+ def initialize(page)
7
+ @page = page
8
+ end
9
+
10
+ def wait_until_ready
11
+ return unless vue_loaded?
12
+
13
+ setup_ready
14
+
15
+ start = Time.now
16
+ until ready?
17
+ timeout! if timeout?(start)
18
+ setup_ready if page_reloaded_on_wait?
19
+ sleep(0.01)
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def timeout?(start)
26
+ Time.now - start > Capybara.default_wait_time
27
+ end
28
+
29
+ def timeout!
30
+ raise TimeoutError.new("timeout while waiting for vue")
31
+ end
32
+
33
+ def ready?
34
+ page.evaluate_script("window.vueReady")
35
+ end
36
+
37
+ def vue_loaded?
38
+ begin
39
+ page.evaluate_script "(typeof Vue !== 'undefined')"
40
+ rescue Capybara::NotSupportedByDriverError
41
+ false
42
+ end
43
+ end
44
+
45
+ def setup_ready
46
+ page.execute_script <<-JS
47
+ window.vueReady = false;
48
+ Vue.nextTick(function() {
49
+ window.vueReady = true;
50
+ });
51
+ JS
52
+ end
53
+
54
+ def page_reloaded_on_wait?
55
+ page.evaluate_script("window.vueReady === undefined")
56
+ end
57
+ end
58
+ end
59
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capybara-vue
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Woowa Brothers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capybara
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Capybara API that knows how to wait for Vue.js in end to end specs
56
+ email:
57
+ - ahastudio@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE
65
+ - README.md
66
+ - Rakefile
67
+ - capybara-vue.gemspec
68
+ - lib/capybara/vue.rb
69
+ - lib/capybara/vue/dsl.rb
70
+ - lib/capybara/vue/version.rb
71
+ - lib/capybara/vue/waiter.rb
72
+ homepage: ''
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.2.2
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Stable Capybara API for Vue.js applications
96
+ test_files: []