page_magic 2.0.4 → 2.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/page_magic/session.rb +12 -3
- metadata +55 -90
- data/.codeclimate.yml +0 -4
- data/.pullreview.yml +0 -14
- data/.rspec +0 -1
- data/.rubocop.yml +0 -39
- data/.simplecov +0 -10
- data/.zsh_config +0 -6
- data/Dockerfile +0 -11
- data/Gemfile +0 -24
- data/Gemfile.lock +0 -175
- data/Makefile +0 -17
- data/Rakefile +0 -32
- data/circle.yml +0 -8
- data/page_magic.gemspec +0 -128
- data/spec/lib/active_support/core_ext/object/to_query_test.rb +0 -78
- data/spec/page_magic/class_methods_spec.rb +0 -92
- data/spec/page_magic/comparator/fuzzy_spec.rb +0 -44
- data/spec/page_magic/comparator/literal_spec.rb +0 -41
- data/spec/page_magic/comparator/null_spec.rb +0 -35
- data/spec/page_magic/comparator/parameter_map_spec.rb +0 -75
- data/spec/page_magic/driver_spec.rb +0 -40
- data/spec/page_magic/drivers/poltergeist_spec.rb +0 -8
- data/spec/page_magic/drivers/rack_test_spec.rb +0 -8
- data/spec/page_magic/drivers/selenium_spec.rb +0 -15
- data/spec/page_magic/drivers_spec.rb +0 -48
- data/spec/page_magic/element/locators_spec.rb +0 -36
- data/spec/page_magic/element/not_found_spec.rb +0 -24
- data/spec/page_magic/element/query/multiple_results_spec.rb +0 -14
- data/spec/page_magic/element/query/single_result_spec.rb +0 -21
- data/spec/page_magic/element/query_spec.rb +0 -38
- data/spec/page_magic/element/selector_spec.rb +0 -166
- data/spec/page_magic/element_context_spec.rb +0 -72
- data/spec/page_magic/element_definition_builder_spec.rb +0 -19
- data/spec/page_magic/element_spec.rb +0 -256
- data/spec/page_magic/elements/config_spec.rb +0 -203
- data/spec/page_magic/elements_spec.rb +0 -125
- data/spec/page_magic/instance_methods_spec.rb +0 -90
- data/spec/page_magic/mapping_spec.rb +0 -181
- data/spec/page_magic/session_methods_spec.rb +0 -40
- data/spec/page_magic/session_spec.rb +0 -149
- data/spec/page_magic/transitions_spec.rb +0 -43
- data/spec/page_magic/utils/string_spec.rb +0 -29
- data/spec/page_magic/utils/url_spec.rb +0 -9
- data/spec/page_magic/wait_methods_spec.rb +0 -35
- data/spec/page_magic/watcher_spec.rb +0 -22
- data/spec/page_magic/watchers_spec.rb +0 -80
- data/spec/page_magic_spec.rb +0 -115
- data/spec/spec_helper.rb +0 -15
- data/spec/support/shared_contexts.rb +0 -5
- data/spec/support/shared_examples.rb +0 -25
data/Gemfile.lock
DELETED
@@ -1,175 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: https://rubygems.org/
|
3
|
-
specs:
|
4
|
-
activesupport (6.1.3.1)
|
5
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
|
-
i18n (>= 1.6, < 2)
|
7
|
-
minitest (>= 5.1)
|
8
|
-
tzinfo (~> 2.0)
|
9
|
-
zeitwerk (~> 2.3)
|
10
|
-
addressable (2.4.0)
|
11
|
-
ast (2.4.2)
|
12
|
-
builder (3.2.4)
|
13
|
-
capybara (3.35.3)
|
14
|
-
addressable
|
15
|
-
mini_mime (>= 0.1.3)
|
16
|
-
nokogiri (~> 1.8)
|
17
|
-
rack (>= 1.6.0)
|
18
|
-
rack-test (>= 0.6.3)
|
19
|
-
regexp_parser (>= 1.5, < 3.0)
|
20
|
-
xpath (~> 3.2)
|
21
|
-
childprocess (3.0.0)
|
22
|
-
cliver (0.3.2)
|
23
|
-
concurrent-ruby (1.1.8)
|
24
|
-
descendants_tracker (0.0.4)
|
25
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
26
|
-
diff-lcs (1.4.4)
|
27
|
-
docile (1.3.5)
|
28
|
-
faraday (0.9.2)
|
29
|
-
multipart-post (>= 1.2, < 3)
|
30
|
-
git (1.8.1)
|
31
|
-
rchardet (~> 1.8)
|
32
|
-
github-markup (4.0.0)
|
33
|
-
github_api (0.16.0)
|
34
|
-
addressable (~> 2.4.0)
|
35
|
-
descendants_tracker (~> 0.0.4)
|
36
|
-
faraday (~> 0.8, < 0.10)
|
37
|
-
hashie (>= 3.4)
|
38
|
-
mime-types (>= 1.16, < 3.0)
|
39
|
-
oauth2 (~> 1.0)
|
40
|
-
hashie (4.1.0)
|
41
|
-
highline (2.0.3)
|
42
|
-
i18n (1.8.10)
|
43
|
-
concurrent-ruby (~> 1.0)
|
44
|
-
jeweler (2.3.9)
|
45
|
-
builder
|
46
|
-
bundler
|
47
|
-
git (>= 1.2.5)
|
48
|
-
github_api (~> 0.16.0)
|
49
|
-
highline (>= 1.6.15)
|
50
|
-
nokogiri (>= 1.5.10)
|
51
|
-
psych
|
52
|
-
rake
|
53
|
-
rdoc
|
54
|
-
semver2
|
55
|
-
jwt (2.2.2)
|
56
|
-
mime-types (2.99.3)
|
57
|
-
mini_mime (1.1.0)
|
58
|
-
mini_portile2 (2.5.0)
|
59
|
-
minitest (5.14.4)
|
60
|
-
multi_json (1.15.0)
|
61
|
-
multi_xml (0.6.0)
|
62
|
-
multipart-post (2.1.1)
|
63
|
-
mustermann (1.1.1)
|
64
|
-
ruby2_keywords (~> 0.0.1)
|
65
|
-
nokogiri (1.11.3)
|
66
|
-
mini_portile2 (~> 2.5.0)
|
67
|
-
racc (~> 1.4)
|
68
|
-
oauth2 (1.4.7)
|
69
|
-
faraday (>= 0.8, < 2.0)
|
70
|
-
jwt (>= 1.0, < 3.0)
|
71
|
-
multi_json (~> 1.3)
|
72
|
-
multi_xml (~> 0.5)
|
73
|
-
rack (>= 1.2, < 3)
|
74
|
-
parallel (1.20.1)
|
75
|
-
parser (3.0.1.1)
|
76
|
-
ast (~> 2.4.1)
|
77
|
-
poltergeist (1.18.1)
|
78
|
-
capybara (>= 2.1, < 4)
|
79
|
-
cliver (~> 0.3.1)
|
80
|
-
websocket-driver (>= 0.2.0)
|
81
|
-
psych (3.3.1)
|
82
|
-
racc (1.5.2)
|
83
|
-
rack (2.2.3)
|
84
|
-
rack-protection (2.1.0)
|
85
|
-
rack
|
86
|
-
rack-test (1.1.0)
|
87
|
-
rack (>= 1.0, < 3)
|
88
|
-
rainbow (3.0.0)
|
89
|
-
rake (13.0.3)
|
90
|
-
rchardet (1.8.0)
|
91
|
-
rdoc (6.3.0)
|
92
|
-
redcarpet (3.5.1)
|
93
|
-
regexp_parser (2.1.1)
|
94
|
-
rexml (3.2.5)
|
95
|
-
rspec (3.10.0)
|
96
|
-
rspec-core (~> 3.10.0)
|
97
|
-
rspec-expectations (~> 3.10.0)
|
98
|
-
rspec-mocks (~> 3.10.0)
|
99
|
-
rspec-core (3.10.1)
|
100
|
-
rspec-support (~> 3.10.0)
|
101
|
-
rspec-expectations (3.10.1)
|
102
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
103
|
-
rspec-support (~> 3.10.0)
|
104
|
-
rspec-mocks (3.10.2)
|
105
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
106
|
-
rspec-support (~> 3.10.0)
|
107
|
-
rspec-support (3.10.2)
|
108
|
-
rubocop (1.15.0)
|
109
|
-
parallel (~> 1.10)
|
110
|
-
parser (>= 3.0.0.0)
|
111
|
-
rainbow (>= 2.2.2, < 4.0)
|
112
|
-
regexp_parser (>= 1.8, < 3.0)
|
113
|
-
rexml
|
114
|
-
rubocop-ast (>= 1.5.0, < 2.0)
|
115
|
-
ruby-progressbar (~> 1.7)
|
116
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
117
|
-
rubocop-ast (1.5.0)
|
118
|
-
parser (>= 3.0.1.1)
|
119
|
-
rubocop-rspec (2.1.0)
|
120
|
-
rubocop (~> 1.0)
|
121
|
-
rubocop-ast (>= 1.1.0)
|
122
|
-
ruby-debug-ide (0.7.2)
|
123
|
-
rake (>= 0.8.1)
|
124
|
-
ruby-progressbar (1.11.0)
|
125
|
-
ruby2_keywords (0.0.4)
|
126
|
-
rubyzip (2.3.0)
|
127
|
-
selenium-webdriver (3.142.7)
|
128
|
-
childprocess (>= 0.5, < 4.0)
|
129
|
-
rubyzip (>= 1.2.2)
|
130
|
-
semver2 (3.4.2)
|
131
|
-
simplecov (0.21.2)
|
132
|
-
docile (~> 1.1)
|
133
|
-
simplecov-html (~> 0.11)
|
134
|
-
simplecov_json_formatter (~> 0.1)
|
135
|
-
simplecov-html (0.12.3)
|
136
|
-
simplecov_json_formatter (0.1.2)
|
137
|
-
sinatra (2.1.0)
|
138
|
-
mustermann (~> 1.0)
|
139
|
-
rack (~> 2.2)
|
140
|
-
rack-protection (= 2.1.0)
|
141
|
-
tilt (~> 2.0)
|
142
|
-
thread_safe (0.3.6)
|
143
|
-
tilt (2.0.10)
|
144
|
-
tzinfo (2.0.4)
|
145
|
-
concurrent-ruby (~> 1.0)
|
146
|
-
unicode-display_width (2.0.0)
|
147
|
-
websocket-driver (0.7.3)
|
148
|
-
websocket-extensions (>= 0.1.0)
|
149
|
-
websocket-extensions (0.1.5)
|
150
|
-
xpath (3.2.0)
|
151
|
-
nokogiri (~> 1.8)
|
152
|
-
yard (0.9.26)
|
153
|
-
zeitwerk (2.4.2)
|
154
|
-
|
155
|
-
PLATFORMS
|
156
|
-
ruby
|
157
|
-
|
158
|
-
DEPENDENCIES
|
159
|
-
activesupport
|
160
|
-
capybara (>= 3.0)
|
161
|
-
github-markup
|
162
|
-
jeweler
|
163
|
-
poltergeist
|
164
|
-
redcarpet
|
165
|
-
rspec
|
166
|
-
rubocop
|
167
|
-
rubocop-rspec
|
168
|
-
ruby-debug-ide
|
169
|
-
selenium-webdriver
|
170
|
-
simplecov
|
171
|
-
sinatra
|
172
|
-
yard (~> 0.8)
|
173
|
-
|
174
|
-
BUNDLED WITH
|
175
|
-
2.1.4
|
data/Makefile
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
.PHONY: help
|
2
|
-
DOCKER_IMAGE = lvl-up/page-magic
|
3
|
-
MOUNT_DIR = /page_magic
|
4
|
-
|
5
|
-
help:
|
6
|
-
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
7
|
-
|
8
|
-
docker: ## build project docker image
|
9
|
-
docker build -t $(DOCKER_IMAGE) .
|
10
|
-
|
11
|
-
test: ## Run tests
|
12
|
-
docker run -v $(PWD):$(MOUNT_DIR) -w $(MOUNT_DIR) -t $(DOCKER_IMAGE) bundle exec rspec
|
13
|
-
|
14
|
-
build: docker ## build gem
|
15
|
-
rake build
|
16
|
-
|
17
|
-
all: docker test build ## run all targets before building gem
|
data/Rakefile
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
Bundler.require :test, :development
|
4
|
-
|
5
|
-
RuboCop::RakeTask.new
|
6
|
-
|
7
|
-
RSpec::Core::RakeTask.new(:spec) do
|
8
|
-
ENV['coverage'] = 'true'
|
9
|
-
end
|
10
|
-
|
11
|
-
Jeweler::Tasks.new do |gem|
|
12
|
-
gem.name = 'page_magic'
|
13
|
-
gem.homepage = 'https://github.com/ladtech/page_magic'
|
14
|
-
gem.license = 'ruby'
|
15
|
-
gem.summary = 'Framework for modeling and interacting with webpages'
|
16
|
-
gem.description = 'Framework for modeling and interacting with webpages which wraps capybara'
|
17
|
-
gem.email = 'info@lvl-up.uk'
|
18
|
-
gem.authors = ['Leon Davis']
|
19
|
-
gem.required_ruby_version = '>= 2.1'
|
20
|
-
end
|
21
|
-
|
22
|
-
Jeweler::RubygemsDotOrgTasks.new
|
23
|
-
|
24
|
-
require 'rake/testtask'
|
25
|
-
Rake::TestTask.new do |t|
|
26
|
-
t.libs << 'spec'
|
27
|
-
t.pattern = 'spec/**/*_test.rb'
|
28
|
-
t.warning = true
|
29
|
-
t.verbose = true
|
30
|
-
end
|
31
|
-
|
32
|
-
task default: [:spec, :test, 'rubocop:auto_correct']
|
data/circle.yml
DELETED
data/page_magic.gemspec
DELETED
@@ -1,128 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: page_magic 1.2.9 ruby lib
|
6
|
-
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.name = "page_magic"
|
9
|
-
s.version = "1.2.9"
|
10
|
-
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
-
s.require_paths = ["lib"]
|
13
|
-
s.authors = ["Leon Davis"]
|
14
|
-
s.date = "2017-10-03"
|
15
|
-
s.description = "Framework for modeling and interacting with webpages which wraps capybara"
|
16
|
-
s.email = "info@lad-tech.com"
|
17
|
-
s.extra_rdoc_files = [
|
18
|
-
"README.md"
|
19
|
-
]
|
20
|
-
s.files = [
|
21
|
-
".codeclimate.yml",
|
22
|
-
".pullreview.yml",
|
23
|
-
".rspec",
|
24
|
-
".rubocop.yml",
|
25
|
-
".simplecov",
|
26
|
-
".yardopts",
|
27
|
-
"Gemfile",
|
28
|
-
"Gemfile.lock",
|
29
|
-
"README.md",
|
30
|
-
"Rakefile",
|
31
|
-
"VERSION",
|
32
|
-
"circle.yml",
|
33
|
-
"lib/active_support/core_ext/object/to_query.rb",
|
34
|
-
"lib/page_magic.rb",
|
35
|
-
"lib/page_magic/class_methods.rb",
|
36
|
-
"lib/page_magic/driver.rb",
|
37
|
-
"lib/page_magic/drivers.rb",
|
38
|
-
"lib/page_magic/drivers/poltergeist.rb",
|
39
|
-
"lib/page_magic/drivers/rack_test.rb",
|
40
|
-
"lib/page_magic/drivers/selenium.rb",
|
41
|
-
"lib/page_magic/element.rb",
|
42
|
-
"lib/page_magic/element/locators.rb",
|
43
|
-
"lib/page_magic/element/query.rb",
|
44
|
-
"lib/page_magic/element/query_builder.rb",
|
45
|
-
"lib/page_magic/element/selector.rb",
|
46
|
-
"lib/page_magic/element/selector_methods.rb",
|
47
|
-
"lib/page_magic/element_context.rb",
|
48
|
-
"lib/page_magic/element_definition_builder.rb",
|
49
|
-
"lib/page_magic/elements.rb",
|
50
|
-
"lib/page_magic/exceptions.rb",
|
51
|
-
"lib/page_magic/instance_methods.rb",
|
52
|
-
"lib/page_magic/matcher.rb",
|
53
|
-
"lib/page_magic/session.rb",
|
54
|
-
"lib/page_magic/session_methods.rb",
|
55
|
-
"lib/page_magic/utils/string.rb",
|
56
|
-
"lib/page_magic/wait_methods.rb",
|
57
|
-
"lib/page_magic/watcher.rb",
|
58
|
-
"lib/page_magic/watchers.rb",
|
59
|
-
"page_magic.gemspec",
|
60
|
-
"spec/element_spec.rb",
|
61
|
-
"spec/lib/active_support/core_ext/object/to_query_test.rb",
|
62
|
-
"spec/page_magic/class_methods_spec.rb",
|
63
|
-
"spec/page_magic/driver_spec.rb",
|
64
|
-
"spec/page_magic/drivers/poltergeist_spec.rb",
|
65
|
-
"spec/page_magic/drivers/rack_test_spec.rb",
|
66
|
-
"spec/page_magic/drivers/selenium_spec.rb",
|
67
|
-
"spec/page_magic/drivers_spec.rb",
|
68
|
-
"spec/page_magic/element/locators_spec.rb",
|
69
|
-
"spec/page_magic/element/query_builder_spec.rb",
|
70
|
-
"spec/page_magic/element/query_spec.rb",
|
71
|
-
"spec/page_magic/element/selector_spec.rb",
|
72
|
-
"spec/page_magic/element_context_spec.rb",
|
73
|
-
"spec/page_magic/element_definition_builder_spec.rb",
|
74
|
-
"spec/page_magic/elements_spec.rb",
|
75
|
-
"spec/page_magic/instance_methods_spec.rb",
|
76
|
-
"spec/page_magic/matcher_spec.rb",
|
77
|
-
"spec/page_magic/session_methods_spec.rb",
|
78
|
-
"spec/page_magic/session_spec.rb",
|
79
|
-
"spec/page_magic/utils/string_spec.rb",
|
80
|
-
"spec/page_magic/wait_methods_spec.rb",
|
81
|
-
"spec/page_magic/watchers_spec.rb",
|
82
|
-
"spec/page_magic_spec.rb",
|
83
|
-
"spec/spec_helper.rb",
|
84
|
-
"spec/support/shared_contexts.rb",
|
85
|
-
"spec/support/shared_contexts/files_context.rb",
|
86
|
-
"spec/support/shared_contexts/nested_elements_html_context.rb",
|
87
|
-
"spec/support/shared_contexts/rack_application_context.rb",
|
88
|
-
"spec/support/shared_contexts/webapp_fixture_context.rb",
|
89
|
-
"spec/support/shared_examples.rb",
|
90
|
-
"spec/watcher_spec.rb"
|
91
|
-
]
|
92
|
-
s.homepage = "https://github.com/ladtech/page_magic"
|
93
|
-
s.licenses = ["ruby"]
|
94
|
-
s.required_ruby_version = Gem::Requirement.new(">= 2.1")
|
95
|
-
s.rubygems_version = "2.4.6"
|
96
|
-
s.summary = "Framework for modeling and interacting with webpages"
|
97
|
-
|
98
|
-
if s.respond_to? :specification_version then
|
99
|
-
s.specification_version = 4
|
100
|
-
|
101
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
102
|
-
s.add_runtime_dependency(%q<activesupport-inflector>, [">= 0"])
|
103
|
-
s.add_runtime_dependency(%q<capybara>, [">= 2.5"])
|
104
|
-
s.add_development_dependency(%q<github-markup>, ["~> 1.4"])
|
105
|
-
s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
|
106
|
-
s.add_development_dependency(%q<redcarpet>, ["~> 3.3"])
|
107
|
-
s.add_development_dependency(%q<rubocop>, ["~> 0.34"])
|
108
|
-
s.add_development_dependency(%q<yard>, ["~> 0.8"])
|
109
|
-
else
|
110
|
-
s.add_dependency(%q<activesupport-inflector>, [">= 0"])
|
111
|
-
s.add_dependency(%q<capybara>, [">= 2.5"])
|
112
|
-
s.add_dependency(%q<github-markup>, ["~> 1.4"])
|
113
|
-
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
114
|
-
s.add_dependency(%q<redcarpet>, ["~> 3.3"])
|
115
|
-
s.add_dependency(%q<rubocop>, ["~> 0.34"])
|
116
|
-
s.add_dependency(%q<yard>, ["~> 0.8"])
|
117
|
-
end
|
118
|
-
else
|
119
|
-
s.add_dependency(%q<activesupport-inflector>, [">= 0"])
|
120
|
-
s.add_dependency(%q<capybara>, [">= 2.5"])
|
121
|
-
s.add_dependency(%q<github-markup>, ["~> 1.4"])
|
122
|
-
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
123
|
-
s.add_dependency(%q<redcarpet>, ["~> 3.3"])
|
124
|
-
s.add_dependency(%q<rubocop>, ["~> 0.34"])
|
125
|
-
s.add_dependency(%q<yard>, ["~> 0.8"])
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
@@ -1,78 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'minitest'
|
4
|
-
Minitest.autorun
|
5
|
-
require 'active_support/core_ext/object/to_query'
|
6
|
-
|
7
|
-
class ToQueryTest < ::Minitest::Test
|
8
|
-
def test_simple_conversion
|
9
|
-
assert_query_equal 'a=10', a: 10
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_cgi_escaping
|
13
|
-
assert_query_equal 'a%3Ab=c+d', 'a:b' => 'c d'
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_nil_parameter_value
|
17
|
-
empty = Object.new
|
18
|
-
def empty.to_param
|
19
|
-
nil
|
20
|
-
end
|
21
|
-
assert_query_equal 'a=', 'a' => empty
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_nested_conversion
|
25
|
-
assert_query_equal 'person%5Blogin%5D=seckar&person%5Bname%5D=Nicholas',
|
26
|
-
person: Hash[:login, 'seckar', :name, 'Nicholas']
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_multiple_nested
|
30
|
-
assert_query_equal 'account%5Bperson%5D%5Bid%5D=20&person%5Bid%5D=10',
|
31
|
-
Hash[:account, { person: { id: 20 } }, :person, { id: 10 }]
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_array_values
|
35
|
-
assert_query_equal 'person%5Bid%5D%5B%5D=10&person%5Bid%5D%5B%5D=20',
|
36
|
-
person: { id: [10, 20] }
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_array_values_are_not_sorted
|
40
|
-
assert_query_equal 'person%5Bid%5D%5B%5D=20&person%5Bid%5D%5B%5D=10',
|
41
|
-
person: { id: [20, 10] }
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_empty_array
|
45
|
-
assert_equal 'person%5B%5D=', [].to_query('person')
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_nested_empty_hash
|
49
|
-
assert_equal '',
|
50
|
-
{}.to_query
|
51
|
-
assert_query_equal 'a=1&b%5Bc%5D=3',
|
52
|
-
a: 1, b: { c: 3, d: {} }
|
53
|
-
assert_query_equal '',
|
54
|
-
a: { b: { c: {} } }
|
55
|
-
assert_query_equal 'b%5Bc%5D=false&b%5Be%5D=&b%5Bf%5D=&p=12',
|
56
|
-
p: 12, b: { c: false, e: nil, f: '' }
|
57
|
-
assert_query_equal 'b%5Bc%5D=3&b%5Bf%5D=',
|
58
|
-
b: { c: 3, k: {}, f: '' }
|
59
|
-
assert_query_equal 'b=3',
|
60
|
-
a: [], b: 3
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_hash_with_namespace
|
64
|
-
hash = { name: 'Nakshay', nationality: 'Indian' }
|
65
|
-
assert_equal 'user%5Bname%5D=Nakshay&user%5Bnationality%5D=Indian', hash.to_query('user')
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_hash_sorted_lexicographically
|
69
|
-
hash = { type: 'human', name: 'Nakshay' }
|
70
|
-
assert_equal 'name=Nakshay&type=human', hash.to_query
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
74
|
-
|
75
|
-
def assert_query_equal(expected, actual)
|
76
|
-
assert_equal expected.split('&'), actual.to_query.split('&')
|
77
|
-
end
|
78
|
-
end
|
@@ -1,92 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe PageMagic::ClassMethods do
|
4
|
-
describe '#load' do
|
5
|
-
subject(:page_class) do
|
6
|
-
Class.new.tap do |clazz|
|
7
|
-
clazz.extend(described_class)
|
8
|
-
clazz.include(PageMagic::InstanceMethods)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
let(:page_title) { 'page title' }
|
13
|
-
let(:page_source) do
|
14
|
-
<<-HTML
|
15
|
-
<html>
|
16
|
-
<head><title>#{page_title}</title></head>
|
17
|
-
</html>
|
18
|
-
HTML
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'returns an instance using that source' do
|
22
|
-
expect(page_class.load(page_source).title).to eq(page_title)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe 'on_load' do
|
27
|
-
subject(:page_class) do
|
28
|
-
Class.new.tap do |clazz|
|
29
|
-
clazz.extend(described_class)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'when a block is not set' do
|
34
|
-
it 'returns a default block' do
|
35
|
-
expect(page_class.on_load).to be(described_class::DEFAULT_ON_LOAD)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'when a block is set' do
|
40
|
-
it 'returns that block' do
|
41
|
-
expected_block = proc {}
|
42
|
-
page_class.on_load(&expected_block)
|
43
|
-
expect(page_class.on_load).to be(expected_block)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '#url' do
|
49
|
-
subject(:page_class) do
|
50
|
-
Class.new.tap do |clazz|
|
51
|
-
clazz.extend(described_class)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'get/sets a value' do
|
56
|
-
page_class.url(:url)
|
57
|
-
expect(page_class.url).to eq(:url)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe '#visit' do
|
62
|
-
subject(:page_class) do
|
63
|
-
Class.new.tap do |clazz|
|
64
|
-
clazz.extend(described_class)
|
65
|
-
clazz.include(PageMagic::InstanceMethods)
|
66
|
-
clazz.url ''
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
let(:rack_app) do
|
71
|
-
Class.new do
|
72
|
-
def self.call(_env)
|
73
|
-
[200, {}, ['<html><head><title>page1</title></head></html>']]
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'passes all options to create an active session on the registered url' do
|
79
|
-
allow(PageMagic).to receive(:session).and_call_original
|
80
|
-
|
81
|
-
page_class.visit(application: rack_app, options: {}, browser: :rack_test)
|
82
|
-
|
83
|
-
expected_option = { application: rack_app, options: {}, browser: :rack_test, url: page_class.url }
|
84
|
-
expect(PageMagic).to have_received(:session).with(expected_option)
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'returns a session' do
|
88
|
-
session = page_class.visit(application: rack_app, options: {}, browser: :rack_test)
|
89
|
-
expect(session).to be_kind_of(PageMagic::Session)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|