rails_extras 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +24 -0
- data/lib/rails_extras/rspec/support/wait_for_ajax.rb +18 -0
- data/lib/rails_extras/version.rb +1 -1
- metadata +3 -2
data/README.md
CHANGED
@@ -19,6 +19,8 @@ Or install it yourself as:
|
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
22
|
+
### Helper
|
23
|
+
|
22
24
|
```ruby
|
23
25
|
add_link('http://example.com', class: 'text-info') do |tag|
|
24
26
|
tag.space "link"
|
@@ -27,6 +29,28 @@ add_link('http://example.com', class: 'text-info') do |tag|
|
|
27
29
|
end
|
28
30
|
end #=> <a href='http://example.com', class: 'text-info'>link 123</a>
|
29
31
|
```
|
32
|
+
|
33
|
+
### RSpec
|
34
|
+
|
35
|
+
Some times are tests which are faster than browser can reload or load page
|
36
|
+
(click link). For this situations we should use ```wait_for_ajax``` mathod.
|
37
|
+
If you want use this method you first should add to file ```spec_helper.rb```
|
38
|
+
this configuration
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
RSpec.configure do |config|
|
42
|
+
config.include ::RailsExtras::RSpec::Support::WaitForAjax, type: :feature
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
and then you can add ```wait_for_ajax``` method to your scenario
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
click_button "Next"
|
50
|
+
wait_for_ajax
|
51
|
+
expect(page).to have_content "Next page"
|
52
|
+
```
|
53
|
+
|
30
54
|
# License
|
31
55
|
|
32
56
|
RailsExtras uses the MIT license. Please check the [LICENSE][] file for more details.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class RailsExtras
|
2
|
+
module RSpec
|
3
|
+
module Support
|
4
|
+
module WaitForAjax
|
5
|
+
|
6
|
+
def wait_for_ajax
|
7
|
+
counter = 0
|
8
|
+
while page.execute_script("return $.active").to_i > 0
|
9
|
+
counter += 1
|
10
|
+
sleep(0.1)
|
11
|
+
raise "AJAX request took longer than 3 seconds." if counter >= 30
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/rails_extras/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_extras
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-06-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- lib/rails_extras/helpers/tag.rb
|
92
92
|
- lib/rails_extras/rspec/formatters/numeric_progress.rb
|
93
93
|
- lib/rails_extras/rspec/support/common.rb
|
94
|
+
- lib/rails_extras/rspec/support/wait_for_ajax.rb
|
94
95
|
- lib/rails_extras/version.rb
|
95
96
|
- rails_extras.gemspec
|
96
97
|
- spec/dummy/app/controllers/application_controller.rb
|