capybara-mechanize 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -57,12 +57,30 @@ class Capybara::Driver::Mechanize < Capybara::Driver::RackTest
57
57
 
58
58
  def post(url, params = {}, headers = {})
59
59
  if remote?(url)
60
- process_remote_request(:post, url, params, headers)
60
+ process_remote_request(:post, url, post_data(params), headers)
61
61
  else
62
62
  register_local_request
63
63
  super
64
64
  end
65
65
  end
66
+
67
+ def post_data(params)
68
+ params.inject({}) do |memo, param|
69
+ case param
70
+ when Hash
71
+ param.each {|attribute, value| memo[attribute] = value }
72
+ memo
73
+ when Array
74
+ case param.last
75
+ when Hash
76
+ param.last.each {|attribute, value| memo["#{param.first}[#{attribute}]"] = value }
77
+ else
78
+ memo[param.first] = param.last
79
+ end
80
+ memo
81
+ end
82
+ end
83
+ end
66
84
 
67
85
  def put(url, params = {}, headers = {})
68
86
  if remote?(url)
@@ -150,7 +168,10 @@ class Capybara::Driver::Mechanize < Capybara::Driver::RackTest
150
168
  end
151
169
 
152
170
  def headers
153
- page.response
171
+ # Hax the content-type contains utf8, so Capybara specs are failing, need to ask mailinglist
172
+ headers = page.response
173
+ headers["content-type"].gsub!(';charset=utf-8', '') if headers["content-type"]
174
+ headers
154
175
  end
155
176
 
156
177
  def status
@@ -163,4 +184,4 @@ class Capybara::Driver::Mechanize < Capybara::Driver::RackTest
163
184
 
164
185
  end
165
186
 
166
- end
187
+ end
@@ -25,6 +25,20 @@ describe Capybara::Driver::Mechanize do
25
25
  @driver.body.should == %{<pre id="results">--- success\n</pre>}
26
26
  end
27
27
 
28
+ it "should pass arguments through to a post request" do
29
+ @driver.post("#{REMOTE_TEST_URL}/form", {:form => "success"})
30
+ @driver.body.should == %{<pre id="results">--- success\n</pre>}
31
+ end
32
+
33
+ context "for a post request" do
34
+
35
+ it "should transform nested map in post data" do
36
+ @driver.post("#{REMOTE_TEST_URL}/form", {:form => {:key => "value"}})
37
+ @driver.body.should == %{<pre id="results">--- \nkey: value\n</pre>}
38
+ end
39
+
40
+ end
41
+
28
42
  it_should_behave_like "driver"
29
43
  it_should_behave_like "driver with header support"
30
44
  it_should_behave_like "driver with status code support"
@@ -32,4 +46,4 @@ describe Capybara::Driver::Mechanize do
32
46
  it_should_behave_like "driver with infinite redirect detection"
33
47
  end
34
48
 
35
- end
49
+ end
@@ -35,7 +35,7 @@ describe Capybara::Session do
35
35
  end
36
36
  end
37
37
 
38
- # Pending: Still 90 (and before the update of capybara to 0.4.0 16) failing tests here (result is 702 examples, 90 failures, instead of 381 examples)
38
+ # Pending: Still 18 failing tests here (result is 705 examples, 18 failures, instead of 384 examples)
39
39
  # it_should_behave_like "session"
40
40
 
41
41
  it_should_behave_like "session without javascript support"
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-mechanize
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 27
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 2
8
- - 5
9
- version: 0.2.5
9
+ - 6
10
+ version: 0.2.6
10
11
  platform: ruby
11
12
  authors:
12
13
  - Jeroen van Dijk
@@ -18,35 +19,37 @@ date: 2010-09-27 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: mechanize
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
23
  none: false
25
24
  requirements:
26
25
  - - ~>
27
26
  - !ruby/object:Gem::Version
27
+ hash: 23
28
28
  segments:
29
29
  - 1
30
30
  - 0
31
31
  - 0
32
32
  version: 1.0.0
33
33
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: capybara
34
+ requirement: *id001
35
+ name: mechanize
37
36
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
37
+ - !ruby/object:Gem::Dependency
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
+ hash: 15
43
44
  segments:
44
45
  - 0
45
46
  - 4
46
47
  - 0
47
48
  version: 0.4.0
48
49
  type: :runtime
49
- version_requirements: *id002
50
+ requirement: *id002
51
+ name: capybara
52
+ prerelease: false
50
53
  description: RackTest driver for Capybara, but with remote request support thanks to mechanize
51
54
  email: jeroen@jeevidee.nl
52
55
  executables: []
@@ -80,6 +83,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
83
  requirements:
81
84
  - - ">="
82
85
  - !ruby/object:Gem::Version
86
+ hash: 3
83
87
  segments:
84
88
  - 0
85
89
  version: "0"
@@ -88,13 +92,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
92
  requirements:
89
93
  - - ">="
90
94
  - !ruby/object:Gem::Version
95
+ hash: 3
91
96
  segments:
92
97
  - 0
93
98
  version: "0"
94
99
  requirements: []
95
100
 
96
101
  rubyforge_project:
97
- rubygems_version: 1.3.7
102
+ rubygems_version: 1.4.1
98
103
  signing_key:
99
104
  specification_version: 3
100
105
  summary: RackTest driver for Capybara with remote request support