generic_test 0.1.12 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5511c72398002fc4468de6f4e1e6a3f8c27783fd2cbeef28decae9a833698f57
4
- data.tar.gz: 4aaad3513df4be30725c97ac25fd07bc052bc90dac9b7270d286c1f5ce017090
3
+ metadata.gz: a5dc87e6158431181b42b3d8775d112382c54617cb5f519657064bb21650a5ac
4
+ data.tar.gz: 9662978df60eb50b37033056dca365c192e7891a5546159a3d4e34e6a62b6911
5
5
  SHA512:
6
- metadata.gz: 4848379d61b1064629f36ca3861759a564ee2fe4d156afb235c6a1eddce86dfd14b05980b6d45dec81b46404d5ce27b81a78fe2f25372ac2040bc5ac480283fe
7
- data.tar.gz: 5c92f007d44d6bcfc74113c091c2fab49a1266c1eef09b093220660eeb2d3db34424f3663f0b752e3c01660df1b8699459954aac88e21e013cf84916f8717370
6
+ metadata.gz: b079ecf7d4f14cd88d64766ed3e49f34052ee349951fdce2c9ec5785e601e8d43c826daaa87f7f693e94c7480b8bfa3d04f5649ce9fbad44793b88a13ce39f52
7
+ data.tar.gz: 22192bdb59c6563dc8228292328f6a3838476143fbc8753569f3cab00c647d2bc7d326133a82330ce8a31084009f78d4ba0033d4dca921c7d73f51f408f79364
data/.gitlab-ci.yml CHANGED
@@ -1,4 +1,4 @@
1
- image: ruby:2.6
1
+ image: ruby:3.3
2
2
 
3
3
  include:
4
4
  - template: Code-Quality.gitlab-ci.yml
@@ -8,16 +8,22 @@ docker_build:
8
8
  # Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
9
9
  DOCKER_HOST: tcp://docker:2376
10
10
  DOCKER_TLS_CERTDIR: "/certs"
11
- stage: deploy # Part of a later stage
11
+ stage: test # Part of a later stage
12
12
  services:
13
- - docker:19.03.5-dind
14
- image: docker:19.03.5
13
+ - docker:20.10.11-dind
14
+ image: docker:20.10.11
15
15
  script:
16
16
  - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
17
17
  - docker pull --quiet $CI_REGISTRY_IMAGE:latest || true
18
18
  - docker build -t $CI_REGISTRY_IMAGE:latest .
19
19
  - docker run -t $CI_REGISTRY_IMAGE:latest generic_test page samuel-garratt.gitlab.io/generic_test/about.html
20
20
  - docker push $CI_REGISTRY_IMAGE:latest
21
+ # only:
22
+ # - master
23
+ # needs: ["test"]
24
+ except:
25
+ changes:
26
+ - "*.md"
21
27
 
22
28
  test:
23
29
  image: registry.gitlab.com/samuel-garratt/generic_test
@@ -34,6 +40,23 @@ test:
34
40
  expire_in: 1 week
35
41
  when: always
36
42
 
43
+ # Example of using generic test
44
+ example_test:
45
+ stage: test
46
+ image: registry.gitlab.com/samuel-garratt/generic_test
47
+ script:
48
+ - generic_test page samuel-garratt.gitlab.io/generic_test/about.html
49
+ variables:
50
+ GIT_STRATEGY: none
51
+ artifacts:
52
+ paths:
53
+ - logs/*.xml
54
+ - reports
55
+ reports:
56
+ junit: logs/*.xml
57
+ expire_in: 1 week
58
+ when: always
59
+
37
60
  pages:
38
61
  stage: deploy
39
62
  script:
@@ -51,4 +74,4 @@ pages:
51
74
  image: docker:19.03.5
52
75
  stage: test
53
76
  script:
54
- - docker run myrepo/generic_test BASE_URL
77
+ - docker run myrepo/generic_test BASE_URL
data/.rspec CHANGED
@@ -1,5 +1,5 @@
1
1
  --format documentation
2
+ --format html --out report.html
2
3
  --color
3
4
  --require spec_helper
4
5
  --format RspecJunitFormatter --out logs/page_<%= ENV['PAGE_URL'].split('://').last.tr('/', '_') %>.xml
5
- --format RspecHtmlReporter
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ Version 0.1.13
2
+ * Enhancement
3
+ * Fail if cannot find url of page provided
4
+ * Ignore checking duplicate links
5
+
1
6
  Version 0.1.12
2
7
  * Enhancement
3
8
  * More generic matching of username labels allowing any case to be used
data/Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
- FROM ruby:2.6
2
- MAINTAINER Samuel Garratt
1
+ FROM ruby:3.3
2
+ LABEL AUTHOR=SamuelGarratt
3
3
 
4
4
  # Required ruby gems
5
5
  RUN mkdir /test
@@ -21,4 +21,6 @@ RUN export LANG=C.UTF-8
21
21
  RUN export LANGUAGE=C.UTF-8
22
22
  RUN export LC_ALL=C.UTF-8
23
23
  # By running test image is checked and webdriver will be cached
24
- RUN generic_test page samuel-garratt.gitlab.io/generic_test/about.html
24
+ RUN generic_test page samuel-garratt.gitlab.io/generic_test/about.html
25
+
26
+ ENTRYPOINT ["generic_test", "page"]
data/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  This gem provides an easy way to run generic tests for a website/api
4
4
 
5
- Test site is at https://samuel-garratt.gitlab.io/generic_test
5
+ Test site is at [https://samuel-garratt.gitlab.io/generic_test](https://samuel-garratt.gitlab.io/generic_test)
6
+
7
+ ## Quick start
6
8
 
7
9
  Run test gem through docker against this website with (Note it is an example that has some failures)
8
10
 
@@ -14,6 +16,27 @@ To get a log of your tests share a volume with the container.
14
16
 
15
17
  > Please share this volume from an empty folder. Running from within another gem might cause an issue
16
18
 
19
+ ## Add to gitlab CI for your website
20
+
21
+ Add the following `YAML` to test against a website
22
+ ```yaml
23
+ example_test:
24
+ stage: test
25
+ image: registry.gitlab.com/samuel-garratt/generic_test
26
+ script:
27
+ - generic_test page YOUR_WEBSITE_URL
28
+ variables:
29
+ GIT_STRATEGY: none # Make more efficient and remove any dependency conflicts
30
+ artifacts:
31
+ paths:
32
+ - logs/*.xml
33
+ - reports # HTML reports
34
+ reports:
35
+ junit: logs/*.xml
36
+ expire_in: 1 week
37
+ when: always
38
+ ```
39
+
17
40
  ## Installation
18
41
 
19
42
  Add this line to your application's Gemfile:
@@ -48,6 +71,10 @@ E.g.,
48
71
 
49
72
  `docker run -t registry.gitlab.com/samuel-garratt/generic_test generic_test page samuel-garratt.gitlab.io/generic_test`
50
73
 
74
+ Check version
75
+
76
+ `docker run -t registry.gitlab.com/samuel-garratt/generic_test generic_test version`
77
+
51
78
  ### Through login page
52
79
 
53
80
  Environment variables store Login URL, username and password
@@ -78,11 +105,17 @@ login:
78
105
 
79
106
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
80
107
 
81
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
108
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update
109
+ the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for
110
+ the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
111
+
112
+ The pipeline running on master will deploy a new version of the docker container with the latest version released
113
+ to rubygems.org. Therefore a `rake release` is required before any changes will be reflected in the newly built
114
+ docker container.
82
115
 
83
116
  ## Contributing
84
117
 
85
- Bug reports and pull requests are welcome on GitHub at https://gitlab.com/samuel-garratt/generic_test. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/generic_test/blob/master/CODE_OF_CONDUCT.md).
118
+ Bug reports and pull requests are welcome on GitLab at https://gitlab.com/samuel-garratt/generic_test. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://gitlab.com/samuel-garratt/generic_test/-/blob/master/CODE_OF_CONDUCT.md).
86
119
 
87
120
  ## License
88
121
 
data/generic_test.gemspec CHANGED
@@ -29,7 +29,8 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'jekyll' # For hosting test website
30
30
  spec.add_development_dependency 'rake'
31
31
  spec.add_dependency 'rspec-legacy_formatters' # Needed for rspec_html_reporter after RSpec 3
32
- spec.add_dependency 'rspec_html_reporter' # Pretty HTML reports
32
+ # This doesn't work with latest Ruby version
33
+ #spec.add_dependency 'rspec_html_reporter' # Pretty HTML reports
33
34
  spec.add_dependency 'rspec_junit_formatter' # Needed for nicer reporting of rspec for use in CI
34
35
  spec.add_dependency 'simplecov' # Code coverage
35
36
 
@@ -34,6 +34,8 @@ if ENV[GT_LOGIN_URL] && ENV[GT_USERNAME] && ENV[GT_PASSWORD]
34
34
  puts "Login through #{ENV[GT_LOGIN_URL]} successful!"
35
35
  end
36
36
 
37
+ ENV['PAGE_URL'] = RestClient.get(ENV['PAGE_URL']).request.url # Check page exists
38
+ puts "Checking #{ENV['PAGE_URL']}"
37
39
  browser.goto ENV['PAGE_URL']
38
40
  sleep 2.5 # Give a bit of time for page to load
39
41
  GenericTest.pages << GenericTest::Page.new(browser)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GenericTest
4
- VERSION = '0.1.12'
4
+ VERSION = '0.2.0'
5
5
  end
data/lib/generic_test.rb CHANGED
@@ -15,9 +15,11 @@ module GenericTest
15
15
  # browser so less likely to be accurate for logged in pages
16
16
  @only_javascript = false
17
17
 
18
+ @tested_links = []
18
19
  class << self
19
20
  attr_accessor :browser
20
21
  attr_accessor :pages
22
+ attr_accessor :tested_links
21
23
  attr_accessor :only_javascript
22
24
  end
23
25
  end
@@ -7,10 +7,14 @@ links = page.links
7
7
  RSpec.describe "#{page.title} Links respond" do
8
8
  links.each_with_index do |link, index|
9
9
  link_text = link.text.to_s.empty? ? '' : " \"#{link.text}\""
10
+ next if GenericTest.tested_links.include? link.href
11
+
12
+ GenericTest.tested_links << link.href
10
13
  it "Link (#{index + 1})#{link_text} to '#{link.href}' succeeds" do
11
14
  expect(Checker.link_status(link.href)).to be_between 200, 399
12
15
  end
13
16
  end
17
+ puts "Checking #{GenericTest.tested_links.count} non duplicate links"
14
18
  end
15
19
 
16
20
  emails = page.emails
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: generic_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Garratt
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-26 00:00:00.000000000 Z
11
+ date: 2024-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec_html_reporter
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rspec_junit_formatter
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -250,7 +236,7 @@ metadata:
250
236
  homepage_uri: https://gitlab.com/samuel-garratt/generic_test
251
237
  source_code_uri: https://gitlab.com/samuel-garratt/generic_test
252
238
  changelog_uri: https://gitlab.com/samuel-garratt/generic_test/blob/master/ChangeLog
253
- post_install_message:
239
+ post_install_message:
254
240
  rdoc_options: []
255
241
  require_paths:
256
242
  - lib
@@ -265,8 +251,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
251
  - !ruby/object:Gem::Version
266
252
  version: '0'
267
253
  requirements: []
268
- rubygems_version: 3.0.6
269
- signing_key:
254
+ rubygems_version: 3.2.3
255
+ signing_key:
270
256
  specification_version: 4
271
257
  summary: Generic tests for a website/api.
272
258
  test_files: []