conformity 0.0.9 → 0.0.10

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: e405b329514c0569897e41ff7e62a3b7d67e552b
4
- data.tar.gz: 2580059337a97a3d998c400dc0450d1b90544004
3
+ metadata.gz: 87ed4a4be55ba1f642ee28d1851df43376966ff1
4
+ data.tar.gz: ad0238e0d7ee61d9239cae38b8ada78f56a9d4a5
5
5
  SHA512:
6
- metadata.gz: bb1593b4682f3d2a468cd73b66ca56b42772cc1048921cf333e1ceab75f52acdeeb935f06bf3683608b1c9d453cb0d070a18769bb14db2f1e14fac91ba20efc1
7
- data.tar.gz: 7f522be5f5bbd0dcd1abbd2dbb95a673c923fe10fdd201dcf46005eb2327ae982a5af5b40fe75695147ce575c85c0b508db82de35ff1897e14bb06472e62808c
6
+ metadata.gz: 6a3b172262aefa4f1942bdc6d118620ab79d413524d8bc943ba9a696388b4977c83a773cf52ae11c0aeba8f33d92e669b5248737487600f13fac94832523da13
7
+ data.tar.gz: a1e062265c33673e758473b5bc0089e5b8aeb6eb6ac413f32fd26d35547c2ba63ba9ea4a98f67daca44d7cdc4773ff5429ddf4251d0e3d0e9d61846d67e2a36d
@@ -29,7 +29,7 @@ module Conformity
29
29
  end
30
30
 
31
31
  def set_all(hash)
32
- hash.each { |name, value| set(name, value) }
32
+ hash.each { |name, value| set(name, value) unless find(name).nil? }
33
33
  end
34
34
  end
35
35
  end
@@ -1,3 +1,3 @@
1
1
  module Conformity
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
data/spec/actions_spec.rb CHANGED
@@ -18,6 +18,109 @@ describe Conformity::Actions do
18
18
  end
19
19
  end
20
20
 
21
+ describe "actions" do
22
+ before :each do
23
+ @actions = Actions.new(@fields)
24
+ @actions.visit "/form"
25
+ end
26
+
27
+ describe "#click_on" do
28
+ it "clicks by text" do
29
+ @actions.click_on "click me"
30
+ expect(page).to include("click success")
31
+ end
32
+
33
+ it "clicks by css" do
34
+ @actions.click_on "#click_me"
35
+ expect(page).to include("click success")
36
+ end
37
+ end
38
+
39
+ describe "#fill_in" do
40
+ it "fills in by text" do
41
+ @actions.fill_in "name", with: "Jane"
42
+ @actions.click_on "Submit"
43
+ expect(page).to include("Jane")
44
+ end
45
+
46
+ it "fills in by css" do
47
+ @actions.fill_in "#name", with: "Jane"
48
+ @actions.click_on "Submit"
49
+ expect(page).to include("Jane")
50
+ end
51
+ end
52
+
53
+ describe "#choose" do
54
+ it "chooses by text" do
55
+ @actions.choose "female"
56
+ @actions.click_on "Submit"
57
+ expect(page).to include("female")
58
+ end
59
+
60
+ it "chooses by css" do
61
+ @actions.choose "#female"
62
+ @actions.click_on "Submit"
63
+ expect(page).to include("female")
64
+ end
65
+ end
66
+
67
+ describe "#check" do
68
+ it "checks by text" do
69
+ @actions.check "chess"
70
+ @actions.click_on "Submit"
71
+ expect(page).to include("chess")
72
+ end
73
+
74
+ it "checks by css" do
75
+ @actions.check "#chess"
76
+ @actions.click_on "Submit"
77
+ expect(page).to include("chess")
78
+ end
79
+ end
80
+
81
+ describe "#uncheck" do
82
+ it "unchecks by text" do
83
+ @actions.uncheck "checkers"
84
+ @actions.click_on "Submit"
85
+ expect(page).to_not include("checkers")
86
+ end
87
+
88
+ it "unchecks by css" do
89
+ @actions.uncheck "#checkers"
90
+ @actions.click_on "Submit"
91
+ expect(page).to_not include("checkers")
92
+ end
93
+ end
94
+
95
+ describe "#select" do
96
+ it "selects by text" do
97
+ @actions.select("Mr")
98
+ @actions.click_on "Submit"
99
+ expect(page).to include("Mr")
100
+ end
101
+
102
+ it "selects by css" do
103
+ @actions.select("#mr")
104
+ @actions.click_on "Submit"
105
+ expect(page).to include("Mr")
106
+ end
107
+ end
108
+
109
+ describe "#unselect" do
110
+ it "unselects by text" do
111
+ @actions.unselect("BMW")
112
+ @actions.click_on "Submit"
113
+ expect(page).to_not include("BMW")
114
+ end
115
+
116
+ it "unselects by css" do
117
+ @actions.unselect("option[value=bmw]")
118
+ @actions.click_on "Submit"
119
+ expect(page).to_not include("BMW")
120
+ end
121
+ end
122
+ end
123
+
21
124
  describe "#method_missing" do
22
125
  it "delegates visit to session" do
23
126
  expect(@session).to receive(:visit).with("/")
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,16 @@
1
1
  lib = File.expand_path('../lib', __FILE__)
2
+ spec = File.expand_path('../spec', __FILE__)
2
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ $LOAD_PATH.unshift(spec) unless $LOAD_PATH.include?(spec)
5
+
3
6
  require 'conformity'
7
+ require 'test_app'
8
+ require 'nokogiri'
9
+
10
+
11
+ Capybara.run_server = true
12
+ Capybara.app = TestApp
13
+
14
+ def page(session = Capybara.current_session)
15
+ Nokogiri::HTML(session.html).xpath("//pre[@id='result']").first.inner_html.strip
16
+ end
data/spec/test_app.rb ADDED
@@ -0,0 +1,22 @@
1
+ require "sinatra/base"
2
+
3
+
4
+ class TestApp < Sinatra::Base
5
+ set :root, File.dirname(__FILE__)
6
+
7
+ get "/form" do
8
+ erb(:form)
9
+ end
10
+
11
+ post "/form" do
12
+ "<pre id='result'>#{params.values.join(", ")}</pre>"
13
+ end
14
+
15
+ get "/clicked" do
16
+ "<pre id='result'>click success</pre"
17
+ end
18
+ end
19
+
20
+ if __FILE__ == $0
21
+ Rack::Handler::WEBrick.run TestApp, :Port => 8070
22
+ end
@@ -0,0 +1,39 @@
1
+ <a id="click_me" href="/clicked">click me</a>
2
+
3
+
4
+ <form action="/form" method="post">
5
+
6
+ <!-- fill_in -->
7
+ <input type="text" name="name" id="name"/>
8
+
9
+
10
+ <!-- choose -->
11
+ <input type="radio" name="sex" id="female" value="female">Female</input>
12
+ <input type="radio" name="sex" id="male" value="male">Male</input>
13
+ <input type="radio" name="sex" id="other" value="other">Other</input>
14
+
15
+
16
+ <!-- check -->
17
+ <input type="checkbox" id="chess" name="checkthis" value="chess">
18
+ <!-- uncheck -->
19
+ <input type="checkbox" id="checkers" name="uncheckthis" value="checkers" checked="true">
20
+
21
+
22
+ <!-- select -->
23
+ <select name="[title]" id="title">
24
+ <option id="ms" value="Ms">Ms</option>
25
+ <option id="mr" value="Mr">Mr</option>
26
+ <option id="none" value="none">none</option>
27
+ </select>
28
+
29
+
30
+ <!-- unselect -->
31
+ <select name="[car]" id="car" multiple>
32
+ <option value="bmw" selected="true">BMW</option>
33
+ <option value="audi">Audi</option>
34
+ <option value="mercedes">Mercedes</option>
35
+ </select>
36
+
37
+
38
+ <button type="submit">Submit</button>
39
+ </form>
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.9
4
+ version: 0.0.10
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-14 00:00:00.000000000 Z
11
+ date: 2014-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -78,6 +78,8 @@ files:
78
78
  - spec/form_spec.rb
79
79
  - spec/spec_helper.rb
80
80
  - spec/success_conditions_spec.rb
81
+ - spec/test_app.rb
82
+ - spec/views/form.erb
81
83
  homepage: https://github.com/nhjk/conformity
82
84
  licenses:
83
85
  - MIT
@@ -109,3 +111,5 @@ test_files:
109
111
  - spec/form_spec.rb
110
112
  - spec/spec_helper.rb
111
113
  - spec/success_conditions_spec.rb
114
+ - spec/test_app.rb
115
+ - spec/views/form.erb