wist 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bb6a402a82ccab3effa69cea5c049681cbb10ed4
4
+ data.tar.gz: 26eaa1f4a52135ac50200c19683a5e1d3ae46d8c
5
+ SHA512:
6
+ metadata.gz: 5332a3666e05912139c939ebfdadb3968556a2b29a8e0e30ace07928e70f60c54e4d367c954fcf38598d4552cc44c8a418381a224410097f038e928bce63ebeb
7
+ data.tar.gz: e855d76233d1334a23651c7455449a92cade9c7b6e4f773dcaf57ace370b0d4817c5d69d51cac51c1d2489f74873e467295584792d79509d6fd9e2b9ceed2e42
data/Gemfile CHANGED
@@ -1,9 +1,9 @@
1
1
  source 'http://rubygems.org/'
2
2
  gemspec
3
3
 
4
- gem 'capybara', '2.0.2'
4
+ gem 'capybara', '2.0.3'
5
5
  gem 'tconsole'
6
6
  gem 'pry'
7
7
  gem 'turn'
8
8
  gem 'rake'
9
- gem 'poltergeist', git: 'git://github.com/jonleighton/poltergeist.git'
9
+ gem "poltergeist", "1.1.0"
@@ -1,60 +1,51 @@
1
- GIT
2
- remote: git://github.com/jonleighton/poltergeist.git
3
- revision: 98d4a4a8936e8d6b3417f2c057bafaba40874eee
4
- specs:
5
- poltergeist (1.0.2)
6
- capybara (~> 2.0, >= 2.0.1)
7
- faye-websocket (~> 0.4, >= 0.4.4)
8
- http_parser.rb (~> 0.5.3)
9
-
10
1
  PATH
11
2
  remote: .
12
3
  specs:
13
- wist (0.0.4)
4
+ wist (0.0.6)
14
5
  capybara
15
6
 
16
7
  GEM
17
8
  remote: http://rubygems.org/
18
9
  specs:
19
- addressable (2.3.2)
20
10
  ansi (1.4.3)
21
- capybara (2.0.2)
11
+ capybara (2.0.3)
22
12
  mime-types (>= 1.16)
23
13
  nokogiri (>= 1.3.3)
24
14
  rack (>= 1.0.0)
25
15
  rack-test (>= 0.5.4)
26
16
  selenium-webdriver (~> 2.0)
27
17
  xpath (~> 1.0.0)
28
- childprocess (0.3.6)
29
- ffi (~> 1.0, >= 1.0.6)
18
+ childprocess (0.3.9)
19
+ ffi (~> 1.0, >= 1.0.11)
30
20
  coderay (1.0.8)
31
- eventmachine (1.0.0)
32
- faye-websocket (0.4.6)
21
+ eventmachine (1.0.1)
22
+ faye-websocket (0.4.7)
33
23
  eventmachine (>= 0.12.0)
34
- ffi (1.3.1)
24
+ ffi (1.6.0)
35
25
  http_parser.rb (0.5.3)
36
- libwebsocket (0.1.7.1)
37
- addressable
38
- websocket
39
26
  method_source (0.8.1)
40
- mime-types (1.19)
27
+ mime-types (1.21)
41
28
  minitest (4.3.3)
42
- multi_json (1.5.0)
43
- nokogiri (1.5.6)
29
+ multi_json (1.7.2)
30
+ nokogiri (1.5.9)
31
+ poltergeist (1.1.0)
32
+ capybara (~> 2.0, >= 2.0.1)
33
+ faye-websocket (~> 0.4, >= 0.4.4)
34
+ http_parser.rb (~> 0.5.3)
44
35
  pry (0.9.10)
45
36
  coderay (~> 1.0.5)
46
37
  method_source (~> 0.8)
47
38
  slop (~> 3.3.1)
48
- rack (1.4.4)
39
+ rack (1.5.2)
49
40
  rack-test (0.6.2)
50
41
  rack (>= 1.0)
51
42
  rake (10.0.3)
52
43
  rubyzip (0.9.9)
53
- selenium-webdriver (2.27.2)
44
+ selenium-webdriver (2.31.0)
54
45
  childprocess (>= 0.2.5)
55
- libwebsocket (~> 0.1.3)
56
46
  multi_json (~> 1.0)
57
47
  rubyzip
48
+ websocket (~> 1.0.4)
58
49
  slop (3.3.3)
59
50
  tconsole (1.2.7)
60
51
  minitest (~> 4.3.0)
@@ -62,7 +53,7 @@ GEM
62
53
  term-ansicolor (1.0.7)
63
54
  turn (0.9.6)
64
55
  ansi
65
- websocket (1.0.6)
56
+ websocket (1.0.7)
66
57
  xpath (1.0.0)
67
58
  nokogiri (~> 1.3)
68
59
 
@@ -70,8 +61,8 @@ PLATFORMS
70
61
  ruby
71
62
 
72
63
  DEPENDENCIES
73
- capybara (= 2.0.2)
74
- poltergeist!
64
+ capybara (= 2.0.3)
65
+ poltergeist (= 1.1.0)
75
66
  pry
76
67
  rake
77
68
  tconsole
@@ -8,8 +8,14 @@ module Wist
8
8
  end
9
9
  end
10
10
 
11
- def wait_until(&block)
12
- Selenium::WebDriver::Wait.new(timeout: defined?(@wait) ? @wait : 20).until &block
11
+ def wait_until
12
+ Selenium::WebDriver::Wait.new(timeout: defined?(@wait) ? @wait : 20).until do
13
+ begin
14
+ yield
15
+ rescue
16
+ false
17
+ end
18
+ end
13
19
  end
14
20
 
15
21
  def click(selector)
@@ -61,8 +67,7 @@ module Wist
61
67
  end
62
68
 
63
69
  def get_val(selector)
64
- find(selector)
65
- get_js "#{jquery_selector selector}.val()"
70
+ find(selector).value
66
71
  end
67
72
 
68
73
  def set_input_and_press_enter(selector, val)
@@ -85,21 +90,16 @@ module Wist
85
90
  visit current_url
86
91
  end
87
92
 
88
- def element_displayed?(selector)
89
- find(selector).visible?
90
- end
91
-
92
93
  def wait_for_ajax
93
94
  wait_until { get_js '$.isReady && ($.active == 0)' }
94
95
  end
95
96
 
96
97
  def wait_til_element_visible(selector)
97
- el = nil
98
- wait_until do
99
- el = find(selector)
100
- el.visible?
101
- end
102
- el
98
+ has_css?(selector, visible: true)
99
+ find(selector)
103
100
  end
104
101
 
102
+ def scroll_to(selector)
103
+ page.execute_script("#{jquery_selector('html, body')}.scrollTop(#{jquery_selector(selector)}.offset().top)")
104
+ end
105
105
  end
@@ -0,0 +1,3 @@
1
+ #test_scroll_to {
2
+ margin-top: 1000px;
3
+ }
@@ -1,12 +1,13 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
+ <link rel='stylesheet' type='text/css' href='test.css'>
4
5
  </head>
5
6
  <body>
6
7
  <button id='click_test'>foo</button>
7
8
  <button id='wait_test'>foo</button>
8
9
  <button id='enable_tweet_button'>foo</button>
9
- <a href="https://twitter.com/share" class="twitter-share-button" data-text='check this out'></a>
10
+ <a href='https://twitter.com/share' class='twitter-share-button' data-text='check this out'></a>
10
11
  <a id='switch_window_test' href='test1.html' target='_blank'>foo</a>
11
12
  <input id='input_test' type='text' />
12
13
 
@@ -23,8 +24,10 @@
23
24
 
24
25
  <input id='test_set_input_and_press_enter' type='text' />
25
26
 
26
- <script src="jquery.js"></script>
27
- <script src="jquery.cookie.js"></script>
28
- <script src="test.js"></script>
27
+ <div id='test_scroll_to'></div>
28
+
29
+ <script src='jquery.js'></script>
30
+ <script src='jquery.cookie.js'></script>
31
+ <script src='test.js'></script>
29
32
  </body>
30
33
  </html>
@@ -16,6 +16,5 @@ class CapybaraTestCase < Test::Unit::TestCase
16
16
 
17
17
  def teardown
18
18
  Capybara.reset_sessions!
19
- Capybara.use_default_driver
20
19
  end
21
20
  end
@@ -20,7 +20,11 @@ class WistTest < CapybaraTestCase
20
20
  button = find('#wait_test')
21
21
  button.click
22
22
  assert button.text != 'clicked'
23
- wait_until { button.text == 'clicked' }
23
+
24
+ wait_until do
25
+ raise unless button.text == 'clicked'
26
+ true
27
+ end
24
28
  end
25
29
 
26
30
  def test_verify_tweet_button
@@ -73,11 +77,6 @@ class WistTest < CapybaraTestCase
73
77
  assert_equal '', get_val('#input_test')
74
78
  end
75
79
 
76
- def test_element_displayed?
77
- assert_equal false, element_displayed?('#invisible')
78
- assert element_displayed?('#input_test')
79
- end
80
-
81
80
  def test_wait_til_element_visible
82
81
  el = find('#test_wait_til_element_visible')
83
82
  el.click
@@ -103,4 +102,10 @@ class WistTest < CapybaraTestCase
103
102
  end
104
103
  assert_equal('bar', get_val('#test_set_input_and_press_enter'))
105
104
  end
105
+
106
+ def test_scroll_to
107
+ old_offset = get_js('window.pageYOffset')
108
+ scroll_to('#test_scroll_to')
109
+ assert_equal(true, get_js('window.pageYOffset') != old_offset)
110
+ end
106
111
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'wist'
3
- gem.version = '0.0.5'
3
+ gem.version = '0.0.6'
4
4
  gem.summary = 'capybara helpers'
5
5
  gem.author = 'Lihan Li'
6
6
  gem.email = 'frankieteardrop@gmail.com'
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
5
- prerelease:
4
+ version: 0.0.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Lihan Li
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-05 00:00:00.000000000 Z
11
+ date: 2013-03-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: capybara
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  description:
@@ -42,6 +39,7 @@ files:
42
39
  - lib/wist.rb
43
40
  - test/jquery.cookie.js
44
41
  - test/jquery.js
42
+ - test/test.css
45
43
  - test/test.js
46
44
  - test/test0.html
47
45
  - test/test1.html
@@ -50,31 +48,31 @@ files:
50
48
  - wist.gemspec
51
49
  homepage: http://github.com/lihanli/wist
52
50
  licenses: []
51
+ metadata: {}
53
52
  post_install_message:
54
53
  rdoc_options: []
55
54
  require_paths:
56
55
  - lib
57
56
  required_ruby_version: !ruby/object:Gem::Requirement
58
- none: false
59
57
  requirements:
60
- - - ! '>='
58
+ - - '>='
61
59
  - !ruby/object:Gem::Version
62
60
  version: '0'
63
61
  required_rubygems_version: !ruby/object:Gem::Requirement
64
- none: false
65
62
  requirements:
66
- - - ! '>='
63
+ - - '>='
67
64
  - !ruby/object:Gem::Version
68
65
  version: '0'
69
66
  requirements: []
70
67
  rubyforge_project:
71
- rubygems_version: 1.8.23
68
+ rubygems_version: 2.0.0
72
69
  signing_key:
73
- specification_version: 3
70
+ specification_version: 4
74
71
  summary: capybara helpers
75
72
  test_files:
76
73
  - test/jquery.cookie.js
77
74
  - test/jquery.js
75
+ - test/test.css
78
76
  - test/test.js
79
77
  - test/test0.html
80
78
  - test/test1.html