page_magic 0.8.9 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/page_magic/browser.rb +7 -5
- data/lib/page_magic/{page_element.rb → element.rb} +2 -7
- data/lib/page_magic/element_context.rb +1 -1
- data/lib/page_magic/{page_elements.rb → elements.rb} +6 -8
- data/lib/page_magic/{page_section.rb → section.rb} +2 -2
- data/lib/page_magic/session.rb +11 -3
- data/lib/page_magic.rb +15 -21
- data/page_magic.gemspec +9 -11
- data/spec/browser_spec.rb +13 -9
- data/spec/{page_element_spec.rb → element_spec.rb} +10 -10
- data/spec/{page_elements_spec.rb → elements_spec.rb} +9 -9
- data/spec/member_methods_spec.rb +3 -3
- data/spec/page_magic_spec.rb +12 -24
- data/spec/{page_section_spec.rb → section_spec.rb} +4 -4
- data/spec/session_spec.rb +6 -1
- data/spec/spec_helper.rb +1 -1
- metadata +38 -20
- data/lib/page_magic/wait.rb +0 -7
- data/spec/helpers.rb +0 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.9.4
|
data/lib/page_magic/browser.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
module PageMagic
|
2
2
|
module Browser
|
3
3
|
class << self
|
4
|
-
|
5
|
-
|
4
|
+
def session
|
5
|
+
@session ||= PageMagic.session(default)
|
6
|
+
end
|
6
7
|
|
7
|
-
def
|
8
|
-
@
|
8
|
+
def default default=nil
|
9
|
+
return (@default || :firefox) unless default
|
10
|
+
@default = default
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
12
14
|
def browser
|
13
|
-
Browser.session
|
15
|
+
Browser.session
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
@@ -5,18 +5,13 @@ module PageMagic
|
|
5
5
|
|
6
6
|
end
|
7
7
|
|
8
|
-
class
|
8
|
+
class Element
|
9
9
|
|
10
10
|
class MissingLocatorOrSelector < Exception
|
11
11
|
end
|
12
12
|
|
13
|
-
include PageElements
|
14
13
|
include AjaxSupport
|
15
14
|
|
16
|
-
module ::Watir
|
17
|
-
SelectList = Select
|
18
|
-
end
|
19
|
-
|
20
15
|
attr_reader :type, :name, :selector, :before_hook, :after_hook, :browser_element, :locator
|
21
16
|
|
22
17
|
class << self
|
@@ -88,7 +83,7 @@ module PageMagic
|
|
88
83
|
|
89
84
|
|
90
85
|
def == page_element
|
91
|
-
page_element.is_a?(
|
86
|
+
page_element.is_a?(Element) &&
|
92
87
|
@type == page_element.type &&
|
93
88
|
@name == page_element.name &&
|
94
89
|
@selector == page_element.selector
|
@@ -37,7 +37,7 @@ module PageMagic
|
|
37
37
|
|
38
38
|
result = element_locator.locate
|
39
39
|
|
40
|
-
return element_locator if element_locator.class.is_a?
|
40
|
+
return element_locator if element_locator.class.is_a? Section
|
41
41
|
|
42
42
|
[:set, :select_option, :unselect_option, :click].each do |action_method|
|
43
43
|
apply_hooks(page_element: result,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module PageMagic
|
2
|
-
module
|
2
|
+
module Elements
|
3
3
|
class InvalidElementNameException < Exception
|
4
4
|
end
|
5
5
|
|
@@ -17,7 +17,6 @@ module PageMagic
|
|
17
17
|
def element_definitions
|
18
18
|
self.class.element_definitions
|
19
19
|
end
|
20
|
-
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
@@ -26,7 +25,6 @@ module PageMagic
|
|
26
25
|
end
|
27
26
|
|
28
27
|
|
29
|
-
|
30
28
|
def elements(browser_element, *args)
|
31
29
|
element_definitions.values.collect { |definition| definition.call(browser_element, *args) }
|
32
30
|
end
|
@@ -35,16 +33,16 @@ module PageMagic
|
|
35
33
|
!element_definitions.empty?
|
36
34
|
end
|
37
35
|
|
38
|
-
|
39
|
-
|
36
|
+
TYPES = [:element, :text_field, :button, :link, :checkbox, :select_list, :radios, :textarea]
|
37
|
+
TYPES.each do |field|
|
40
38
|
define_method field do |*args, &block|
|
41
39
|
name, selector = args
|
42
40
|
add_element_definition(name) do |browser_element|
|
43
41
|
case selector
|
44
42
|
when Hash, NilClass
|
45
|
-
|
43
|
+
Element.new(name, browser_element, field, selector, &block)
|
46
44
|
else
|
47
|
-
|
45
|
+
Element.new(name, selector, field, nil, &block)
|
48
46
|
end
|
49
47
|
|
50
48
|
end
|
@@ -58,7 +56,7 @@ module PageMagic
|
|
58
56
|
|
59
57
|
add_element_definition(name) do |parent_browser_element, *args_for_section|
|
60
58
|
page_section = Class.new do
|
61
|
-
extend PageMagic::
|
59
|
+
extend PageMagic::Section
|
62
60
|
end
|
63
61
|
|
64
62
|
page_section.parent_browser_element = parent_browser_element.browser_element
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module PageMagic
|
2
|
-
module
|
2
|
+
module Section
|
3
3
|
|
4
4
|
module Location
|
5
5
|
def locate_in browser_element, selector
|
@@ -20,7 +20,7 @@ module PageMagic
|
|
20
20
|
|
21
21
|
class << self
|
22
22
|
def extended clazz
|
23
|
-
clazz.extend(
|
23
|
+
clazz.extend(Elements)
|
24
24
|
clazz.class_eval do
|
25
25
|
attr_reader :name, :selector
|
26
26
|
class << self
|
data/lib/page_magic/session.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
+
require 'wait'
|
1
2
|
module PageMagic
|
2
3
|
class Session
|
3
4
|
attr_reader :browser
|
4
5
|
attr_accessor :current_page
|
5
6
|
|
6
|
-
include WaitUntil
|
7
|
-
|
8
7
|
def initialize browser
|
9
8
|
@browser = browser
|
10
9
|
end
|
@@ -15,10 +14,19 @@ module PageMagic
|
|
15
14
|
self
|
16
15
|
end
|
17
16
|
|
17
|
+
def current_url
|
18
|
+
@browser.current_url
|
19
|
+
end
|
20
|
+
|
18
21
|
def move_to page_class
|
19
22
|
page_class = eval(page_class) if page_class.is_a?(String)
|
20
23
|
@current_page = page_class.new self
|
21
|
-
|
24
|
+
wait_until { browser.current_url == page_class.url }
|
25
|
+
end
|
26
|
+
|
27
|
+
def wait_until &block
|
28
|
+
@wait ||= Wait.new
|
29
|
+
@wait.until &block
|
22
30
|
end
|
23
31
|
|
24
32
|
def method_missing name, *args, &block
|
data/lib/page_magic.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}")
|
2
2
|
require 'capybara'
|
3
|
-
require 'wait'
|
4
|
-
require 'page_magic/wait'
|
5
3
|
require 'page_magic/browser'
|
6
4
|
require 'page_magic/session'
|
7
5
|
require 'page_magic/ajax_support'
|
8
|
-
require 'page_magic/
|
6
|
+
require 'page_magic/elements'
|
9
7
|
require 'page_magic/element_context'
|
10
|
-
require 'page_magic/
|
8
|
+
require 'page_magic/element'
|
11
9
|
require 'page_magic/page_magic'
|
12
|
-
require 'page_magic/
|
10
|
+
require 'page_magic/section'
|
13
11
|
|
14
12
|
module PageMagic
|
15
13
|
class << self
|
@@ -45,29 +43,25 @@ module PageMagic
|
|
45
43
|
end
|
46
44
|
|
47
45
|
def included clazz
|
48
|
-
clazz.extend
|
46
|
+
clazz.extend Elements
|
49
47
|
pages << clazz if clazz.is_a? Class
|
50
48
|
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
class << clazz
|
50
|
+
def url url=nil
|
51
|
+
@url = url if url
|
52
|
+
@url
|
53
|
+
end
|
54
|
+
|
55
|
+
def inherited clazz
|
56
|
+
clazz.element_definitions.merge!(element_definitions)
|
57
|
+
PageMagic.pages << clazz
|
58
|
+
end
|
54
59
|
end
|
60
|
+
|
55
61
|
end
|
56
62
|
|
57
63
|
def pages
|
58
64
|
@pages||=[]
|
59
65
|
end
|
60
66
|
end
|
61
|
-
|
62
|
-
module ClassMethods
|
63
|
-
def included clazz
|
64
|
-
clazz.instance_eval { include PageMagic }
|
65
|
-
clazz.element_definitions.merge!(element_definitions)
|
66
|
-
end
|
67
|
-
|
68
|
-
def method_missing method_name, *args
|
69
|
-
raise "You can only instantiate child pages" if method_name == :new
|
70
|
-
super
|
71
|
-
end
|
72
|
-
end
|
73
67
|
end
|
data/page_magic.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "page_magic"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.9.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Leon Davis"]
|
12
|
-
s.date = "2013-11-
|
12
|
+
s.date = "2013-11-17"
|
13
13
|
s.description = "Framework for modeling and interacting with webpages which wraps capybara"
|
14
14
|
s.email = "info@lad-tech.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -27,30 +27,28 @@ Gem::Specification.new do |s|
|
|
27
27
|
"lib/page_magic.rb",
|
28
28
|
"lib/page_magic/ajax_support.rb",
|
29
29
|
"lib/page_magic/browser.rb",
|
30
|
+
"lib/page_magic/element.rb",
|
30
31
|
"lib/page_magic/element_context.rb",
|
31
|
-
"lib/page_magic/
|
32
|
-
"lib/page_magic/page_elements.rb",
|
32
|
+
"lib/page_magic/elements.rb",
|
33
33
|
"lib/page_magic/page_magic.rb",
|
34
|
-
"lib/page_magic/
|
34
|
+
"lib/page_magic/section.rb",
|
35
35
|
"lib/page_magic/session.rb",
|
36
|
-
"lib/page_magic/wait.rb",
|
37
36
|
"page_magic.gemspec",
|
38
37
|
"spec/browser_spec.rb",
|
39
38
|
"spec/element_context_spec.rb",
|
40
|
-
"spec/
|
39
|
+
"spec/element_spec.rb",
|
40
|
+
"spec/elements_spec.rb",
|
41
41
|
"spec/helpers/capybara.rb",
|
42
42
|
"spec/member_methods_spec.rb",
|
43
|
-
"spec/page_element_spec.rb",
|
44
|
-
"spec/page_elements_spec.rb",
|
45
43
|
"spec/page_magic_spec.rb",
|
46
|
-
"spec/
|
44
|
+
"spec/section_spec.rb",
|
47
45
|
"spec/session_spec.rb",
|
48
46
|
"spec/spec_helper.rb"
|
49
47
|
]
|
50
48
|
s.homepage = "https://github.com/ladtech/page_magic"
|
51
49
|
s.licenses = ["ruby"]
|
52
50
|
s.require_paths = ["lib"]
|
53
|
-
s.rubygems_version = "1.8.
|
51
|
+
s.rubygems_version = "1.8.25"
|
54
52
|
s.summary = "Framework for modeling and interacting with webpages"
|
55
53
|
|
56
54
|
if s.respond_to? :specification_version then
|
data/spec/browser_spec.rb
CHANGED
@@ -4,29 +4,33 @@ describe PageMagic::Browser do
|
|
4
4
|
let(:app) { Object.new }
|
5
5
|
|
6
6
|
before do
|
7
|
-
PageMagic::Browser.session
|
7
|
+
PageMagic::Browser.instance_variable_set(:@session, nil)
|
8
8
|
app.extend PageMagic::Browser
|
9
9
|
end
|
10
10
|
|
11
|
-
describe '
|
12
|
-
it 'should
|
13
|
-
|
14
|
-
|
11
|
+
describe 'default' do
|
12
|
+
it 'should be firefox' do
|
13
|
+
PageMagic::Browser.default.should == :firefox
|
14
|
+
end
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
+
describe 'browser' do
|
18
|
+
it 'should return the existing session' do
|
19
|
+
session_instance = app.browser
|
20
|
+
app.browser.should == session_instance
|
17
21
|
end
|
18
22
|
|
19
23
|
it 'should create a session if not already set' do
|
20
24
|
new_session = double(:new_session)
|
21
25
|
|
22
|
-
PageMagic.should_receive(:session).with(:
|
26
|
+
PageMagic.should_receive(:session).with(:firefox).and_return new_session
|
23
27
|
app.browser.should == new_session
|
24
28
|
end
|
25
29
|
|
26
30
|
it 'should use custom browser' do
|
27
|
-
PageMagic
|
31
|
+
PageMagic.should_receive(:session).with(:custom_browser)
|
28
32
|
|
29
|
-
PageMagic.
|
33
|
+
PageMagic::Browser.default :custom_browser
|
30
34
|
app.browser
|
31
35
|
end
|
32
36
|
end
|
@@ -29,51 +29,51 @@ describe 'Page elements' do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should locate an element using its id' do
|
32
|
-
element = PageMagic::
|
32
|
+
element = PageMagic::Element.new(:my_input,page, :text_field, id:'field_id').locate
|
33
33
|
element.value == 'filled in'
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should locate an element using its name' do
|
37
|
-
element = PageMagic::
|
37
|
+
element = PageMagic::Element.new(:my_input,page, :text_field, name:'field_name').locate
|
38
38
|
element.value == 'filled in'
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should locate a link using its text' do
|
42
|
-
element = PageMagic::
|
42
|
+
element = PageMagic::Element.new(:my_link,page, :link, text: 'my link').locate
|
43
43
|
element[:id].should == 'my_link'
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'should locate an element using its label' do
|
47
|
-
element = PageMagic::
|
47
|
+
element = PageMagic::Element.new(:my_link,page, :link, label: 'enter text').locate
|
48
48
|
element[:id].should == 'field_id'
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should raise an exception when finding another element using its text' do
|
52
|
-
expect{PageMagic::
|
52
|
+
expect{PageMagic::Element.new(:my_link,page, :text_field, text: 'my link').locate}.to raise_error(PageMagic::UnsupportedSelectorException)
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'should locate an element using css' do
|
56
|
-
element = PageMagic::
|
56
|
+
element = PageMagic::Element.new(:my_link,page, :link, css: "input[name='field_name']").locate
|
57
57
|
element[:id].should == 'field_id'
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'should raise errors for unsupported selectors' do
|
61
|
-
expect{PageMagic::
|
61
|
+
expect{PageMagic::Element.new(:my_link,page, :link, unsupported:"").locate}.to raise_error(PageMagic::UnsupportedSelectorException)
|
62
62
|
end
|
63
63
|
|
64
64
|
|
65
65
|
|
66
66
|
it 'should return the browser element if a selector was not specified' do
|
67
|
-
PageMagic::
|
67
|
+
PageMagic::Element.new(:help, browser, :link, nil).locate.should == browser
|
68
68
|
end
|
69
69
|
|
70
70
|
#TODO - Bug here, parent element reference is not available
|
71
71
|
it 'should return a prefetched value' do
|
72
|
-
PageMagic::
|
72
|
+
PageMagic::Element.new(:help, "prefetched text", :link ).locate.should == "prefetched text"
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'should have a handle to the session' do
|
76
|
-
PageMagic::
|
76
|
+
PageMagic::Element.new(:help, page, :link, :selector ).session.should == page.session
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'page_magic'
|
3
3
|
|
4
|
-
describe PageMagic::
|
4
|
+
describe PageMagic::Elements do
|
5
5
|
|
6
6
|
|
7
7
|
let(:page_elements) do
|
8
8
|
page_element = Class.new do
|
9
|
-
extend(PageMagic::
|
9
|
+
extend(PageMagic::Elements)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -22,7 +22,7 @@ describe PageMagic::PageElements do
|
|
22
22
|
context 'using a selector' do
|
23
23
|
it 'should add an element' do
|
24
24
|
page_elements.text_field :name, selector
|
25
|
-
page_elements.element_definitions[:name].call(parent_page_element).should == PageMagic::
|
25
|
+
page_elements.element_definitions[:name].call(parent_page_element).should == PageMagic::Element.new(:name, parent_page_element, :text_field, selector)
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'should return your a copy of the core definition' do
|
@@ -47,10 +47,10 @@ describe PageMagic::PageElements do
|
|
47
47
|
|
48
48
|
let!(:section_class) do
|
49
49
|
Class.new do
|
50
|
-
extend PageMagic::
|
50
|
+
extend PageMagic::Section
|
51
51
|
|
52
52
|
def == object
|
53
|
-
object.class.is_a?(PageMagic::
|
53
|
+
object.class.is_a?(PageMagic::Section) &&
|
54
54
|
object.name == self.name
|
55
55
|
end
|
56
56
|
end
|
@@ -132,7 +132,7 @@ describe PageMagic::PageElements do
|
|
132
132
|
page_elements.section :page_section, nil do
|
133
133
|
end
|
134
134
|
|
135
|
-
expect { page_elements.elements(parent_page_element, arg) }.to raise_error(PageMagic::
|
135
|
+
expect { page_elements.elements(parent_page_element, arg) }.to raise_error(PageMagic::Section::UndefinedSelectorException)
|
136
136
|
end
|
137
137
|
|
138
138
|
|
@@ -167,7 +167,7 @@ describe PageMagic::PageElements do
|
|
167
167
|
def hello;
|
168
168
|
end
|
169
169
|
end
|
170
|
-
end.to raise_error(PageMagic::
|
170
|
+
end.to raise_error(PageMagic::Elements::InvalidMethodNameException)
|
171
171
|
end
|
172
172
|
|
173
173
|
it 'should not allow element names that match method names' do
|
@@ -178,7 +178,7 @@ describe PageMagic::PageElements do
|
|
178
178
|
|
179
179
|
link(:hello, text: 'world')
|
180
180
|
end
|
181
|
-
end.to raise_error(PageMagic::
|
181
|
+
end.to raise_error(PageMagic::Elements::InvalidElementNameException)
|
182
182
|
end
|
183
183
|
|
184
184
|
it 'should not allow duplicate element names' do
|
@@ -187,7 +187,7 @@ describe PageMagic::PageElements do
|
|
187
187
|
link(:hello, text: 'world')
|
188
188
|
link(:hello, text: 'world')
|
189
189
|
end
|
190
|
-
end.to raise_error(PageMagic::
|
190
|
+
end.to raise_error(PageMagic::Elements::InvalidElementNameException)
|
191
191
|
end
|
192
192
|
|
193
193
|
it 'should not evaluate the elements when applying naming checks' do
|
data/spec/member_methods_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe 'member methods' do
|
|
5
5
|
|
6
6
|
let(:page_object_class) do
|
7
7
|
Class.new do
|
8
|
-
extend PageMagic::
|
8
|
+
extend PageMagic::Elements
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -17,7 +17,7 @@ describe 'member methods' do
|
|
17
17
|
|
18
18
|
|
19
19
|
describe 'the element types that you can define' do
|
20
|
-
PageMagic::
|
20
|
+
PageMagic::Elements::TYPES.each do |element_type|
|
21
21
|
|
22
22
|
it "can have a #{element_type}" do
|
23
23
|
parent_page_element = double('parent_page_object', browser_element: double('browser_element'))
|
@@ -26,7 +26,7 @@ describe 'member methods' do
|
|
26
26
|
page_object_class.send(element_type, friendly_name,{})
|
27
27
|
|
28
28
|
|
29
|
-
expected_element = PageMagic::
|
29
|
+
expected_element = PageMagic::Element.new(friendly_name,parent_page_element, element_type, {})
|
30
30
|
page_object_class.element_definitions[friendly_name].call(parent_page_element) == expected_element
|
31
31
|
end
|
32
32
|
end
|
data/spec/page_magic_spec.rb
CHANGED
@@ -90,42 +90,30 @@ describe 'page magic' do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
|
93
|
-
describe '
|
94
|
-
|
95
|
-
|
93
|
+
describe 'inheritance' do
|
94
|
+
let(:parent_page) do
|
95
|
+
Class.new do
|
96
96
|
include PageMagic
|
97
97
|
link(:next, :text => "next page")
|
98
98
|
end
|
99
|
+
end
|
99
100
|
|
100
|
-
|
101
|
-
|
102
|
-
url '/page1'
|
103
|
-
end
|
101
|
+
let(:child_page) do
|
102
|
+
Class.new(parent_page)
|
104
103
|
end
|
105
104
|
|
106
105
|
context 'children' do
|
107
|
-
it '
|
108
|
-
ChildPage.url.should == '/page1'
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'inherit elements' do
|
112
|
-
child_page = ChildPage.new
|
113
|
-
child_page.visit
|
106
|
+
it 'should inherit elements defined on the parent class' do
|
114
107
|
child_page.element_definitions.should include(:next)
|
115
108
|
end
|
116
109
|
|
117
110
|
it 'are added to PageMagic.pages list' do
|
118
|
-
PageMagic.pages.
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
context 'parent' do
|
123
|
-
it 'is not registered as Page' do
|
124
|
-
PageMagic.pages.should_not include(ParentPage)
|
111
|
+
PageMagic.pages.should include(child_page)
|
125
112
|
end
|
126
113
|
|
127
|
-
it '
|
128
|
-
|
114
|
+
it 'should pass on element definitions to their children' do
|
115
|
+
grand_child_class = Class.new(child_page)
|
116
|
+
grand_child_class.element_definitions.should include(:next)
|
129
117
|
end
|
130
118
|
end
|
131
119
|
end
|
@@ -152,7 +140,7 @@ describe 'page magic' do
|
|
152
140
|
|
153
141
|
|
154
142
|
it 'can have fields' do
|
155
|
-
@page.element_definitions[:next].call(@page).should == PageMagic::
|
143
|
+
@page.element_definitions[:next].call(@page).should == PageMagic::Element.new(:next, @page, :button, :text => "next")
|
156
144
|
end
|
157
145
|
|
158
146
|
it 'should copy fields on to element' do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe PageMagic::
|
3
|
+
describe PageMagic::Section do
|
4
4
|
|
5
5
|
include_context :webapp
|
6
6
|
|
@@ -29,7 +29,7 @@ describe PageMagic::PageSection do
|
|
29
29
|
context 'class level' do
|
30
30
|
let(:section) do
|
31
31
|
Class.new do
|
32
|
-
extend PageMagic::
|
32
|
+
extend PageMagic::Section
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -69,7 +69,7 @@ describe PageMagic::PageSection do
|
|
69
69
|
|
70
70
|
let(:page_section_class) do
|
71
71
|
page_section_class = Class.new do
|
72
|
-
extend PageMagic::
|
72
|
+
extend PageMagic::Section
|
73
73
|
end
|
74
74
|
page_section_class.stub(:name).and_return('PageSection')
|
75
75
|
page_section_class
|
@@ -87,7 +87,7 @@ describe PageMagic::PageSection do
|
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'should raise an error if a class selector is not defined and one is not given to the constructor' do
|
90
|
-
expect { page_section_class.new(parent_page_element) }.to raise_error(PageMagic::
|
90
|
+
expect { page_section_class.new(parent_page_element) }.to raise_error(PageMagic::Section::UndefinedSelectorException)
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
data/spec/session_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe PageMagic::Session do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
let(:browser) { double('browser') }
|
23
|
+
let(:browser) { double('browser', current_url: 'url') }
|
24
24
|
|
25
25
|
it 'should visit the given url' do
|
26
26
|
browser.should_receive(:visit).with(page.url)
|
@@ -28,6 +28,11 @@ describe PageMagic::Session do
|
|
28
28
|
session.current_page.should be_a(page)
|
29
29
|
end
|
30
30
|
|
31
|
+
it 'should return the current url' do
|
32
|
+
session = PageMagic::Session.new(browser)
|
33
|
+
session.current_url.should == 'url'
|
34
|
+
end
|
35
|
+
|
31
36
|
context 'method_missing' do
|
32
37
|
it 'should delegate to current page' do
|
33
38
|
browser.stub(:visit)
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: page_magic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.4
|
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: 2013-11-
|
12
|
+
date: 2013-11-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capybara
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: wait
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: jeweler
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: 1.8.4
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.4
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: watir-webdriver
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,7 +69,12 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :runtime
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
description: Framework for modeling and interacting with webpages which wraps capybara
|
59
79
|
email: info@lad-tech.com
|
60
80
|
executables: []
|
@@ -73,23 +93,21 @@ files:
|
|
73
93
|
- lib/page_magic.rb
|
74
94
|
- lib/page_magic/ajax_support.rb
|
75
95
|
- lib/page_magic/browser.rb
|
96
|
+
- lib/page_magic/element.rb
|
76
97
|
- lib/page_magic/element_context.rb
|
77
|
-
- lib/page_magic/
|
78
|
-
- lib/page_magic/page_elements.rb
|
98
|
+
- lib/page_magic/elements.rb
|
79
99
|
- lib/page_magic/page_magic.rb
|
80
|
-
- lib/page_magic/
|
100
|
+
- lib/page_magic/section.rb
|
81
101
|
- lib/page_magic/session.rb
|
82
|
-
- lib/page_magic/wait.rb
|
83
102
|
- page_magic.gemspec
|
84
103
|
- spec/browser_spec.rb
|
85
104
|
- spec/element_context_spec.rb
|
86
|
-
- spec/
|
105
|
+
- spec/element_spec.rb
|
106
|
+
- spec/elements_spec.rb
|
87
107
|
- spec/helpers/capybara.rb
|
88
108
|
- spec/member_methods_spec.rb
|
89
|
-
- spec/page_element_spec.rb
|
90
|
-
- spec/page_elements_spec.rb
|
91
109
|
- spec/page_magic_spec.rb
|
92
|
-
- spec/
|
110
|
+
- spec/section_spec.rb
|
93
111
|
- spec/session_spec.rb
|
94
112
|
- spec/spec_helper.rb
|
95
113
|
homepage: https://github.com/ladtech/page_magic
|
@@ -107,7 +125,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
125
|
version: '0'
|
108
126
|
segments:
|
109
127
|
- 0
|
110
|
-
hash:
|
128
|
+
hash: 183880895719648639
|
111
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
130
|
none: false
|
113
131
|
requirements:
|
@@ -116,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
134
|
version: '0'
|
117
135
|
requirements: []
|
118
136
|
rubyforge_project:
|
119
|
-
rubygems_version: 1.8.
|
137
|
+
rubygems_version: 1.8.25
|
120
138
|
signing_key:
|
121
139
|
specification_version: 3
|
122
140
|
summary: Framework for modeling and interacting with webpages
|
data/lib/page_magic/wait.rb
DELETED
data/spec/helpers.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'helpers/capybara'
|