akephalos2 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -36,18 +36,22 @@ gem 'akephalos', :git => 'git://github.com/Nerian/akephalos.git'
36
36
  ```
37
37
 
38
38
 
39
-
40
39
  # Development
41
40
 
41
+ <img src="https://secure.travis-ci.org/Nerian/akephalos2.png?branch=master&amp;.png">
42
+
42
43
  ``` bash
43
44
  git clone https://github.com/Nerian/akephalos2
44
45
  git submodule update --init
45
- # optional
46
- cp .rvmrc.example .rvmrc
47
46
  ```
48
47
 
49
48
  The last line will grab the HTMLUnit jar files from [https://github.com/Nerian/html-unit-vendor](https://github.com/Nerian/html-unit-vendor)
50
49
 
50
+ Also, we have a .rvmrc file already cooked:
51
+
52
+ ``` bash
53
+ cp .rvmrc.example .rvmrc
54
+ ```
51
55
 
52
56
  ## Setup
53
57
 
@@ -82,7 +86,33 @@ describe "Home Page" do
82
86
  end
83
87
  end
84
88
  ```
85
-
89
+
90
+ Capybara allows you to perform your action on a context, for example inside a div or a frame. With Akephalos you can select the frame either by id or by index.
91
+
92
+ ``` html
93
+ <body>
94
+ <p id="test">Test</p>
95
+ <iframe id="first" src="/one_text"></iframe>
96
+ <p id="test2">Test2</p>
97
+ <iframe class="second" src="/two_text"></iframe>
98
+ <p id="test3">Test3</p>
99
+ <iframe id="third" src="/three_text"></iframe>
100
+ </body>
101
+ ```
102
+
103
+ You can operate within the context of iframe `test2` with any of these calls:
104
+
105
+ ``` ruby
106
+ # By ID
107
+ within_frame("test2") do
108
+ ....
109
+ end
110
+
111
+ # By index
112
+ within_frame(1) do
113
+ ....
114
+ end
115
+ ```
86
116
 
87
117
  ## Configuration
88
118
 
data/bin/akephalos CHANGED
@@ -58,8 +58,7 @@ when options[:use_htmlunit_snapshot]
58
58
  $stdout.puts "="*40
59
59
  $stdout.puts "The latest HtmlUnit snapshot has been extracted to vendor/htmlunit!"
60
60
  when options[:interactive]
61
- $:.unshift('vendor', lib, src)
62
- require 'rubygems'
61
+ $LOAD_PATH.unshift('vendor', lib, src)
63
62
  require 'akephalos'
64
63
  require 'akephalos/console'
65
64
  Akephalos::Console.start
@@ -70,11 +69,10 @@ else
70
69
  end
71
70
 
72
71
  if RUBY_PLATFORM == "java"
73
- $:.unshift("vendor", lib, src)
72
+ $LOAD_PATH.unshift("vendor", lib, src)
74
73
  require 'akephalos/server'
75
74
  Akephalos::Server.start!(port)
76
75
  else
77
- require 'rubygems'
78
76
  require 'jruby-jars'
79
77
 
80
78
  jruby = JRubyJars.core_jar_path
@@ -235,11 +235,12 @@ class Capybara::Driver::Akephalos < Capybara::Driver::Base
235
235
 
236
236
  # Execute the given block within the context of a specified frame.
237
237
  #
238
- # @param [String] frame_id the frame's id
238
+ # @param [String] frame_id the frame's id or index
239
239
  # @raise [Capybara::ElementNotFound] if the frame is not found
240
- def within_frame(frame_id, &block)
241
- unless page.within_frame(frame_id, &block)
242
- raise Capybara::ElementNotFound, "Unable to find frame with id '#{frame_id}'"
240
+ def within_frame(frame_id_or_index, &block)
241
+ result = page.within_frame(frame_id_or_index, &block)
242
+ unless page.within_frame(frame_id_or_index, &block)
243
+ raise Capybara::ElementNotFound, "Unable to find frame with id '#{frame_id_or_index}'"
243
244
  end
244
245
  end
245
246
 
@@ -14,7 +14,7 @@ module Akephalos
14
14
  # response.
15
15
  #
16
16
  # @param [WebRequest] request the pending HTTP request
17
- # @return [WebResponseImpl] when the request matches a defined filter
17
+ # @return [WebResponse] when the request matches a defined filter
18
18
  # @return [nil] when no filters match the request
19
19
  def filter(request)
20
20
  if filter = find_filter(request)
@@ -28,7 +28,7 @@ module Akephalos
28
28
  HTTP_STATUS_CODES.fetch(filter[:status], "Unknown"),
29
29
  headers
30
30
  )
31
- HtmlUnit::WebResponseImpl.new(response, request, Time.now - start_time)
31
+ HtmlUnit::WebResponse.new(response, request, Time.now - start_time)
32
32
  end
33
33
  end
34
34
 
@@ -49,7 +49,7 @@ module Akephalos
49
49
  #
50
50
  # @api htmlunit
51
51
  # @param [WebRequest] request the pending HTTP request
52
- # @return [WebResponseImpl]
52
+ # @return [WebResponse]
53
53
  def getResponse(request)
54
54
  filter(request) || super
55
55
  end
@@ -1,9 +1,9 @@
1
1
  require "pathname"
2
2
  require "java"
3
3
 
4
- dependency_directory = $:.detect { |path| Dir[File.join(path, 'html-unit/htmlunit-*.jar')].any? }
4
+ dependency_directory = $LOAD_PATH.detect { |path| Dir[File.join(path, 'html-unit/htmlunit-*.jar')].any? }
5
5
 
6
- raise "Could not find htmlunit/htmlunit-VERSION.jar in load path:\n [ #{$:.join(",\n ")}\n ]" unless dependency_directory
6
+ raise "Could not find html-unit/htmlunit-VERSION.jar in load path:\n [ #{$LOAD_PATH.join(",\n ")}\n ]" unless dependency_directory
7
7
 
8
8
  Dir[File.join(dependency_directory, "html-unit/*.jar")].each do |jar|
9
9
  require jar
@@ -23,7 +23,7 @@ module HtmlUnit
23
23
  java_import "com.gargoylesoftware.htmlunit.SilentCssErrorHandler"
24
24
  java_import "com.gargoylesoftware.htmlunit.WebClient"
25
25
  java_import "com.gargoylesoftware.htmlunit.WebResponseData"
26
- java_import "com.gargoylesoftware.htmlunit.WebResponseImpl"
26
+ java_import "com.gargoylesoftware.htmlunit.WebResponse"
27
27
 
28
28
  # Container module for com.gargoylesoftware.htmlunit.util namespace.
29
29
  module Util
@@ -61,7 +61,7 @@ module Akephalos
61
61
 
62
62
  # @return [String] the current page's URL.
63
63
  def current_url
64
- current_frame.getWebResponse.getRequestSettings.getUrl.toString
64
+ current_frame.getWebResponse.getWebRequest.getUrl.toString
65
65
  end
66
66
 
67
67
  # Execute JavaScript against the current page, discarding any return value.
@@ -99,15 +99,20 @@ module Akephalos
99
99
  @current_frame || @_page
100
100
  end
101
101
 
102
- # @param [String] id the frame's id
102
+ # @param [String/Integer] id the frame's id or index
103
103
  # @return [HtmlUnit::HtmlPage] the specified frame
104
104
  # @return [nil] if no frame is found
105
- def find_frame(id)
106
- frame = @_page.getFrames.find do |frame|
107
- frame.getFrameElement.getAttribute("id") == id
108
- end
109
- frame.getEnclosedPage if frame
105
+ def find_frame(id_or_index)
106
+ if id_or_index.is_a? Fixnum
107
+ frame = @_page.getFrames.get(id_or_index) rescue nil
108
+ else
109
+ frame = @_page.getFrames.find do |frame|
110
+ frame.getFrameElement.getAttribute("id") == id_or_index
111
+ end
112
+ end
113
+ frame.getEnclosedPage if frame
110
114
  end
115
+
111
116
  end
112
117
 
113
118
  end
@@ -1,3 +1,3 @@
1
1
  module Akephalos #:nodoc
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akephalos2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-03 00:00:00.000000000 Z
12
+ date: 2011-10-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capybara
16
- requirement: &70315413792500 !ruby/object:Gem::Requirement
16
+ requirement: &70180671835000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,21 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70315413792500
24
+ version_requirements: *70180671835000
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &70180671834260 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70180671834260
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: jruby-jars
27
- requirement: &70315413791980 !ruby/object:Gem::Requirement
38
+ requirement: &70180671833360 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
41
  - - ! '>='
@@ -32,10 +43,10 @@ dependencies:
32
43
  version: '0'
33
44
  type: :runtime
34
45
  prerelease: false
35
- version_requirements: *70315413791980
46
+ version_requirements: *70180671833360
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: sinatra
38
- requirement: &70315413791400 !ruby/object:Gem::Requirement
49
+ requirement: &70180671832520 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ! '>='
@@ -43,10 +54,10 @@ dependencies:
43
54
  version: '0'
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *70315413791400
57
+ version_requirements: *70180671832520
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: rspec
49
- requirement: &70315413790820 !ruby/object:Gem::Requirement
60
+ requirement: &70180671830980 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ! '>='
@@ -54,7 +65,7 @@ dependencies:
54
65
  version: '0'
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *70315413790820
68
+ version_requirements: *70180671830980
58
69
  description: Headless Browser for Integration Testing with Capybara
59
70
  email: bj.schaefer@gmail.com
60
71
  executables:
@@ -82,10 +93,10 @@ files:
82
93
  - vendor/html-unit/commons-codec-1.4.jar
83
94
  - vendor/html-unit/commons-collections-3.2.1.jar
84
95
  - vendor/html-unit/commons-io-2.0.1.jar
85
- - vendor/html-unit/commons-lang-2.6.jar
96
+ - vendor/html-unit/commons-lang3-3.0.1.jar
86
97
  - vendor/html-unit/commons-logging-1.1.1.jar
87
- - vendor/html-unit/cssparser-0.9.5.jar
88
- - vendor/html-unit/htmlunit-2.9.jar
98
+ - vendor/html-unit/cssparser-0.9.6-20110829.205617-3.jar
99
+ - vendor/html-unit/htmlunit-2.10-SNAPSHOT.jar
89
100
  - vendor/html-unit/htmlunit-core-js-2.9.jar
90
101
  - vendor/html-unit/httpclient-4.1.2.jar
91
102
  - vendor/html-unit/httpcore-4.1.2.jar
@@ -117,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
128
  requirements:
118
129
  - - ! '>='
119
130
  - !ruby/object:Gem::Version
120
- version: 1.3.6
131
+ version: '0'
121
132
  requirements: []
122
133
  rubyforge_project: akephalos
123
134
  rubygems_version: 1.8.10
Binary file
Binary file