conformity 0.0.7 → 0.0.8
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 -3
- data/lib/conformity/actions.rb +43 -5
- data/lib/conformity/fields.rb +8 -4
- data/lib/conformity/form.rb +2 -2
- data/lib/conformity/version.rb +1 -1
- data/spec/actions_spec.rb +6 -14
- data/spec/fields_spec.rb +18 -8
- data/spec/form_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b8455307bec73a30aafcac8703555a260a59683
|
4
|
+
data.tar.gz: 740f87bd8c214605fdd86d611d0c24306704a2a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a957db00a62c401b20343edfd5dd308f51fe518c600a4f866aea68ff7a7c7725507b574b2f9fab3c068f46b09231c46cd9bdc6ccf7344d88cea84eab11f7537
|
7
|
+
data.tar.gz: 571371f18eb5df39db3f92575ff8b9fe775275967f3b3529432ec9337b0b53602fb65dfe17d21709cedc098eefe0dc73657930cae736182de3a9d446eaafddc5
|
data/README.md
CHANGED
@@ -36,9 +36,9 @@ form.field_names
|
|
36
36
|
# => [:query]
|
37
37
|
|
38
38
|
# returns Capybara::Session, can call #html etc. on it
|
39
|
-
form.fill_with('news') # perform google search for 'news'
|
40
|
-
form.fill_with('what is the third planet from the sun')
|
41
|
-
form.fill_with('alternatives to gmail')
|
39
|
+
form.fill_with(query: 'news') # perform google search for 'news'
|
40
|
+
form.fill_with(query: 'what is the third planet from the sun')
|
41
|
+
form.fill_with(query: 'alternatives to gmail')
|
42
42
|
|
43
43
|
# check if the last form submission succeeded (if success conditions were set)
|
44
44
|
form.success?
|
data/lib/conformity/actions.rb
CHANGED
@@ -14,6 +14,49 @@ module Conformity
|
|
14
14
|
fields.value(name)
|
15
15
|
end
|
16
16
|
|
17
|
+
def click_on(locator, options={})
|
18
|
+
session.find(locator, options).click
|
19
|
+
screenshot(name) if Conformity.log_screenshots
|
20
|
+
end
|
21
|
+
alias_method :click_link_or_button, :click_on
|
22
|
+
alias_method :click_link, :click_on
|
23
|
+
alias_method :click_button, :click_on
|
24
|
+
|
25
|
+
def fill_in(locator, options={})
|
26
|
+
raise "Must pass a hash containing 'with'" if not options.is_a?(Hash) or not options.has_key?(:with)
|
27
|
+
with = options.delete(:with)
|
28
|
+
fill_options = options.delete(:fill_options)
|
29
|
+
session.find(locator, options).set(with, fill_options)
|
30
|
+
screenshot(:fill_in) if Conformity.log_screenshots
|
31
|
+
end
|
32
|
+
|
33
|
+
def choose(locator, options={})
|
34
|
+
session.find(locator, options).set(true)
|
35
|
+
screenshot(:choose) if Conformity.log_screenshots
|
36
|
+
end
|
37
|
+
|
38
|
+
def check(locator, options={})
|
39
|
+
session.find(locator, options).set(true)
|
40
|
+
screenshot(:check) if Conformity.log_screenshots
|
41
|
+
end
|
42
|
+
|
43
|
+
def uncheck(locator, options={})
|
44
|
+
session.find(locator, options).set(false)
|
45
|
+
screenshot(:uncheck) if Conformity.log_screenshots
|
46
|
+
end
|
47
|
+
|
48
|
+
def select(value, options={})
|
49
|
+
options.delete(:from)
|
50
|
+
session.find(value, options).select_option
|
51
|
+
screenshot(:select) if Conformity.log_screenshots
|
52
|
+
end
|
53
|
+
|
54
|
+
def unselect(value, options={})
|
55
|
+
options.delete(:from)
|
56
|
+
session.find(value, options).unselect_option
|
57
|
+
screenshot(:unselect) if Conformity.log_screenshots
|
58
|
+
end
|
59
|
+
|
17
60
|
def method_missing(name, *args, &block)
|
18
61
|
if ACTIONS.include?(name)
|
19
62
|
session.send(name, *args, &block)
|
@@ -25,11 +68,6 @@ module Conformity
|
|
25
68
|
end
|
26
69
|
end
|
27
70
|
|
28
|
-
# so Kernel#select isn't called
|
29
|
-
def select(*args, &block)
|
30
|
-
session.send(:select, *args, &block)
|
31
|
-
end
|
32
|
-
|
33
71
|
def screenshot(name)
|
34
72
|
file_name = "#{Time.now.to_i}_#{name}.png"
|
35
73
|
full_path = Conformity.screenshots_folder + "/" + file_name
|
data/lib/conformity/fields.rb
CHANGED
@@ -16,16 +16,20 @@ module Conformity
|
|
16
16
|
fields.map { |field| field.name }
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
fields.
|
19
|
+
def find(name)
|
20
|
+
fields.select { |field| field.name == name }.first
|
21
21
|
end
|
22
22
|
|
23
23
|
def value(name)
|
24
24
|
find(name).value
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
|
27
|
+
def set(name, value)
|
28
|
+
find(name).value = value
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_all(hash)
|
32
|
+
hash.each { |name, value| set(name, value) }
|
29
33
|
end
|
30
34
|
end
|
31
35
|
end
|
data/lib/conformity/form.rb
CHANGED
data/lib/conformity/version.rb
CHANGED
data/spec/actions_spec.rb
CHANGED
@@ -19,26 +19,18 @@ describe Conformity::Actions do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "#method_missing" do
|
22
|
-
it "delegates
|
22
|
+
it "delegates visit to session" do
|
23
23
|
expect(@session).to receive(:visit).with("/")
|
24
24
|
@actions.visit('/')
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
28
|
-
expect
|
27
|
+
it "delegates find to session" do
|
28
|
+
expect(@session).to receive(:find).with("#id")
|
29
|
+
@actions.find("#id")
|
29
30
|
end
|
30
|
-
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
expect(@session).to receive(:select)
|
35
|
-
@actions.select('Yes')
|
36
|
-
end
|
37
|
-
|
38
|
-
it "is not called on Kernel" do
|
39
|
-
skip "not sure how to test"
|
40
|
-
expect(Kernel).to_not receive(:select)
|
41
|
-
@actions.select('Yes')
|
32
|
+
it "ignores success conditions" do
|
33
|
+
expect { @actions.has_status_code?; @actions.has_content? }.to_not raise_error
|
42
34
|
end
|
43
35
|
end
|
44
36
|
|
data/spec/fields_spec.rb
CHANGED
@@ -40,16 +40,26 @@ describe Conformity::Fields do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
describe "#
|
44
|
-
it "sets the value of
|
45
|
-
|
46
|
-
|
43
|
+
describe "#set" do
|
44
|
+
it "sets the value of field name" do
|
45
|
+
field = double("Field", name: "number")
|
46
|
+
@fields.add_field(field)
|
47
|
+
expect(field).to receive(:value=).with("867-5309")
|
48
|
+
@fields.set("number", "867-5309")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#set_all" do
|
53
|
+
it "sets the value of all fields" do
|
54
|
+
name = double("Field", name: "name")
|
55
|
+
number = double("Field", name: "number")
|
56
|
+
@fields.add_field(name)
|
57
|
+
@fields.add_field(number)
|
47
58
|
|
48
|
-
|
49
|
-
expect(
|
50
|
-
expect(field_b).to receive(:value=).with('2')
|
59
|
+
expect(name).to receive(:value=).with("Jenny")
|
60
|
+
expect(number).to receive(:value=).with("867-5309")
|
51
61
|
|
52
|
-
@fields.
|
62
|
+
@fields.set_all("name" => "Jenny", "number" => "867-5309")
|
53
63
|
end
|
54
64
|
end
|
55
65
|
end
|
data/spec/form_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conformity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikias Kalpaxis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|