capybara-experience 0.1.2 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/capybara/experience/rspec.rb +30 -26
- data/lib/capybara/experience/version.rb +1 -1
- data/lib/capybara/experience.rb +5 -14
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66f9abbe2b8c449fd5757456f39cf7c376adbf1fb456ed462cb452adf4cb5aa6
|
4
|
+
data.tar.gz: 4a8c6b7d01a40beaa5653a46693272239dfbb826f7403c8ff16549bf0a3ed6d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3889ec278546633b65a980942773fec6c0f5517812328ed687eeff7056774ada49f3e9fe96f460b18df380c512eb30fdf171bbf87500358887887e6621efb8e4
|
7
|
+
data.tar.gz: d950c605b5aa346db94b184a56d39f5c12b8f97c6f594a5a2fe2f3a8059fc2588bd7e970d090871b950ee8e06128aea9b341e24ff9de09d8bb260df8ba3c1ee4
|
data/README.md
CHANGED
@@ -36,6 +36,8 @@ This scenario is for your standard user/admin.
|
|
36
36
|
```ruby
|
37
37
|
# spec/support/experiences/user_experience.rb
|
38
38
|
class UserExperience < Capybara::Experience
|
39
|
+
include Rails.application.routes.url_helpers
|
40
|
+
|
39
41
|
def login(user)
|
40
42
|
@user = user
|
41
43
|
login_as user, scope: :user
|
@@ -98,7 +100,7 @@ RSpec.describe "sign up flow", feature: true do
|
|
98
100
|
|
99
101
|
it "works" do
|
100
102
|
behavior "user can sign up" do # behaviors are an added DSL by capybara-experiences to group interactions & assertions
|
101
|
-
guest_ux =
|
103
|
+
guest_ux = GuestExperience.new
|
102
104
|
guest_ux.navigate_to_sign_up
|
103
105
|
|
104
106
|
guest_ux.sign_up(
|
@@ -1,30 +1,34 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
|
3
|
+
module Capybara
|
4
|
+
class Experience
|
5
|
+
module BehaviorDSL
|
6
|
+
def behavior(name)
|
7
|
+
metadata[:description_args].push(name)
|
8
|
+
refresh_description unless in_continuous_integration_env?
|
9
|
+
yield
|
10
|
+
metadata[:description_args].pop
|
11
|
+
refresh_description unless in_continuous_integration_env?
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def refresh_description
|
17
|
+
metadata[:description] = metadata[:description_args].join(" ")
|
18
|
+
metadata[:full_description] = [metadata[:example_group][:full_description]].concat(metadata[:description_args]).join(" ")
|
19
|
+
end
|
20
|
+
|
21
|
+
def metadata
|
22
|
+
RSpec.current_example.metadata
|
23
|
+
end
|
24
|
+
|
25
|
+
def in_continuous_integration_env?
|
26
|
+
ENV["CI"].present?
|
27
|
+
end
|
9
28
|
end
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def refresh_description
|
14
|
-
metadata[:description] = metadata[:description_args].join(" ")
|
15
|
-
metadata[:full_description] = [metadata[:example_group][:full_description]].concat(metadata[:description_args]).join(" ")
|
29
|
+
|
30
|
+
RSpec.configure do |config|
|
31
|
+
config.include BehaviorDSL
|
16
32
|
end
|
17
|
-
|
18
|
-
def metadata
|
19
|
-
RSpec.current_example.metadata
|
20
|
-
end
|
21
|
-
|
22
|
-
def in_continuous_integration_env?
|
23
|
-
ENV["CI"].present?
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
RSpec.configure do |config|
|
28
|
-
config.include BehaviorDSL
|
29
33
|
end
|
30
|
-
|
34
|
+
end
|
data/lib/capybara/experience.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require "capybara/dsl"
|
2
3
|
require "capybara/experience/session"
|
3
4
|
|
4
5
|
module Capybara
|
5
6
|
class Experience
|
6
7
|
include Capybara::DSL
|
7
|
-
include Rails.application.routes.url_helpers
|
8
|
-
include Warden::Test::Helpers
|
9
8
|
|
10
|
-
delegate :t, to: I18n
|
9
|
+
delegate :t, to: I18n if defined?(I18n)
|
11
10
|
|
12
11
|
def initialize(driver_name: nil)
|
13
12
|
@driver_name = driver_name
|
@@ -37,20 +36,12 @@ module Capybara
|
|
37
36
|
save_and_open_screenshot(path, options.merge(full: true))
|
38
37
|
end
|
39
38
|
|
40
|
-
def current_driver_adapter
|
41
|
-
adapter = ShowMeTheCookies.adapters[driver_name]
|
42
|
-
if adapter.nil?
|
43
|
-
raise(ShowMeTheCookies::UnknownDriverError, "Unsupported driver #{driver_name}, use one of #{ShowMeTheCookies.adapters.keys} or register your new driver with ShowMeTheCookies.register_adapter")
|
44
|
-
end
|
45
|
-
adapter.new(page.driver)
|
46
|
-
end
|
47
|
-
|
48
39
|
def click_with_js(element)
|
49
40
|
xpath = element.path
|
50
41
|
execute_script <<~JS
|
51
|
-
|
52
|
-
|
53
|
-
|
42
|
+
document.evaluate('#{xpath}', document, null, XPathResult.ANY_TYPE, null)
|
43
|
+
.iterateNext()
|
44
|
+
.click()
|
54
45
|
JS
|
55
46
|
end
|
56
47
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-experience
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Ong
|
8
8
|
- Britt Lewis
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-09-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -81,7 +81,7 @@ licenses: []
|
|
81
81
|
metadata:
|
82
82
|
homepage_uri: https://github.com/ryanong/capybara-experience
|
83
83
|
source_code_uri: https://github.com/ryanong/capybara-experience
|
84
|
-
post_install_message:
|
84
|
+
post_install_message:
|
85
85
|
rdoc_options: []
|
86
86
|
require_paths:
|
87
87
|
- lib
|
@@ -96,8 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
|
-
rubygems_version: 3.
|
100
|
-
signing_key:
|
99
|
+
rubygems_version: 3.3.17
|
100
|
+
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Simplify Capybara testing for larger applications
|
103
103
|
test_files: []
|