capybara-feature_helpers 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: 06316e01a4224c65700514d0020baa99a66fbfcd
4
+ data.tar.gz: c2c6c445300b810f7b18e1249bddf52802966501
5
+ SHA512:
6
+ metadata.gz: 8421f219b514c8d408cb7d49c9dddb9bab695b50302347615a6a35202ab01620f13b1641d38e022cc8da319656808c4c1c812a64c572b375a9eb8d319a73be7f
7
+ data.tar.gz: 70c502aef599adb086001f25efc491637ff82e4ca31877181a320350bf67f242dcc39a4c764057d7cceed51c1b26711d0f0fde7025ff1d64e352f6f287c1a1f4
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Andriy Yanko
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Capybara feature helpers
2
+
3
+ Set of handy capybara feature helpers used by Railsware:
4
+
5
+ * `within_maybe`
6
+ * `should_see_text`
7
+ * `should_not_see_text`
8
+
9
+ ## Requirements
10
+
11
+ * capybara 2.x
12
+ * rspec 3.x
13
+
14
+ ## Installation
15
+
16
+ Add to your application's `Gemfile`:
17
+
18
+ ```ruby
19
+ group :test do
20
+ gem 'capybara-feature_helpers'
21
+ end
22
+ ```
23
+
24
+ Add to `spec/spec_helper.rb`
25
+ ```ruby
26
+ require 'capybara/feature_helpers'
27
+ ```
28
+
29
+ ## Authors
30
+
31
+ * [Andriy Yanko](http://ayanko.github.io/)
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "capybara-feature_helpers"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Andriy Yanko"]
9
+ spec.email = ["andriy.yanko@railsware.com"]
10
+ spec.summary = %q{Railsware capybara feature helpers}
11
+ spec.homepage = "https://github.com/railsware/capybara-feature_helpers"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0")
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.7"
20
+ spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_development_dependency "rspec", "~> 3.0.0"
22
+ spec.add_development_dependency "capybara", "~> 2.4.0"
23
+ end
@@ -0,0 +1,8 @@
1
+ module Capybara
2
+ module FeatureHelpers
3
+
4
+ alias_method :should_see, :should_see_text
5
+ alias_method :should_not_see, :should_not_see_text
6
+
7
+ end
8
+ end
@@ -0,0 +1,17 @@
1
+ module Capybara
2
+ module FeatureHelpers
3
+
4
+ def should_see_text(text, selector = nil)
5
+ within_maybe(selector) do
6
+ expect(page).to have_text(text)
7
+ end
8
+ end
9
+
10
+ def should_not_see_text(text, selector = nil)
11
+ within_maybe(selector) do
12
+ expect(page).not_to have_text(text)
13
+ end
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ module Capybara
2
+ module FeatureHelpers
3
+
4
+ def within_maybe(*args)
5
+ if args.compact.empty?
6
+ yield
7
+ else
8
+ within(*args) do
9
+ yield
10
+ end
11
+ end
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ require 'capybara/feature_helpers/within_maybe'
2
+ require 'capybara/feature_helpers/should_see_text'
3
+ require 'capybara/feature_helpers/should_see'
4
+
5
+ require 'rspec/core'
6
+
7
+ RSpec.configure do |config|
8
+ config.include Capybara::FeatureHelpers, type: :feature
9
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'should_see_text', type: :feature do
4
+
5
+ TestApp.body = <<-BODY
6
+ <h1 class="title">Hello World</h1>
7
+
8
+ <div class="container">
9
+ <div>Content</div>
10
+ </div>
11
+ BODY
12
+
13
+ it 'should see' do
14
+ should_see_text 'Hello World'
15
+ end
16
+
17
+ it 'should not see' do
18
+ should_not_see_text 'Goodbye World'
19
+ end
20
+
21
+ it 'should see with css selector' do
22
+ should_see_text 'Hello World', '.title'
23
+ end
24
+
25
+ it 'should not see with css selector' do
26
+ should_not_see_text 'Goodbye World', '.container'
27
+ end
28
+
29
+ end
@@ -0,0 +1,12 @@
1
+ require 'capybara/rspec'
2
+ require 'capybara/feature_helpers'
3
+
4
+ require_relative 'support/test_app'
5
+
6
+ Capybara.app = TestApp
7
+
8
+ RSpec.configure do |config|
9
+ config.before(:each) do
10
+ visit '/'
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ class TestApp
2
+ class << self
3
+ attr_accessor :body
4
+
5
+ def call(env)
6
+ [200, {}, build_body]
7
+ end
8
+
9
+ private
10
+
11
+ def build_body
12
+ [
13
+ "<html><body>#{body}</body></html>"
14
+ ]
15
+ end
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capybara-feature_helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andriy Yanko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: capybara
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.4.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.4.0
69
+ description:
70
+ email:
71
+ - andriy.yanko@railsware.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - capybara-feature_helpers.gemspec
82
+ - lib/capybara/feature_helpers.rb
83
+ - lib/capybara/feature_helpers/should_see.rb
84
+ - lib/capybara/feature_helpers/should_see_text.rb
85
+ - lib/capybara/feature_helpers/within_maybe.rb
86
+ - spec/features/should_see_text_spec.rb
87
+ - spec/spec_helper.rb
88
+ - spec/support/test_app.rb
89
+ homepage: https://github.com/railsware/capybara-feature_helpers
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.2.2
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Railsware capybara feature helpers
113
+ test_files:
114
+ - spec/features/should_see_text_spec.rb
115
+ - spec/spec_helper.rb
116
+ - spec/support/test_app.rb