page_magic 1.1.0 → 1.2.0

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: 4acdbbbed10c450234259833ff79fc6fe45ba7f8
4
- data.tar.gz: 3167a8d0be893169dac91a1f449f9713a057189e
3
+ metadata.gz: 5de023c943b2c64e2b8bf0a74d4c3875be2b74c5
4
+ data.tar.gz: 2d3d1baf2f1f14965f7ac9d7825663cc3e329105
5
5
  SHA512:
6
- metadata.gz: cd8232c273a46b22c349e8819da69f3d12680443bf3493334f0ab549698656d27ab98ddbd0ec0d2957b93038e7ec7735c9dfbfcef831aa20823b0f7cbf39ca18
7
- data.tar.gz: be986a4a47b5645fb9629a6c695d090de31c0c969a82bff6f23cbef482cca57ca504acc27002a3de98fe6eafd432726a1d3f41197855e8023a9362c65f718526
6
+ metadata.gz: 60c8b45cc4c56a0aac851a892b30710e8bfd0ccb962f985813289ca397d031b2ce68592558b56972f1538abd6cbcaeb44b82f459b32a866fe5a0e17e9fd779bc
7
+ data.tar.gz: 0e6222727b66e406d2dd1f365af3c46591f3189633b337832242209b9db41aaf0c3be39a12b4f1fca3fbcba6bd40102553bcf498b19907d23f65c2ffc36cd3a0
data/README.md CHANGED
@@ -39,6 +39,7 @@ we are not aware of so your feedback/pull requests are greatly appreciated!
39
39
  - [Page mapping](#page-mapping)
40
40
  - [Mapping against query string parameters](#mapping-against-query-string-parameters)
41
41
  - [Mapping against fragment identifiers](#mapping-against-fragment-identifiers)
42
+ - [Loading pages from source](#loading-pages-from-source)
42
43
  - [Watchers](#watchers)
43
44
  - [Method watchers](#method-watchers)
44
45
  - [Simple watchers](#simple-watchers)
@@ -316,6 +317,18 @@ against URL fragments.
316
317
  browser.define_page_mappings PageMagic.mapping(fragment: string_or_regex) => ResultsPage
317
318
  ```
318
319
 
320
+ # Loading pages from source
321
+ PageMagic supports loading page objects using html source. This technique can be useful for getting quick feedback that
322
+ your templates correctly render based on your view objects. I.e you can test your templates in isolation.
323
+ ```ruby
324
+ class MyPage
325
+ include PageMagic
326
+ #element definitions
327
+ end
328
+
329
+ page_instance = Page.load(html_string)
330
+ ```
331
+
319
332
  # Watchers
320
333
  PageMagic lets you set a watcher on any element. Use watchers to decide when things have changed. The `watch` method can be called from anywhere within an element definition. For PageObjects it can only be called from within hooks and helper methods.
321
334
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -4,6 +4,13 @@ module PageMagic
4
4
  # Default block to be run when a page is loaded. This is used if a specific handler is not registered
5
5
  DEFAULT_ON_LOAD = proc {}
6
6
 
7
+ # create an new page object instance based on top of the source supplied
8
+ # @param [String] source html source code
9
+ # @return [Object<InstanceMethods>] instance of class with all the same methods as normal PageMagic page objects.
10
+ def load(source)
11
+ new(Session.new(Capybara::Node::Simple.new(source)))
12
+ end
13
+
7
14
  # sets block to run when page has loaded
8
15
  # if one has not been set on the page object class it will return a default block that does nothing
9
16
  def on_load(&block)
data/page_magic.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: page_magic 1.1.0 ruby lib
5
+ # stub: page_magic 1.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "page_magic"
9
- s.version = "1.1.0"
9
+ s.version = "1.2.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Leon Davis"]
14
- s.date = "2015-11-25"
14
+ s.date = "2015-11-26"
15
15
  s.description = "Framework for modeling and interacting with webpages which wraps capybara"
16
16
  s.email = "info@lad-tech.com"
17
17
  s.extra_rdoc_files = [
@@ -86,7 +86,7 @@ Gem::Specification.new do |s|
86
86
  s.homepage = "https://github.com/ladtech/page_magic"
87
87
  s.licenses = ["ruby"]
88
88
  s.required_ruby_version = Gem::Requirement.new(">= 2.1")
89
- s.rubygems_version = "2.2.2"
89
+ s.rubygems_version = "2.4.8"
90
90
  s.summary = "Framework for modeling and interacting with webpages"
91
91
 
92
92
  if s.respond_to? :specification_version then
@@ -7,6 +7,21 @@ module PageMagic
7
7
  end
8
8
  end
9
9
 
10
+ describe '#load' do
11
+ let(:page_title) { 'page title' }
12
+ let(:page_source) do
13
+ <<-HTML
14
+ <html>
15
+ <head><title>#{page_title}</title></head>
16
+ </html>
17
+ HTML
18
+ end
19
+
20
+ it 'returns an instance using that source' do
21
+ expect(subject.load(page_source).title).to eq(page_title)
22
+ end
23
+ end
24
+
10
25
  describe 'on_load' do
11
26
  context 'block not set' do
12
27
  it 'returns a default block' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_magic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leon Davis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-25 00:00:00.000000000 Z
11
+ date: 2015-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  version: '0'
200
200
  requirements: []
201
201
  rubyforge_project:
202
- rubygems_version: 2.2.2
202
+ rubygems_version: 2.4.8
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: Framework for modeling and interacting with webpages