capistrano-ghostinspector 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cc04965ad83dd32a46922bb4945d37f6523c591b
4
+ data.tar.gz: ee6edf4ae49d651e917393b5c0e9570cd612c48b
5
+ SHA512:
6
+ metadata.gz: 1c56e3ac17840978f33e429ec681291e1287ac34b6a7a08cc2daaa3f91b2fe6a2abcf20e1b71a41600937c4bdf246d1f615f363168377683bcf19f956c2fd5d4
7
+ data.tar.gz: d90f5869f9c89757f6f69d2a5e9286484210b7f0230d2829bf0db76c29732589dd11521b62d0a5548d82bec370f2753fa5382a7ebdffa27d2bb4990159a73b49
@@ -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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-ghostinspector.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Steven Richardson
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.
@@ -0,0 +1,98 @@
1
+ # Capistrano::Ghostinspector
2
+
3
+ [![Scrutinizer Code Quality](https://www2.scrutinizer-ci.com/g/richdynamix/capistrano-ghostinspector/badges/quality-score.png?b=develop)](https://www2.scrutinizer-ci.com/g/richdynamix/capistrano-ghostinspector/?branch=develop) [![Build Status](https://www2.scrutinizer-ci.com/g/richdynamix/capistrano-ghostinspector/badges/build.png?b=develop)](https://www2.scrutinizer-ci.com/g/richdynamix/capistrano-ghostinspector/build-status/develop)
4
+
5
+
6
+ [Ghost Inspector](https://ghostinspector.com/ "Ghost Inspector") is an automated website regression testing tool. This [Capistrano](http://capistranorb.com/ "Capistrano") plugin is a simple, configurable gem that will provide the following features.
7
+
8
+
9
+ #### Features
10
+ - Set individual tests/suites to run from command line
11
+ - Exclude individual stages
12
+ - Auto rollback to previous version on failed tests (can be disabled in config per stage)
13
+ - Auto configure start URL to reuse tests across multiple stages
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'capistrano-ghostinspector'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install capistrano-ghostinspector
30
+
31
+ And the add the following to the top of your `deploy.rb` file
32
+
33
+ ```ruby
34
+ require 'capistrano/ghostinspector'
35
+ ```
36
+
37
+ ## Configuration
38
+
39
+ First thing you need to do is create your `YAML` file (`gi_config.yaml`) in the Capistrano folder with the following format -
40
+ ```
41
+ ---
42
+ APIKEY: XXXXXXXXXXXXXXXXXXX
43
+ gi_enabled: true
44
+ rollback: true
45
+ suites:
46
+ aboutpage: "XXXXXXXXXXXXXXXXXXX"
47
+ suite2: ""
48
+ tests:
49
+ homepage: "XXXXXXXXXXXXXXXXXXX"
50
+ test2: ""
51
+ test3: ""
52
+ ```
53
+
54
+ You can obtain your API key, suite ID and test ID from your Ghost Inspector console. At the bottom right of the suite page you will see API Access e.g.
55
+ `https://api.ghostinspector.com/v1/suites/`SUITE ID IS HERE`/execute/?apiKey=`API KEY ID IS HERE
56
+
57
+ Add as many suites or tests as you like, the name you give your test isn't important but you should make it easy to remember when executing the test.
58
+
59
+ By default the ghost inspector execution is enabled, you can disabled this for all stages by setting `gi_enabled: false` in the `YAML` file. Alternatively you can change this on a per stage basis by setting the appropriate variable
60
+ ```ruby
61
+ set :gi_enabled, false
62
+ ```
63
+ This ensures that Ghost Inspector is not automatically run when accidentally triggered via the command line.
64
+
65
+ By default the `rollback` feature is enabled, you can disabled this for all stages by setting `rollback: false` in the `YAML` file. Alternatively you can change this on a per stage basis by setting the appropriate variable
66
+ ```ruby
67
+ set :rollback, false
68
+ ```
69
+
70
+ ## Usage
71
+
72
+ Run a particular test when deploying to staging -
73
+
74
+ $ cap staging deploy -s gitest=homepage
75
+
76
+
77
+ Run a multiple tests when deploying to staging -
78
+
79
+ $ cap staging deploy -s gitest=homepage,test2,test3
80
+
81
+
82
+ Run a particular suite when deploying to staging -
83
+
84
+ $ cap staging deploy -s gisuite=aboutpage
85
+
86
+
87
+ Run a multiple suites when deploying to staging -
88
+
89
+ $ cap staging deploy -s gisuite=aboutpage,suite2
90
+
91
+
92
+ ## Contributing
93
+
94
+ 1. Fork it ( https://github.com/richdynamix/capistrano-ghostinspector/fork )
95
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
96
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
97
+ 4. Push to the branch (`git push origin my-new-feature`)
98
+ 5. Create a new Pull Request
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ Dir.glob('tasks/**/*.rake').each(&method(:import))
@@ -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 'capistrano/ghostinspector/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-ghostinspector"
8
+ spec.version = Capistrano::Ghostinspector::VERSION
9
+ spec.authors = ["Steven Richardson"]
10
+ spec.email = ["steven@richdynamix.com"]
11
+ spec.summary = "Ghost Inspector - Capistrano"
12
+ spec.description = "A Ghost Inspector plugin for Capistrano"
13
+ spec.homepage = 'http://rubygems.org/gems/capistrano-ghostinspector'
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 'rspec'
24
+ spec.add_development_dependency 'capistrano', "~> 2.15.5"
25
+ spec.add_development_dependency 'capistrano-spec'
26
+ end
@@ -0,0 +1,66 @@
1
+ require "capistrano/ghostinspector/version"
2
+ require "capistrano/ghostinspector/arrays"
3
+ require "capistrano/ghostinspector/api"
4
+ require "capistrano"
5
+
6
+ module Capistrano
7
+ module Ghostinspector
8
+ def self.load_into(config)
9
+ config.load do
10
+ after "deploy", "capistrano:ghostinspector:run"
11
+
12
+ namespace :capistrano do
13
+ namespace :ghostinspector do
14
+ task :run, :only => { :primary => true } do
15
+
16
+ set :giconfig = YAML::load(File.read("gi_config.yaml"))
17
+
18
+ set :gi_api_key, giconfig["APIKEY"]
19
+
20
+ # Get tests and suites from command line
21
+ set :gitest, fetch(:gitest, nil)
22
+ set :gisuite, fetch(:gisuite, nil)
23
+
24
+ # Check if GI is enabled for this deployment (Default: true)
25
+ set :gi_enabled, fetch(:gi_enabled, giconfig["gi_enabled"])
26
+
27
+ # Should we rollback on failed GI tests (Default: true)
28
+ set :rollback, fetch(:rollback, giconfig["rollback"])
29
+
30
+ if (gi_enabled == true)
31
+
32
+ # run each test
33
+ Capistrano::Ghostinspector.getTests(gitest, giconfig["tests"]).each do |test|
34
+ puts "* * * Running Ghost Inspector Test * * *"
35
+ set :passing, Capistrano::Ghostinspector.executeApi("tests", test, gi_api_key, domain, rollback)
36
+ end
37
+
38
+ # run each suite
39
+ Capistrano::Ghostinspector.getTests(gisuite, giconfig["suites"]).each do |suite|
40
+ puts "* * * Running Ghost Inspector Suite * * *"
41
+ set :passing, Capistrano::Ghostinspector.executeApi("suites", suite, gi_api_key, domain, rollback)
42
+ end
43
+
44
+ # If any test fails and the stage allows rollbacks then
45
+ # rollback to previous version.
46
+ if (passing == false && rollback == true)
47
+ puts "* * * Ghost Inspector Failed. Rolling back * * *"
48
+ run_locally %{cap #{stage} deploy:rollback}
49
+ else
50
+ puts "* * * Ghost Inspector Complete. Deployment Complete * * *"
51
+ end
52
+
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+
64
+ if Capistrano::Configuration.instance
65
+ Capistrano::Ghostinspector.load_into(Capistrano::Configuration.instance)
66
+ end
@@ -0,0 +1,42 @@
1
+ require 'net/https'
2
+ require 'json'
3
+
4
+ module Capistrano
5
+ module Ghostinspector
6
+ def self.executeApi(type, test, gi_api_key, domain, rollback)
7
+
8
+ # Determine if we should get results to
9
+ # check for any failed tests
10
+ if (rollback == false)
11
+ immediate = "&immediate=1"
12
+ else
13
+ immediate = ""
14
+ puts "* * * Gathering results. This could take a few minutes. * * *"
15
+ end
16
+
17
+ # Default all tests pass
18
+ passing = true
19
+
20
+ # execute the Ghost Inspector API call
21
+ uri = URI("https://api.ghostinspector.com/v1/#{type}/#{test}/execute/?apiKey=#{gi_api_key}&startUrl=http://#{domain}/#{immediate}")
22
+ data = Net::HTTP.get(uri)
23
+
24
+ # Check the data returned for failed tests
25
+ if (rollback == true)
26
+ results = JSON.parse(data)
27
+
28
+ if (type == "suite")
29
+ results['data'].each do |testItem|
30
+ passing = testItem['passing']
31
+ end
32
+ else
33
+ passing = results['data']['passing']
34
+ end
35
+
36
+ end
37
+
38
+ return passing
39
+
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,20 @@
1
+ module Capistrano
2
+ module Ghostinspector
3
+ def self.getTests(test, giconfig)
4
+
5
+ # Return an array of tests/suites to
6
+ # run in ghost inspector
7
+ array = Array.new
8
+ if (test != nil)
9
+ test.split(',').each do |key|
10
+ if (giconfig.has_key?(key))
11
+ array << giconfig[key]
12
+ end
13
+ end
14
+ end
15
+
16
+ return array
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Ghostinspector
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Ghostinspector" do
4
+ before do
5
+ @configuration = Capistrano::Configuration.new
6
+ @configuration.extend(Capistrano::Spec::ConfigurationExtension)
7
+
8
+ Capistrano::Ghostinspector.load_into(@configuration)
9
+ end
10
+
11
+ subject { @configuration }
12
+
13
+ context "when running capistrano:ghostinspector:run" do
14
+ before do
15
+ @configuration.set :gitest, 'home'
16
+ end
17
+
18
+ it "it should define tests" do
19
+ @configuration.fetch(:gitest).should == 'home'
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+
26
+
27
+
28
+
29
+
30
+
31
+
@@ -0,0 +1,10 @@
1
+ require 'capistrano'
2
+
3
+ require 'capistrano-spec'
4
+ require 'rspec'
5
+
6
+ # Add capistrano-spec matchers and helpers to RSpec
7
+ RSpec.configure do |config|
8
+ config.include Capistrano::Spec::Matchers
9
+ config.include Capistrano::Spec::Helpers
10
+ end
@@ -0,0 +1,3 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec)
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-ghostinspector
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Steven Richardson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-17 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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: capistrano
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.15.5
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.15.5
69
+ - !ruby/object:Gem::Dependency
70
+ name: capistrano-spec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: A Ghost Inspector plugin for Capistrano
84
+ email:
85
+ - steven@richdynamix.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - capistrano-ghostinspector.gemspec
96
+ - lib/capistrano/ghostinspector.rb
97
+ - lib/capistrano/ghostinspector/api.rb
98
+ - lib/capistrano/ghostinspector/arrays.rb
99
+ - lib/capistrano/ghostinspector/version.rb
100
+ - spec/capistrano-ghostinspector_spec.rb
101
+ - spec/spec_helper.rb
102
+ - tasks/rspec.rake
103
+ homepage: http://rubygems.org/gems/capistrano-ghostinspector
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.4.5
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Ghost Inspector - Capistrano
127
+ test_files:
128
+ - spec/capistrano-ghostinspector_spec.rb
129
+ - spec/spec_helper.rb