site-object 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 560ad57af8dc4f42986d83000bc3ebae19c8b49e
4
- data.tar.gz: db9a6825e5a7590eddd5f52b69d31cc07f45fa2b
3
+ metadata.gz: 9ad431d5441a28f4dc1457ab72f96974165f47f1
4
+ data.tar.gz: 14de5b9f55418c89c43e190baad1b186d486c3e4
5
5
  SHA512:
6
- metadata.gz: 792d37179ae06be6cf700e01e3764185bdc01743541b5f34dc04952f249a99484c2114b5a894f998eb95db018445d9879c953bc225de2f84dbd7694d8766ea01
7
- data.tar.gz: 8ed7700e22002050e9e6bd5453441e2a8e847ccf95f32b46e3423611fbb8ded78ce0b006ebc225e62ca913e795fb4a8e4800a20af74de088ecb1139443305d6b
6
+ metadata.gz: b9e90c86c260bc457965ed1fe75db2280fcf679ab7c93cbab57a3040634ef3b76170aa180a4983640e559c1bdef09994cb657fda61596490362d59c0094cde6a
7
+ data.tar.gz: ea13a80a9d73c9cd9b5054467245c89c04913c07579929c97d35f6670ccde6dbef00a444cea25feb1cd09ba3dcc1b280b12cc5e0a97fd0fb500988ba3af6bcba
@@ -23,12 +23,12 @@ module SiteObject
23
23
  @browser.close # Same for watir-webdriver and selenium-webdriver.
24
24
  end
25
25
 
26
- # Helper method designed to assist with complex workflows. Basically, if you're navigating and
27
- # expect a certain page to be displayed you can use this method to confirm that the page you want is
26
+ # Helper method designed to assist with complex workflows. Basically, if you're navigating and
27
+ # expect a certain page to be displayed you can use this method to confirm that the page you want is
28
28
  # displayed and then get a page object for it.
29
29
  #
30
- # This method just checks to see if the right class of page is being displayed. If you have defined
31
- # a templated value in the URL of the page object getting checked it doesn't check the values of
30
+ # This method just checks to see if the right class of page is being displayed. If you have defined
31
+ # a templated value in the URL of the page object getting checked it doesn't check the values of
32
32
  # the arguments. It only confirms whether or not the arguments are present.
33
33
  def expect_page(page_arg)
34
34
  p = page
@@ -41,19 +41,19 @@ module SiteObject
41
41
  elsif page_arg.is_a?(Symbol) && p.class.name.underscore.to_sym == page_arg
42
42
  return p
43
43
  else
44
- raise SiteObject::WrongPageError, "Expected #{page_arg} page to be displayed but the URL doesn't look right. \n\n#{caller.join("\n")}"
44
+ raise SiteObject::WrongPageError, "Expected #{page_arg} page to be displayed but the URL doesn't look right. \n\n#{caller.join("\n")}"
45
45
  end
46
46
  else
47
47
  raise SiteObject::WrongPageError, "Expected #{page_arg} page to be displayed but the URL doesn't appear to match the URL template of any known page. \n\n#{caller.join("\n")}"
48
48
  end
49
49
  end
50
50
 
51
- # Creates a site object, which will have accessor methods for all pages that have been defined for
52
- # the site. This object takes a hash argument. There is only one required value (the base_url for
51
+ # Creates a site object, which will have accessor methods for all pages that have been defined for
52
+ # the site. This object takes a hash argument. There is only one required value (the base_url for
53
53
  # the site.) Example:
54
54
  #
55
55
  # class MySite
56
- # include SiteObject
56
+ # include SiteObject
57
57
  # end
58
58
  #
59
59
  # site = MySite.new(base_url: "http://foo.com")
@@ -63,28 +63,26 @@ module SiteObject
63
63
  # site = MySite.new(
64
64
  # base_url: "http://foo.com",
65
65
  # foo: true
66
- # bar: 1
66
+ # bar: 1
67
67
  # )
68
68
  # site.foo
69
69
  # => true
70
70
  # site.bar
71
71
  # => 1
72
- def initialize(args={})
72
+ def initialize(args={})
73
73
  unless args.is_a?(Hash)
74
- unless
75
- raise SiteObject::SiteInitError, "You must provide hash arguments when initializing a site object. At a minimum you must specify a base_url. Example:\ns = SiteObject.new(base_url: 'http://foo.com')"
76
- end
74
+ raise SiteObject::SiteInitError, "You must provide hash arguments when initializing a site object. At a minimum you must specify a base_url. Example:\ns = SiteObject.new(base_url: 'http://foo.com')"
77
75
  end
78
-
76
+
79
77
  @arguments = args.with_indifferent_access
80
78
  @base_url = @arguments[:base_url]
81
79
  @browser = @arguments[:browser]
82
80
  @pages = self.class::Page.descendants
83
-
81
+
84
82
  # Set up accessor methods for each page and defines the URL template.
85
83
  @pages.each do |current_page|
86
84
  current_page.set_url_template(@base_url)
87
-
85
+
88
86
  self.class.class_eval do
89
87
  define_method(current_page.to_s.underscore) do |args={}, block=nil|
90
88
  current_page.new(self, args)
@@ -110,8 +108,8 @@ module SiteObject
110
108
 
111
109
  # In cases where the site object doesn't recognize a method it will try to delegate the method call
112
110
  # to the page that's currently being displayed in the browser, assuming that the site object recognizes
113
- # the page by its URL. If the page is the last visited page and method is unique, (i.e., doesn't belong
114
- # to any other page object) then the site object won't attempt to regenerate the page when calling
111
+ # the page by its URL. If the page is the last visited page and method is unique, (i.e., doesn't belong
112
+ # to any other page object) then the site object won't attempt to regenerate the page when calling
115
113
  # the method.
116
114
  def method_missing(sym, *args, &block)
117
115
  if @unique_methods.include?(sym) && @most_recent_page.respond_to?(sym)
@@ -133,7 +131,7 @@ module SiteObject
133
131
  elsif block
134
132
  p.send(sym, &block)
135
133
  else
136
- p.send sym
134
+ p.send sym
137
135
  end
138
136
  else
139
137
  super
@@ -144,7 +142,7 @@ module SiteObject
144
142
  end
145
143
 
146
144
  # Returns true or false depending on whether the specified page is displayed. You can use a page
147
- # object or a PageObject class name to identify the page you are looking for. Examples:
145
+ # object or a PageObject class name to identify the page you are looking for. Examples:
148
146
  #
149
147
  # page = site.account_summary_page
150
148
  # =>#<AccountSummaryPage:70341126478080 ...>
@@ -165,7 +163,7 @@ module SiteObject
165
163
  end
166
164
  end
167
165
 
168
- # Can be used to open a browser for the site object if the user did not pass one in when it was
166
+ # Can be used to open a browser for the site object if the user did not pass one in when it was
169
167
  # initialized. The arguments used here get passed down to Watir when starting the browser. Example:
170
168
  # s = SomeSite.new(hash)
171
169
  # s.open_browser :watir, :firefox
@@ -183,7 +181,7 @@ module SiteObject
183
181
  end
184
182
  end
185
183
 
186
- # Looks at the page currently being displayed in the browser and tries to return a page object for
184
+ # Looks at the page currently being displayed in the browser and tries to return a page object for
187
185
  # it. Does this by looking at the currently displayed URL in the browser. The first page that gets
188
186
  # checked is the page that was most recently accessed. After that it will cycle through all available
189
187
  # pages looking for a match. Returns nil if it can't find a matching page object.
@@ -192,7 +190,7 @@ module SiteObject
192
190
 
193
191
  url = @browser.url
194
192
  found_page = nil
195
-
193
+
196
194
  @pages.each do |p|
197
195
  if p.url_template.match url
198
196
  found_page = p
@@ -202,8 +200,8 @@ module SiteObject
202
200
 
203
201
  break if found_page
204
202
  end
205
-
206
- if found_page && !found_page.required_arguments.empty?
203
+
204
+ if found_page && !found_page.required_arguments.empty?
207
205
  return found_page.new(self, found_page.url_template.extract(url))
208
206
  elsif found_page
209
207
  return found_page.new(self)
@@ -1,3 +1,3 @@
1
1
  module SiteObject
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: site-object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Fitisoff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-25 00:00:00.000000000 Z
11
+ date: 2015-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 3.2.10
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 3.2.10
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: addressable
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  requirements: []
82
82
  rubyforge_project: site-object
83
- rubygems_version: 2.2.2
83
+ rubygems_version: 2.2.3
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: Wraps page objects up into a site object, which provides some introspection