lita-ghost-inspector 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dffcfa679f33db1583890609714e602901a3d302
4
+ data.tar.gz: 8e9b7340b38ab66dbc9bbcbd488eb8ad64acb154
5
+ SHA512:
6
+ metadata.gz: c6c4d00f6fa2fb2f6289bdda63c7aeaed6764729f4428208a1a44d03187dfe3d9efaf121fa4c9cfff3341ef7a00097f61f241e2527ec871a87f6303db1600beb
7
+ data.tar.gz: 00eec699ddb3b2bfbec8b2ff360787f8d8b734f5919ee6bec1082282b39fc8d266dc72a0f21788cdb6b2442f0826a0f4b7320467ff1fe1d4ac129075450eef90
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor/bundle
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,19 @@
1
+ # lita-ghost-inspector
2
+
3
+ TODO: Add a description of the plugin.
4
+
5
+ ## Installation
6
+
7
+ Add lita-ghost-inspector to your Lita instance's Gemfile:
8
+
9
+ ``` ruby
10
+ gem "lita-ghost-inspector"
11
+ ```
12
+
13
+ ## Configuration
14
+
15
+ TODO: Describe any configuration attributes the plugin exposes.
16
+
17
+ ## Usage
18
+
19
+ TODO: Describe the plugin's features and how to use them.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,17 @@
1
+ require "lita"
2
+ require "json"
3
+ require "http"
4
+
5
+ Lita.load_locales Dir[File.expand_path(
6
+ File.join("..", "..", "locales", "*.yml"), __FILE__
7
+ )]
8
+
9
+ require "lita/handlers/ghost_inspector"
10
+ require "lita/handlers/ghost_inspector_results"
11
+ require "lita/handlers/ghost_inspector_suites"
12
+ require "lita/handlers/ghost_inspector_tests"
13
+
14
+ Lita::Handlers::GhostInspector.template_root File.expand_path(
15
+ File.join("..", "..", "templates"),
16
+ __FILE__
17
+ )
@@ -0,0 +1,28 @@
1
+ module LitaGhostInspector
2
+ module API
3
+ def gi_get(url, params={})
4
+ gi_api :get, url, params: merge_api_key(params)
5
+ end
6
+
7
+ def gi_api(action, url, *args)
8
+ JSON.parse(
9
+ HTTP.send(action, "https://api.ghostinspector.com/v1#{url}", *args).tap do |response|
10
+ unless response.to_s.start_with? '{"code":"SUCCESS"'
11
+ response = JSON.parse response
12
+ raise "GhostInspector API Error: #{response["errorType"]} #{response["message"]}"
13
+ end
14
+
15
+ unless response.code.to_s.match(/^[2|3]/)
16
+ raise "GhostInspector API Response Code #{response.code}"
17
+ end
18
+ end
19
+ )["data"]
20
+ end
21
+
22
+ protected
23
+
24
+ def merge_api_key(params)
25
+ { apiKey: config.api_key }.merge params
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ module LitaGhostInspector
2
+ module Config
3
+ def config
4
+ Lita.config.handlers.ghost_inspector
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ module LitaGhostInspector
2
+ module Utility
3
+ def seconds_to_human(seconds)
4
+ {
5
+ seconds => "every #{seconds} seconds",
6
+ 86400 => "daily",
7
+ 3600 => "hourly",
8
+ 1800 => "every 30 minutes",
9
+ 900 => "every 15 minutes",
10
+ 300 => "every 5 minutes",
11
+ 0 => "never"
12
+ }[seconds]
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ require 'lita-ghost-inspector/config'
2
+ require 'lita-ghost-inspector/api'
3
+ require 'lita-ghost-inspector/utility'
4
+
5
+ module Lita
6
+ module Handlers
7
+ class GhostInspector < Handler
8
+ include LitaGhostInspector::Config
9
+
10
+ config :api_key, required: true
11
+
12
+ Lita.register_handler(self)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ require 'lita-ghost-inspector/config'
2
+ require 'lita-ghost-inspector/api'
3
+ require 'lita-ghost-inspector/utility'
4
+
5
+ module Lita
6
+ module Handlers
7
+ class GhostInspectorResults < Handler
8
+ include LitaGhostInspector::Config
9
+ # insert handler code here
10
+
11
+ Lita.register_handler(self)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,66 @@
1
+ require 'lita-ghost-inspector/config'
2
+ require 'lita-ghost-inspector/api'
3
+ require 'lita-ghost-inspector/utility'
4
+
5
+ module Lita
6
+ module Handlers
7
+ class GhostInspectorSuites < Handler
8
+ include LitaGhostInspector::Config
9
+ include LitaGhostInspector::API
10
+ include LitaGhostInspector::Utility
11
+
12
+ route(/^gi suites list$/, :list, command: true, help: {
13
+ "gi suites list" => "Lists GhostInspector Suites"
14
+ })
15
+
16
+ def list(response)
17
+ suites_response = suites.map{ |suite| "#{suite["name"]} - #{suite["testCount"]} tests" }
18
+ response.reply suites_response.join "\n"
19
+ end
20
+
21
+ route(/^gi suites execute\s(.+)/, :execute, command: true, help: {
22
+ "gi suites execute robot overlords" => "Executes a GhostInspector Suite by name"
23
+ })
24
+
25
+ def execute(response)
26
+ suite_name = response.matches[0][0]
27
+ suite_id = suite_id_by_name suite_name
28
+ execute_response = gi_get "/suites/#{suite_id}/execute", immediate: true
29
+ if execute_response == {}
30
+ response.reply "Started #{suite_name} suite..."
31
+ end
32
+ end
33
+
34
+ route(/^gi suites list tests\s(.+)/, :list_tests, command: true, help: {
35
+ "gi suites list tests robot overlords" => "Lists tests for a GhostInspector Suite by name"
36
+ })
37
+
38
+ def list_tests(response)
39
+ suite_name = response.matches[0][0]
40
+ suite_id = suite_id_by_name suite_name
41
+ tests = gi_get "/suites/#{suite_id}/tests"
42
+ tests_response = tests.map{ |test|
43
+ "#{test["name"]} - " +
44
+ "#{test["passing"] ? "Passing" : "*Not passing*"}" +
45
+ " with screenshot " +
46
+ "#{test["screenshotComparePassing"] ? "passing" : "*not passing*"}" +
47
+ ". " +
48
+ "Runs #{seconds_to_human test["testFrequency"]}. "
49
+ }
50
+ response.reply tests_response.join "\n"
51
+ end
52
+
53
+ Lita.register_handler(self)
54
+
55
+ private
56
+
57
+ def suites
58
+ @suites ||= gi_get "/suites"
59
+ end
60
+
61
+ def suite_id_by_name(suite_name)
62
+ suites.find{|suite| suite["name"] == suite_name }&.[]("_id")
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,68 @@
1
+ require 'lita-ghost-inspector/config'
2
+ require 'lita-ghost-inspector/api'
3
+ require 'lita-ghost-inspector/utility'
4
+
5
+ module Lita
6
+ module Handlers
7
+ class GhostInspectorTests < Handler
8
+ include LitaGhostInspector::Config
9
+ include LitaGhostInspector::API
10
+ include LitaGhostInspector::Utility
11
+
12
+ route(/^gi tests list$/, :list, command: true, help: {
13
+ "gi tests list" => "Lists GhostInspector Tests"
14
+ })
15
+
16
+ def list(response)
17
+ tests = gi_get "/tests"
18
+ tests_response = tests.map{ |test|
19
+ "`#{test["_id"]}` - " +
20
+ "#{test["name"]} - " +
21
+ "#{test["passing"] ? "Passing" : "*Not passing*"}" +
22
+ " with screenshot " +
23
+ "#{test["screenshotComparePassing"] ? "passing" : "*not passing*"}" +
24
+ ". " +
25
+ "Runs #{seconds_to_human test["testFrequency"]}. "
26
+ }
27
+ response.reply tests_response.join "\n"
28
+ end
29
+
30
+ route(/^gi tests execute\s(.+)/, :execute, command: true, help: {
31
+ "gi tests execute robot dance" => "Executes a GhostInspector test by partial name match or id"
32
+ })
33
+
34
+ def execute(response)
35
+ test_name = response.matches[0][0]
36
+ test_ids = test_ids_by_name test_name
37
+ test_ids = [test_name] unless test_ids.any?
38
+ execute_response = test_ids.map do |test_id|
39
+ execute_response = gi_get "/tests/#{test_id}/execute", immediate: true
40
+ if execute_response == {}
41
+ test = test(test_id) || test(test_ids_by_name(test_id)[0])
42
+ "#{test["name"]} (#{test["_id"]})"
43
+ end
44
+ end.join ", "
45
+
46
+ response.reply "Started #{execute_response}..."
47
+ rescue Exception => e
48
+ response.reply "GhostInspector Test Execute failed: #{e}"
49
+ end
50
+
51
+ Lita.register_handler(self)
52
+
53
+ private
54
+
55
+ def test(id)
56
+ tests.find{|test| test["_id"] == id }
57
+ end
58
+
59
+ def tests
60
+ @tests ||= gi_get "/tests"
61
+ end
62
+
63
+ def test_ids_by_name(test_name)
64
+ tests.select{|test| test["name"].match test_name }.map{|h| h["_id"]}
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "lita-ghost-inspector"
3
+ spec.version = "0.1.0"
4
+ spec.authors = ["Eric Boehs"]
5
+ spec.email = ["ericboehs@gmail.com"]
6
+ spec.description = "Query and Run tests on Ghost Inspector"
7
+ spec.summary = "Query and Run tests on Ghost Inspector"
8
+ spec.homepage = "https://github.com/ericboehs/lita-ghost-inspector"
9
+ spec.license = "MIT"
10
+ spec.metadata = { "lita_plugin_type" => "handler" }
11
+
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_runtime_dependency "lita", ">= 4.7"
18
+ spec.add_runtime_dependency "http", "~> 1.0"
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "pry"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rack-test"
24
+ spec.add_development_dependency "rspec", ">= 3.0.0"
25
+ end
@@ -0,0 +1,4 @@
1
+ en:
2
+ lita:
3
+ handlers:
4
+ ghost_inspector:
@@ -0,0 +1,4 @@
1
+ require "spec_helper"
2
+
3
+ describe Lita::Handlers::GhostInspector, lita_handler: true do
4
+ end
@@ -0,0 +1,6 @@
1
+ require "lita-ghost-inspector"
2
+ require "lita/rspec"
3
+
4
+ # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
5
+ # was generated with Lita 4, the compatibility mode should be left disabled.
6
+ Lita.version_3_compatibility_mode = false
File without changes
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-ghost-inspector
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Eric Boehs
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lita
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: http
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
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'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
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
+ - !ruby/object:Gem::Dependency
84
+ name: rack-test
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.0
111
+ description: Query and Run tests on Ghost Inspector
112
+ email:
113
+ - ericboehs@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - Gemfile
120
+ - README.md
121
+ - Rakefile
122
+ - lib/lita-ghost-inspector.rb
123
+ - lib/lita-ghost-inspector/api.rb
124
+ - lib/lita-ghost-inspector/config.rb
125
+ - lib/lita-ghost-inspector/utility.rb
126
+ - lib/lita/handlers/ghost_inspector.rb
127
+ - lib/lita/handlers/ghost_inspector_results.rb
128
+ - lib/lita/handlers/ghost_inspector_suites.rb
129
+ - lib/lita/handlers/ghost_inspector_tests.rb
130
+ - lita-ghost-inspector.gemspec
131
+ - locales/en.yml
132
+ - spec/lita/handlers/ghost_inspector_spec.rb
133
+ - spec/spec_helper.rb
134
+ - templates/.gitkeep
135
+ homepage: https://github.com/ericboehs/lita-ghost-inspector
136
+ licenses:
137
+ - MIT
138
+ metadata:
139
+ lita_plugin_type: handler
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.5.1
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: Query and Run tests on Ghost Inspector
160
+ test_files:
161
+ - spec/lita/handlers/ghost_inspector_spec.rb
162
+ - spec/spec_helper.rb