wist 0.0.7 → 0.0.8

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: fbc06a3b129c1c6c9b7f6715e9f2e2065dd2c397
4
- data.tar.gz: f30b2539cbe103b2d5a9379c3cdfa786b5466747
3
+ metadata.gz: defbea13737d26d4cdbc46898f6fb193512bb242
4
+ data.tar.gz: f71f5d8a862b0791cbbaa78e75da5f10cb8b21ae
5
5
  SHA512:
6
- metadata.gz: 9c4430cd97e892c41ee486fad1d9e205b84f4452a23b123922e1e7c4c2737b7acc896ecda4a04ab99527e96bcf6dc536d887f0962fed4a6f12398b1276c456f1
7
- data.tar.gz: b437373e8368f6d6d1a53100697aeef3a06a1f898a45a1faf94dfb429a532afe889eb68e11f35c224c126a92c6441b4d719c4f24488ef19a217ecc6ae97b8cdc
6
+ metadata.gz: ef438a027f1b3beff9f89d69e664a38fdd876da9c9deb9b8373bcfb1e07b28cacfbcb22ffdd97b3a6aa07706d34b524aba4d68b2a0459695cf085415c940be5b
7
+ data.tar.gz: 2bbae2c698f949703194505695d2dc55325e3db90d1a194d2ba797ab6782904c502ed9d7133952abc88ff170750d3eea68adeff8a07934b629332a432b4a12be
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wist (0.0.6)
4
+ wist (0.0.7)
5
5
  capybara
6
6
 
7
7
  GEM
@@ -15,16 +15,17 @@ GEM
15
15
  rack-test (>= 0.5.4)
16
16
  selenium-webdriver (~> 2.0)
17
17
  xpath (~> 1.0.0)
18
+ chattyproc (1.0.0)
18
19
  childprocess (0.3.9)
19
20
  ffi (~> 1.0, >= 1.0.11)
20
- coderay (1.0.8)
21
- eventmachine (1.0.1)
21
+ coderay (1.0.9)
22
+ eventmachine (1.0.3)
22
23
  faye-websocket (0.4.7)
23
24
  eventmachine (>= 0.12.0)
24
25
  ffi (1.6.0)
25
26
  http_parser.rb (0.5.3)
26
27
  method_source (0.8.1)
27
- mime-types (1.21)
28
+ mime-types (1.22)
28
29
  minitest (4.3.3)
29
30
  multi_json (1.7.2)
30
31
  nokogiri (1.5.9)
@@ -32,22 +33,23 @@ GEM
32
33
  capybara (~> 2.0, >= 2.0.1)
33
34
  faye-websocket (~> 0.4, >= 0.4.4)
34
35
  http_parser.rb (~> 0.5.3)
35
- pry (0.9.10)
36
+ pry (0.9.12)
36
37
  coderay (~> 1.0.5)
37
38
  method_source (~> 0.8)
38
- slop (~> 3.3.1)
39
+ slop (~> 3.4)
39
40
  rack (1.5.2)
40
41
  rack-test (0.6.2)
41
42
  rack (>= 1.0)
42
- rake (10.0.3)
43
+ rake (10.0.4)
43
44
  rubyzip (0.9.9)
44
- selenium-webdriver (2.31.0)
45
+ selenium-webdriver (2.32.1)
45
46
  childprocess (>= 0.2.5)
46
47
  multi_json (~> 1.0)
47
48
  rubyzip
48
49
  websocket (~> 1.0.4)
49
- slop (3.3.3)
50
- tconsole (1.2.7)
50
+ slop (3.4.4)
51
+ tconsole (1.2.8)
52
+ chattyproc (~> 1.0.0)
51
53
  minitest (~> 4.3.0)
52
54
  term-ansicolor (~> 1.0.7)
53
55
  term-ansicolor (1.0.7)
data/lib/wist.rb CHANGED
@@ -8,6 +8,14 @@ module Wist
8
8
  end
9
9
  end
10
10
 
11
+ module Helpers
12
+ class << self
13
+ def blank?(obj)
14
+ obj.respond_to?(:empty?) ? obj.empty? : !obj
15
+ end
16
+ end
17
+ end
18
+
11
19
  def wait_until
12
20
  Selenium::WebDriver::Wait.new(timeout: Capybara.default_wait_time).until do
13
21
  begin
@@ -76,7 +84,9 @@ module Wist
76
84
  end
77
85
 
78
86
  def has_class?(el, class_name)
79
- el[:class].split(' ').include?(class_name)
87
+ klass = el[:class]
88
+ return false if Helpers.blank?(klass)
89
+ klass.split(' ').include?(class_name)
80
90
  end
81
91
 
82
92
  def wait_for_new_url(element_to_click)
@@ -102,4 +112,11 @@ module Wist
102
112
  def scroll_to(selector)
103
113
  page.execute_script("#{jquery_selector('html, body')}.scrollTop(#{jquery_selector(selector)}.offset().top)")
104
114
  end
115
+
116
+ %w(first all).each do |finder|
117
+ define_method(:"#{finder}_with_wait") do |selector|
118
+ has_css?(selector)
119
+ page.send(finder.to_sym, selector)
120
+ end
121
+ end
105
122
  end
data/test/test.js CHANGED
@@ -34,3 +34,11 @@ $('#test_set_value_and_trigger_evts').change(function () {
34
34
  $('#test_set_input_and_press_enter').keydown(function (e) {
35
35
  if (e.which === 13) alert('enter pressed');
36
36
  });
37
+
38
+ $('#finder_with_wait').click(function () {
39
+ var $this = $(this);
40
+
41
+ setTimeout(function () {
42
+ $this.addClass('done');
43
+ }, 1000);
44
+ });
data/test/test0.html CHANGED
@@ -26,6 +26,8 @@
26
26
 
27
27
  <div id='test_scroll_to'></div>
28
28
 
29
+ <button id='finder_with_wait'>foo</button>
30
+
29
31
  <script src='jquery.js'></script>
30
32
  <script src='jquery.cookie.js'></script>
31
33
  <script src='test.js'></script>
@@ -57,6 +57,8 @@ class WistTest < CapybaraTestCase
57
57
  el = find('#class_test')
58
58
  %w(foo bar).each { |c| assert_equal(true, has_class?(el, c)) }
59
59
  assert_equal(false, has_class?(el, 'baz'))
60
+
61
+ assert_equal(false, has_class?(find('#click_test'), 'foo'))
60
62
  end
61
63
 
62
64
  def test_alert_accept
@@ -108,4 +110,13 @@ class WistTest < CapybaraTestCase
108
110
  scroll_to('#test_scroll_to')
109
111
  assert_equal(true, get_js('window.pageYOffset') != old_offset)
110
112
  end
113
+
114
+ def test_finder_with_wait
115
+ click('#finder_with_wait')
116
+ assert_equal('finder_with_wait', first_with_wait('.done')[:id])
117
+
118
+ refresh
119
+ click('#finder_with_wait')
120
+ assert_equal('finder_with_wait', all_with_wait('.done')[0][:id])
121
+ end
111
122
  end
data/wist.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'wist'
3
- gem.version = '0.0.7'
3
+ gem.version = '0.0.8'
4
4
  gem.summary = 'capybara helpers'
5
5
  gem.author = 'Lihan Li'
6
6
  gem.email = 'frankieteardrop@gmail.com'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lihan Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-02 00:00:00.000000000 Z
11
+ date: 2013-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara