handy_feature_helpers 0.0.1 → 0.0.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
  SHA1:
3
- metadata.gz: cba7dd2dc97cc28ed1e9b63bcc8b4e23a1362c30
4
- data.tar.gz: 41cb5a572dd8e8f891c0feebbc619f1d7083e223
3
+ metadata.gz: fed561e32b774ed59e173853d4e2d16e631c86e1
4
+ data.tar.gz: b9f7a9e5e2998fbe46311cc4a81f5189cc7b5799
5
5
  SHA512:
6
- metadata.gz: b4394e7b8432f8081094f978038e90068e2ea0b4992b75b526ae34a4203b96af6906b6acfa0d3777d4d3a7567a8268dfe4983043fa2227c4893dbc7ae677c700
7
- data.tar.gz: e66f494907ba983796b2749fef9af1fae2bc520120d9997f4b117392096ead4a57c8fdc93ea6bd6fa81ce2c7ed7fecec5ce4012837b74518f0681a62fb58ae46
6
+ metadata.gz: 332e0b8cfae07a0bcb11b00f78d5f80e8072aa268cc98582756fee7f529ffde23464427f51643b08c652beb53ef13fcae25eb0a4ccc01264ea27b92e7badd617
7
+ data.tar.gz: e9bbf22cb12c2ae79f77a8b628b77a352151e495aa1a6174cbcfb0b82bcce4c8a29782d3a5b05bccfedbb0161f943fe17fea9606a3b5482d0478704f3c67d784
data/README.md CHANGED
@@ -5,18 +5,20 @@ Feature helpers for use with Capybara and Rspec
5
5
  ## Installation
6
6
 
7
7
  Add this line to your application's Gemfile:
8
-
9
- gem 'handy_feature_helpers'
8
+ ```ruby
9
+ gem 'handy_feature_helpers'
10
+ ```
10
11
 
11
12
  And then execute:
12
13
 
13
14
  $ bundle
14
15
 
15
16
  Add to your spec_helper.rb:
16
-
17
- RSpec.configure do |config|
18
- config.include HandyFeatureHelpers::Helpers, type: :feature
19
- end
17
+ ```ruby
18
+ RSpec.configure do |config|
19
+ config.include HandyFeatureHelpers::Helpers, type: :feature
20
+ end
21
+ ```
20
22
 
21
23
  ## Usage
22
24
 
@@ -18,6 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency 'capybara'
22
+ spec.add_dependency 'rspec'
23
+
21
24
  spec.add_development_dependency "bundler", "~> 1.3"
22
25
  spec.add_development_dependency "rake"
23
26
  end
@@ -0,0 +1,9 @@
1
+ require "handy_feature_helpers/main_helpers"
2
+ require "handy_feature_helpers/flash_helpers"
3
+
4
+ module HandyFeatureHelpers
5
+ module AllHelpers
6
+ include FlashHelpers
7
+ include MainHelpers
8
+ end
9
+ end
@@ -0,0 +1,33 @@
1
+ module HandyFeatureHelpers
2
+ module FlashHelpers
3
+
4
+ def flash?(text)
5
+ page.should have_selector('#notice', text: text)
6
+ end
7
+
8
+ def flash_created?
9
+ flash? 'successfully created'
10
+ end
11
+
12
+ def flash_updated?
13
+ flash? 'successfully updated'
14
+ end
15
+
16
+ def flash_destroyed?
17
+ flash? 'successfully destroyed'
18
+ end
19
+
20
+ def flash_recovered?
21
+ flash? 'successfully recovered'
22
+ end
23
+
24
+ def flash_uploaded?
25
+ flash? 'successfully uploaded'
26
+ end
27
+
28
+ def flash_error_for(field)
29
+ page.should have_selector("div.#{field}formError")
30
+ end
31
+
32
+ end
33
+ end
@@ -1,5 +1,7 @@
1
+ require 'capybara'
2
+
1
3
  module HandyFeatureHelpers
2
- module Helpers
4
+ module MainHelpers
3
5
 
4
6
  @@resource = ''
5
7
  @@resource_plural = ''
@@ -66,23 +68,15 @@ module HandyFeatureHelpers
66
68
  end
67
69
 
68
70
  def accept_alert
69
- page.driver.browser.switch_to.alert.accept
71
+ if Capybara.javascript_driver == 'selenium'
72
+ page.driver.switch_to.alert.accept rescue Selenium::WebDriver::Error::NoAlertOpenError
73
+ end
70
74
  end
71
75
 
72
76
  def size_of(selector)
73
77
  page.all(selector).size
74
78
  end
75
79
 
76
- def wait_until_visible(selector)
77
- wait_for_ajax
78
- wait_until { find(selector).visible? }
79
- end
80
-
81
- def wait_until_invisible(selector)
82
- wait_for_ajax
83
- wait_until { !page.find(selector).visible? }
84
- end
85
-
86
80
  def visible?(selector)
87
81
  find(selector).visible?
88
82
  end
@@ -99,31 +93,34 @@ module HandyFeatureHelpers
99
93
  find("option[value='#{resource.id}']").click
100
94
  end
101
95
 
96
+ def has_content?(text)
97
+ expect(page).to have_content(text)
98
+ end
99
+
100
+ def has_no_content?(text)
101
+ expect(page).to have_no_content(text)
102
+ end
103
+
102
104
  def ensure_delete_is_working
103
105
  tr_count = size_of table_rows
104
106
  within(table) { click delete_link }
105
-
106
107
  accept_alert
107
-
108
- wait_until { size_of(table_rows) == tr_count - 1 }
108
+ size_of(table_rows) == tr_count - 1
109
109
  end
110
110
 
111
111
  def ensure_cancel_creating_is_working
112
112
  click cancel_link
113
113
 
114
- wait_for_ajax
115
-
116
114
  invisible? form
117
115
  click new_link
118
116
 
119
- wait_for_ajax
120
117
  visible? submit
121
118
  invisible? new_link
122
119
  end
123
120
 
124
121
  def ensure_cancel_modal_is_working
125
122
  click cancel_link
126
- wait_until_invisible modal
123
+ invisible? modal
127
124
  end
128
125
 
129
126
  def has_validations?
@@ -1,3 +1,3 @@
1
1
  module HandyFeatureHelpers
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,5 +1,7 @@
1
1
  require "handy_feature_helpers/version"
2
- require "handy_feature_helpers/helpers"
2
+ require "handy_feature_helpers/all_helpers"
3
+ require "handy_feature_helpers/main_helpers"
4
+ require "handy_feature_helpers/flash_helpers"
3
5
 
4
6
  module HandyFeatureHelpers
5
7
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handy_feature_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vassil Kalkov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-11 00:00:00.000000000 Z
11
+ date: 2013-08-13 00:00:00.000000000 Z
12
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: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: bundler
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,7 +80,9 @@ files:
52
80
  - Rakefile
53
81
  - handy_feature_helpers.gemspec
54
82
  - lib/handy_feature_helpers.rb
55
- - lib/handy_feature_helpers/helpers.rb
83
+ - lib/handy_feature_helpers/all_helpers.rb
84
+ - lib/handy_feature_helpers/flash_helpers.rb
85
+ - lib/handy_feature_helpers/main_helpers.rb
56
86
  - lib/handy_feature_helpers/version.rb
57
87
  homepage: ''
58
88
  licenses: