page_right 0.3 → 0.4

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: a04365b175ef112a7848ee3fa2c32fb9f3e7bb79
4
- data.tar.gz: 87717fc01b2053bd06c5903fafa394d2d8d05689
3
+ metadata.gz: 03bb63f1e3959333578a8cef939d0db37e22eb1c
4
+ data.tar.gz: 2962e93f840f68bf441ddfc8b21d57c4376a8f34
5
5
  SHA512:
6
- metadata.gz: 97972581e3e9641a6dde35c9da27c522548f718fd8f0034a2b300ceb203d16d826d280252f579735b223574eced59d284bc20cf0c3e83e2cd6397b3007676ea2
7
- data.tar.gz: bab05fe5c32bbfb2ef88f610ac78e40bdc01292db1e3cc89158060a769af8c820aa57d870da8a588090db3a8864c7ba18486452f2da124501d3d2903b9760994
6
+ metadata.gz: c08854273c6ce8c4b2117ace6b1be12354cbc943156ae293724855433b11c3c04d77a3e1704d0ca5a675187284ac5d67c4f6bca78525f9ff3aa44979a1859b76
7
+ data.tar.gz: 365592ec0dbf11b7cec3469ab906cb5c6b89804cb1208cfbfbe0597cb534a7596f83f5963b4d7c2e666f86ec2a83c2ac2feec5073bd339d03e0c813d36754411
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/CHANGES.md ADDED
@@ -0,0 +1,4 @@
1
+ 0.3
2
+ --------------------
3
+
4
+ - Migrated original code from the old page-right gem to this new page_right gem and separated out the methods into sub files.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in page_right.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Dave Collier
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,126 @@
1
+ ## PageRight Gem - Checks the content of your rendered web pages. `Currently under development !!`
2
+
3
+ Version 0.4 20th November 2014
4
+
5
+ A very simple gem that contains a few helper/wrapper methods utilising Capybara to aid testing the contents of a rendered web page when writing integration tests.
6
+
7
+ It works with Test::Unit for now since this gem simply adds methods to ActiveSupport::TestCase, but I hope to develop it further to be used with RSpec and Cucumber.
8
+
9
+ Semantic versioning is applied to this gem.
10
+
11
+ ### Installation:
12
+
13
+ Include it in your Gemfile.
14
+
15
+ ```ruby
16
+ gem 'page_right'
17
+ ```
18
+
19
+ Then require it in you `test_helper.rb` file.
20
+
21
+ ```ruby
22
+ require 'page_right'
23
+ ```
24
+
25
+ ### Method Descriptions:
26
+
27
+ #### text_in_page(content, flag=true)
28
+
29
+ This method will search the whole page for the `content` provided and check that it is in the page. If `flag=false` is set, then the method will check that `content` is not on the page.
30
+
31
+ Examples:
32
+
33
+ ```ruby
34
+ text_in_page('This text')
35
+ ```
36
+
37
+ Checks `This text` is in the page.
38
+
39
+ ```ruby
40
+ text_in_page('Your text here', false)
41
+ ```
42
+
43
+ Check `This text` is NOT in the page.
44
+
45
+ #### text_in_section(section, content, flag=true)
46
+
47
+ This method will check that the `content` is displayed within a particular css selector `section` (div, or other named html element). If `flag=false` is set, then the method will check that the `content` is not within the css selector `section`.
48
+
49
+ Examples:
50
+
51
+ ```ruby
52
+ text_in_section('.named-class' 'This text')
53
+ ```
54
+
55
+ Check `This text` is within a class called `named-class`.
56
+
57
+ ```ruby
58
+ text_in_section('#named-id', 'Your text here', false)
59
+
60
+ Check `This text` is not within any id called `named-id`
61
+
62
+ #### css_in_page(css, flag=true))
63
+
64
+ This method will check that the class or id supplied is displayed somewhere on the page. If `flag=false` is set, then the method will check that the class or id supplied is not displayed anywhere on the page.
65
+
66
+ Examples:
67
+
68
+ ```ruby
69
+ css_in_page('#my-css')
70
+ ```
71
+
72
+ Check that a css selector with id `my-css` is in the page.
73
+
74
+ ```ruby
75
+ css_in_page('.my-css', false)
76
+ ```
77
+ Check that an css selector with a class `my-css`is NOT in the page.
78
+
79
+ #### css_in_section(css1, css2, flag=true)
80
+
81
+ This method will check that the `css2` selector is nested within a another `css1` selector. If `flag=false` is set, then the method will check that the `css2` selector is not within the `css1` selector. This method is good if you want to check for nested css selectors as if often the case.
82
+
83
+ Examples:
84
+
85
+ ```ruby
86
+ css_in_section('.my-css1', '#my-css2')
87
+ ```
88
+
89
+ Check the id `my-css2`is nested in class `my-css1`.
90
+
91
+ ```ruby
92
+ css_in_section('#my-css1', '.my-css2', false)
93
+ ```
94
+
95
+ Check the class `my-css2` is NOT nested within the id `my-css1`.
96
+
97
+ ### image_in_section(section, image, count, flag=true)
98
+
99
+ This method will check that the number of `image(s)` in the `section` is equal to `count`. If `flag=false` is set, then the method will check the number of `image(s)` in the `section` is not equal to `count`. If you just want to check that a particular `image` is in a particluar css selector `section` then pass in value of 1 for the `count` argument.
100
+
101
+ Examples:
102
+
103
+ ```ruby
104
+ image_in_section('.my-css', 'my-image.jpg', 1)
105
+ ```
106
+
107
+ Check there is exactly one `my-image.jpg` image within a class `my-css`.
108
+
109
+ ```ruby
110
+ image_in_section('#my-css', 'my-image.jpg', 1, false)
111
+ ```
112
+
113
+ Check there is NOT a `my-image.jpg` image within an id `my-css`.
114
+
115
+ ```ruby
116
+ image_in_section('#my-css', 'my-image.jpg', 3, false)
117
+ ```
118
+
119
+ Check there are 3 `my-image.jpg` image's within an id `my-css`.
120
+
121
+
122
+ ### License
123
+
124
+ PageRight is released under the <a href="http://www.opensource.org/licenses/MIT" target="_blank">MIT License</a>.
125
+
126
+ <a href="https://www.omniref.com/ruby/gems/page-right"><img src="https://www.omniref.com/ruby/gems/page-right.png" alt="page-right API Documentation" /></a>
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ t.pattern='"**/*_test.rb"'
7
+ end
8
+
9
+ task :default => :test
10
+
11
+ task :console do
12
+ exec "pry -r 'page_right' -I './lib'"
13
+ end
@@ -0,0 +1,23 @@
1
+ module ActiveSupport
2
+ class TestCase
3
+ # Check that a css element is on the page, set flag to check that it isn't
4
+ def css_in_page(css, flag=true)
5
+ if flag
6
+ assert page.has_css?("#{css}"), "Error: #{css} not found on page !"
7
+ else
8
+ assert !page.has_css?("#{css}"), "Error: #{css} found on page !"
9
+ end
10
+ end
11
+
12
+ # Check that a css element is nested within another css element, set flag to check that it isn't
13
+ def css_in_section(css1, css2, flag=true)
14
+ within("#{css1}") do
15
+ if flag
16
+ assert page.has_css?("#{css2}"), "Error: #{css2} not found in #{css1} !"
17
+ else
18
+ assert !page.has_css?("#{css2}"), "Error: #{css2} found in #{css1} !"
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,12 @@
1
+ module ActiveSupport
2
+ class TestCase
3
+ # Check that 'count' number of 'image's is in a 'section' of css, set flag to check that it/they isn't/arn't
4
+ def image_in_section(section, image, count, flag=true)
5
+ if flag
6
+ assert page.has_selector?(:css,"#{section} img[src$='/assets/#{image}']", count: count), "Error: #{count} #{image}(s) not found in #{section} !"
7
+ else
8
+ assert !page.has_selector?(:css,"#{section} img[src$='/assets/#{image}']", count: count), "Error: #{count} #{image}(s) found in #{section} !"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,23 @@
1
+ module ActiveSupport
2
+ class TestCase
3
+ # Check that the text 'content' is on the page, set flag to check that it isn't
4
+ def text_in_page(content, flag=true)
5
+ if flag
6
+ assert page.has_content?("#{content}"), "Error: #{content} not found page !"
7
+ else
8
+ assert !page.has_content?("#{content}"), "Error: #{content} found in page !"
9
+ end
10
+ end
11
+
12
+ # Check that the text 'content' is within a particular css section, set flag to check that it isn't
13
+ def text_in_section(section, content, flag=true)
14
+ within("#{section}") do
15
+ if flag
16
+ assert page.has_content?("#{content}"), "Error: #{content} not found in #{section} !"
17
+ else
18
+ assert !page.has_content?("#{content}"), "Error: #{content} found in #{section} !"
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module PageRight
2
+ VERSION = "0.4"
3
+ end
data/lib/page_right.rb CHANGED
@@ -1,56 +1,14 @@
1
- require 'capybara'
2
- require 'active_support'
3
-
4
- module ActiveSupport
5
- class TestCase
6
-
7
- # Check that the text 'content' is on the page, set flag to check that it isn't
8
- def text_in_page(content, flag=true)
9
- if flag
10
- assert page.has_content?("#{content}"), "Error: #{content} not found page !"
11
- else
12
- assert !page.has_content?("#{content}"), "Error: #{content} found in page !"
13
- end
14
- end
15
-
16
- # Check that the text 'content' is within a particular css section, set flag to check that it isn't
17
- def text_in_section(section, content, flag=true)
18
- within("#{section}") do
19
- if flag
20
- assert page.has_content?("#{content}"), "Error: #{content} not found in #{section} !"
21
- else
22
- assert !page.has_content?("#{content}"), "Error: #{content} found in #{section} !"
23
- end
24
- end
25
- end
26
-
27
- # Check that a css element is on the page, set flag to check that it isn't
28
- def css_in_page(css, flag=true)
29
- if flag
30
- assert page.has_css?("#{css}"), "Error: #{css} not found on page !"
31
- else
32
- assert !page.has_css?("#{css}"), "Error: #{css} found on page !"
33
- end
34
- end
35
-
36
- # Check that a css element is nested within another css element, set flag to check that it isn't
37
- def css_in_section(css1, css2, flag=true)
38
- within("#{css1}") do
39
- if flag
40
- assert page.has_css?("#{css2}"), "Error: #{css2} not found in #{css1} !"
41
- else
42
- assert !page.has_css?("#{css2}"), "Error: #{css2} found in #{css1} !"
43
- end
44
- end
45
- end
46
-
47
- # Check that 'count' number of 'image's is in a 'section' of css, set flag to check that it/they isn't/arn't
48
- def image_in_section(section, image, count, flag=true)
49
- if flag
50
- assert page.has_selector?(:css,"#{section} img[src$='/assets/#{image}']", count: count), "Error: #{count} #{image}(s) not found in #{section} !"
51
- else
52
- assert !page.has_selector?(:css,"#{section} img[src$='/assets/#{image}']", count: count), "Error: #{count} #{image}(s) found in #{section} !"
53
- end
54
- end
55
- end
1
+ require "page_right/version"
2
+ require "page_right/css_checker"
3
+ require "page_right/image_checker"
4
+ require "page_right/text_checker"
5
+
6
+ begin
7
+ require 'pry'
8
+ rescue LoadError
9
+ end
10
+
11
+ module PageRight
12
+ # Your code goes here...
13
+ # binding.pry
56
14
  end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'page_right/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "page_right"
8
+ spec.version = PageRight::VERSION
9
+ spec.authors = ["Dave Collier"]
10
+ spec.email = ["lardelbow@gmail.com"]
11
+ spec.summary = 'A simple gem that helps you with testing the contents of a rendered web page'
12
+ spec.description = 'A simple gem that helps you with testing the contents of a rendered web page. Currently in development.'
13
+ spec.homepage = "https://github.com/lardelbow/page_right"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest", "~> 5.4"
24
+ spec.add_development_dependency "pry", "~> 0.10"
25
+ spec.add_development_dependency "pry-doc", "~> 0.6"
26
+ end
@@ -0,0 +1,3 @@
1
+ require 'page_right'
2
+ require 'minitest/autorun'
3
+ require 'minitest/pride'
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class TestSetup < Minitest::Test
4
+ def test_my_setup
5
+ assert_equal 1, 1, "1=1 is a simple test"
6
+ end
7
+ end
metadata CHANGED
@@ -1,23 +1,107 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_right
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Collier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-18 00:00:00.000000000 Z
12
- dependencies: []
13
- description: A simple gem that provides wrapper/helper methods ontop of capybara to
14
- test the contents of your page. Currently in development!
15
- email: lardelbow@gmail.com
11
+ date: 2014-11-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-doc
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.6'
83
+ description: A simple gem that helps you with testing the contents of a rendered web
84
+ page. Currently in development.
85
+ email:
86
+ - lardelbow@gmail.com
16
87
  executables: []
17
88
  extensions: []
18
89
  extra_rdoc_files: []
19
90
  files:
91
+ - ".gitignore"
92
+ - CHANGES.md
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
20
97
  - lib/page_right.rb
98
+ - lib/page_right/css_checker.rb
99
+ - lib/page_right/image_checker.rb
100
+ - lib/page_right/text_checker.rb
101
+ - lib/page_right/version.rb
102
+ - page_right.gemspec
103
+ - test/test_helper.rb
104
+ - test/test_setup_test.rb
21
105
  homepage: https://github.com/lardelbow/page_right
22
106
  licenses:
23
107
  - MIT
@@ -42,4 +126,7 @@ rubygems_version: 2.2.2
42
126
  signing_key:
43
127
  specification_version: 4
44
128
  summary: A simple gem that helps you with testing the contents of a rendered web page
45
- test_files: []
129
+ test_files:
130
+ - test/test_helper.rb
131
+ - test/test_setup_test.rb
132
+ has_rdoc: