page_right 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/page-right.rb +56 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7892574b0b328479b14528df9b27f61c6730d7e8
4
+ data.tar.gz: fc3fa9ebc67e947558d7c376eb7d9807b6d4fd8e
5
+ SHA512:
6
+ metadata.gz: 40be684a6f5536aedf0826b781bc8c007d83e69ebf9f94b6c952e3d260719929a18c245b832ca0213dc0a1c4a68879789f3d1c095f1db9d59f79fcf7e5d6f04d
7
+ data.tar.gz: ca37872b57dfe744e0365d9edf7497cc2b9123736c24bc9838b798d504aac273ed7e679a8a8ddcd22bb31fb6e62997d72b333cce269bb52cdd2654791a796e0d
data/lib/page-right.rb ADDED
@@ -0,0 +1,56 @@
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
56
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: page_right
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.2'
5
+ platform: ruby
6
+ authors:
7
+ - Dave Collier
8
+ autorequire:
9
+ bindir: bin
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
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/page-right.rb
21
+ homepage: https://github.com/lardelbow/page-right
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.2.2
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: A simple gem that helps you with testing the contents of a rendered web page
45
+ test_files: []