quke_demo_app 0.1.1 → 0.2.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.
- checksums.yaml +4 -4
- data/bin/console +1 -1
- data/exe/quke_demo_app +2 -2
- data/lib/quke_demo_app.rb +9 -0
- data/lib/quke_demo_app/app.rb +77 -0
- data/lib/quke_demo_app/cli.rb +17 -0
- data/lib/quke_demo_app/concerns/can_have_search_results.rb +31 -0
- data/lib/{quke/demo_app → quke_demo_app}/public/assets/css/bootstrap.min.css +0 -0
- data/lib/{quke/demo_app → quke_demo_app}/public/assets/css/custom.css +0 -0
- data/lib/{quke/demo_app → quke_demo_app}/public/assets/css/ie10-viewport-bug-workaround.css +0 -0
- data/lib/{quke/demo_app → quke_demo_app}/public/assets/images/favicon.ico +0 -0
- data/lib/{quke/demo_app → quke_demo_app}/public/assets/images/quke.png +0 -0
- data/lib/{quke/demo_app → quke_demo_app}/public/assets/javascript/bootstrap.min.js +0 -0
- data/lib/{quke/demo_app → quke_demo_app}/public/assets/javascript/ie10-viewport-bug-workaround.js +0 -0
- data/lib/{quke/demo_app → quke_demo_app}/public/assets/javascript/jquery.min.js +0 -0
- data/lib/quke_demo_app/version.rb +5 -0
- data/lib/{quke/demo_app → quke_demo_app}/views/_partial_example.erb +0 -0
- data/lib/{quke/demo_app → quke_demo_app}/views/about.erb +0 -0
- data/lib/{quke/demo_app → quke_demo_app}/views/contact.erb +0 -0
- data/lib/{quke/demo_app → quke_demo_app}/views/css_selector.erb +0 -0
- data/lib/{quke/demo_app → quke_demo_app}/views/index.erb +0 -0
- data/lib/{quke/demo_app → quke_demo_app}/views/javascript_error.erb +0 -0
- data/lib/{quke/demo_app → quke_demo_app}/views/layout.erb +0 -0
- data/lib/{quke/demo_app → quke_demo_app}/views/radio_button.erb +0 -0
- data/lib/{quke/demo_app → quke_demo_app}/views/request.erb +0 -0
- data/lib/{quke/demo_app → quke_demo_app}/views/search.erb +0 -0
- data/spec/quke_demo_app/app_spec.rb +151 -0
- data/spec/quke_demo_app/cli_spec.rb +33 -0
- data/spec/{quke/demo_app_spec.rb → quke_demo_app_spec.rb} +3 -3
- data/spec/support/quke_demo_app.rb +1 -1
- metadata +31 -32
- data/lib/quke.rb +0 -7
- data/lib/quke/demo_app.rb +0 -11
- data/lib/quke/demo_app/app.rb +0 -79
- data/lib/quke/demo_app/cli.rb +0 -19
- data/lib/quke/demo_app/concerns/can_have_search_results.rb +0 -33
- data/lib/quke/demo_app/version.rb +0 -7
- data/spec/quke/demo_app/app_spec.rb +0 -153
- data/spec/quke/demo_app/cli_spec.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 559a330920d858658c3c69d768d24654c7c076a24cd78acfe849ff36f46e5b2c
|
4
|
+
data.tar.gz: 7d2e81a6001d9bf827e554aad9238bc3b3fc1040799ef6a9b741a64823824c2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 242170ba2eab636d88c8248c32fe673c3df87a78e9a66ad1ee76a8e15389585d08645b3c5a6efcf47c84651ffbf5c87d43960490926f8d7b4e3e9b0f7632c903
|
7
|
+
data.tar.gz: eeb6b3abaf2eec973dced9a79350354f17054201b1767a26e05fa2c949b9387e88faa4198e8e0a32755c2a51fcde1b0b2ffb5d12e2051627f82dfa8dd7cd10ce
|
data/bin/console
CHANGED
data/exe/quke_demo_app
CHANGED
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This stops the following Sinatra warning appearing when running the test suite
|
4
|
+
# or the app from bin/console (essentially any non-production environment)
|
5
|
+
#
|
6
|
+
# WARNING: If you plan to load any of ActiveSupport's core extensions to Hash,
|
7
|
+
# be sure to do so *before* loading Sinatra::Application or Sinatra::Base. If
|
8
|
+
# not, you may disregard this warning.
|
9
|
+
ENV["SINATRA_ACTIVESUPPORT_WARNING"] = "false"
|
10
|
+
|
11
|
+
require "sinatra/base"
|
12
|
+
|
13
|
+
module QukeDemoApp
|
14
|
+
class App < Sinatra::Base
|
15
|
+
include CanHaveSearchResults
|
16
|
+
|
17
|
+
get "/" do
|
18
|
+
@title = "Welcome to Quke"
|
19
|
+
erb :index
|
20
|
+
end
|
21
|
+
|
22
|
+
get "/about" do
|
23
|
+
@title = "About"
|
24
|
+
erb :about
|
25
|
+
end
|
26
|
+
|
27
|
+
get "/contact" do
|
28
|
+
@title = "Contact"
|
29
|
+
erb :contact
|
30
|
+
end
|
31
|
+
|
32
|
+
get "/cssselector" do
|
33
|
+
@title = "CSS selector"
|
34
|
+
erb :css_selector
|
35
|
+
end
|
36
|
+
|
37
|
+
get "/jserror" do
|
38
|
+
@title = "JavaScript error"
|
39
|
+
@results = "Open your browser's dev tools, specifically the JavaScript"\
|
40
|
+
"console. You should see an error!"
|
41
|
+
erb :javascript_error
|
42
|
+
end
|
43
|
+
|
44
|
+
get "/radiobutton" do
|
45
|
+
@title = "Radio button"
|
46
|
+
erb :radio_button
|
47
|
+
end
|
48
|
+
|
49
|
+
post "/radiobutton" do
|
50
|
+
@title = "Radio button"
|
51
|
+
@selection = params["enrollment"]["organisation_attributes"]["type"]
|
52
|
+
@result = @selection.match(/OrganisationType::([^"]*)/)[1]
|
53
|
+
|
54
|
+
erb :radio_button
|
55
|
+
end
|
56
|
+
|
57
|
+
get "/request" do
|
58
|
+
@title = "Request details"
|
59
|
+
@results = request.env
|
60
|
+
erb :request
|
61
|
+
end
|
62
|
+
|
63
|
+
get "/search" do
|
64
|
+
@title = "Search"
|
65
|
+
erb :search
|
66
|
+
end
|
67
|
+
|
68
|
+
post "/search" do
|
69
|
+
@title = "Search"
|
70
|
+
@query = params["search_input"]
|
71
|
+
|
72
|
+
@results = search_results if @query.casecmp("capybara").zero?
|
73
|
+
|
74
|
+
erb :search
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
module QukeDemoApp
|
6
|
+
class Cli < Thor
|
7
|
+
desc("execute", "Start the demo app running")
|
8
|
+
option(:port, aliases: "-p", desc: "Port to run the app on", default: "4567")
|
9
|
+
def execute
|
10
|
+
puts "Warming up the Quke Demo App. Hold on!"
|
11
|
+
QukeDemoApp::App.set(port: options[:port])
|
12
|
+
QukeDemoApp::App.run!
|
13
|
+
end
|
14
|
+
|
15
|
+
default_task :execute
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module QukeDemoApp
|
4
|
+
module CanHaveSearchResults
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def search_results
|
9
|
+
{
|
10
|
+
Capybara: "The capybara (Hydrochoerus hydrochaeris) is a large rodent "\
|
11
|
+
"of the genus Hydrochoerus of which the only other extant member is "\
|
12
|
+
"the lesser capybara (Hydrochoerus isthmius). The capybara is the "\
|
13
|
+
"largest rodent in the world. Close relatives are guinea pigs and "\
|
14
|
+
"rock cavies, and it is more distantly related to the agouti, "\
|
15
|
+
"chinchillas, and the coypu. Native to South America, the capybara "\
|
16
|
+
"inhabits savannas and dense forests and lives near bodies of water. "\
|
17
|
+
"It is a highly social species and can be found in groups as large as "\
|
18
|
+
"100 individuals, but usually lives in groups of 10-20 individuals. "\
|
19
|
+
"The capybara is not a threatened species and is hunted for its meat "\
|
20
|
+
"and hide and also for a grease from its thick fatty skin which is "\
|
21
|
+
"used in the pharmaceutical trade.",
|
22
|
+
Capybara_software: "Capybara is a web-based test automation "\
|
23
|
+
"software that simulates scenarios for user stories and automates "\
|
24
|
+
"web application testing for behavior-driven software "\
|
25
|
+
"development. It is a part of the Cucumber testing framework "\
|
26
|
+
"written in the Ruby programming language that simulates various "\
|
27
|
+
"aspects of a web browser from the perspective of a real user."
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/{quke/demo_app → quke_demo_app}/public/assets/javascript/ie10-viewport-bug-workaround.js
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,151 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
module QukeDemoApp
|
6
|
+
RSpec.describe App do
|
7
|
+
|
8
|
+
it "includes CanHaveSearchResults" do
|
9
|
+
included_modules = described_class.ancestors.select { |ancestor| ancestor.instance_of?(Module) }
|
10
|
+
|
11
|
+
expect(included_modules)
|
12
|
+
.to include(QukeDemoApp::CanHaveSearchResults)
|
13
|
+
end
|
14
|
+
|
15
|
+
context "/" do
|
16
|
+
it "GET displays the page" do
|
17
|
+
get "/"
|
18
|
+
|
19
|
+
expect(last_response.body).to include("Welcome to Quke")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "GET returns the status 200" do
|
23
|
+
get "/"
|
24
|
+
|
25
|
+
expect(last_response).to be_ok
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "/about" do
|
30
|
+
it "GET displays the page" do
|
31
|
+
get "/about"
|
32
|
+
|
33
|
+
expect(last_response.body).to include("The about page.")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "GET returns the status 200" do
|
37
|
+
get "/about"
|
38
|
+
|
39
|
+
expect(last_response).to be_ok
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "/contact" do
|
44
|
+
it "GET displays the page" do
|
45
|
+
get "/contact"
|
46
|
+
|
47
|
+
expect(last_response.body).to include("The contact page.")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "GET returns the status 200" do
|
51
|
+
get "/contact"
|
52
|
+
|
53
|
+
expect(last_response).to be_ok
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "/cssselector" do
|
58
|
+
it "GET displays the page" do
|
59
|
+
get "/cssselector"
|
60
|
+
|
61
|
+
expect(last_response.body).to include("rely on using CSS selectors to locate elements")
|
62
|
+
end
|
63
|
+
|
64
|
+
it "GET returns the status 200" do
|
65
|
+
get "/cssselector"
|
66
|
+
|
67
|
+
expect(last_response).to be_ok
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "/jserror" do
|
72
|
+
it "GET displays the page" do
|
73
|
+
get "/jserror"
|
74
|
+
|
75
|
+
expect(last_response.body).to include("page with a JavaScript error")
|
76
|
+
end
|
77
|
+
|
78
|
+
it "GET returns the status 200" do
|
79
|
+
get "/jserror"
|
80
|
+
|
81
|
+
expect(last_response).to be_ok
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "/request" do
|
86
|
+
it "GET displays the page" do
|
87
|
+
get "/request"
|
88
|
+
|
89
|
+
expect(last_response.body).to include("checking that the request")
|
90
|
+
end
|
91
|
+
|
92
|
+
it "GET returns the status 200" do
|
93
|
+
get "/request"
|
94
|
+
|
95
|
+
expect(last_response).to be_ok
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context "/radiobutton" do
|
100
|
+
it "GET displays the page" do
|
101
|
+
get "/radiobutton"
|
102
|
+
|
103
|
+
expect(last_response.body).to include("elements like radio buttons")
|
104
|
+
end
|
105
|
+
|
106
|
+
it "GET returns the status 200" do
|
107
|
+
get "/radiobutton"
|
108
|
+
|
109
|
+
expect(last_response).to be_ok
|
110
|
+
end
|
111
|
+
|
112
|
+
it "POST to the page displays selected option" do
|
113
|
+
post "/radiobutton", "enrollment[organisation_attributes][type]=WasteExemptionsShared::OrganisationType::Partnership"
|
114
|
+
|
115
|
+
expect(last_response.body).to include("You selected <strong>Partnership</strong>")
|
116
|
+
end
|
117
|
+
|
118
|
+
it "POST returns the status 200" do
|
119
|
+
post "/radiobutton", "enrollment[organisation_attributes][type]=WasteExemptionsShared::OrganisationType::Partnership"
|
120
|
+
|
121
|
+
expect(last_response).to be_ok
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context "/search" do
|
126
|
+
it "GET displays the page" do
|
127
|
+
get "/search"
|
128
|
+
|
129
|
+
expect(last_response.body).to include("confirming you got the right number of results")
|
130
|
+
end
|
131
|
+
|
132
|
+
it "GET returns the status 200" do
|
133
|
+
get "/search"
|
134
|
+
|
135
|
+
expect(last_response).to be_ok
|
136
|
+
end
|
137
|
+
|
138
|
+
it "POST to the page displays selected option" do
|
139
|
+
post "/search", "search_input=capybara"
|
140
|
+
|
141
|
+
expect(last_response.body).to include("Hydrochoerus hydrochaeris")
|
142
|
+
end
|
143
|
+
|
144
|
+
it "POST returns the status 200" do
|
145
|
+
post "/search", "search_input=capybara"
|
146
|
+
|
147
|
+
expect(last_response).to be_ok
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
module QukeDemoApp
|
6
|
+
# We make use of https://github.com/cucumber/aruba here to allow us to test
|
7
|
+
# the CLI for our demo app. Because we are kicking off a long lived process
|
8
|
+
# (Sinatra web server) we need someway to kill the process but still
|
9
|
+
# capture a result. That's what the `exit_timeout` arg does for us.
|
10
|
+
RSpec.describe Cli, type: :aruba, exit_timeout: 2 do
|
11
|
+
context "Start the demo app" do
|
12
|
+
let(:port_args) { "" }
|
13
|
+
before(:each) do
|
14
|
+
# We have to set the env var to invoke the simplecov section of our
|
15
|
+
# quke_demo_app exe file in order to capture test coverage accurately.
|
16
|
+
# set_environment_variable() is a method provided by Aruba, as is
|
17
|
+
# run_command
|
18
|
+
set_environment_variable("COVERAGE", "true")
|
19
|
+
run_command("exe/quke_demo_app #{port_args}")
|
20
|
+
end
|
21
|
+
|
22
|
+
it { expect(last_command_started).to be_successfully_executed }
|
23
|
+
it { expect(last_command_started).to have_output(/has taken the stage on 4567/) }
|
24
|
+
|
25
|
+
context "and set a custom port" do
|
26
|
+
let(:port_args) { "--port 9876" }
|
27
|
+
|
28
|
+
it { expect(last_command_started).to be_successfully_executed }
|
29
|
+
it { expect(last_command_started).to have_output(/has taken the stage on 9876/) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
RSpec.describe
|
5
|
+
RSpec.describe QukeDemoApp do
|
6
6
|
describe "VERSION" do
|
7
7
|
it "is a version string in the correct format" do
|
8
|
-
expect(
|
9
|
-
expect(
|
8
|
+
expect(QukeDemoApp::VERSION).to be_a(String)
|
9
|
+
expect(QukeDemoApp::VERSION).to match(/\d+\.\d+\.\d+/)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quke_demo_app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Defra
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -177,33 +177,32 @@ files:
|
|
177
177
|
- bin/console
|
178
178
|
- bin/setup
|
179
179
|
- exe/quke_demo_app
|
180
|
-
- lib/
|
181
|
-
- lib/
|
182
|
-
- lib/
|
183
|
-
- lib/
|
184
|
-
- lib/
|
185
|
-
- lib/
|
186
|
-
- lib/
|
187
|
-
- lib/
|
188
|
-
- lib/
|
189
|
-
- lib/
|
190
|
-
- lib/
|
191
|
-
- lib/
|
192
|
-
- lib/
|
193
|
-
- lib/
|
194
|
-
- lib/
|
195
|
-
- lib/
|
196
|
-
- lib/
|
197
|
-
- lib/
|
198
|
-
- lib/
|
199
|
-
- lib/
|
200
|
-
- lib/
|
201
|
-
- lib/
|
202
|
-
- lib/
|
203
|
-
-
|
204
|
-
- spec/
|
205
|
-
- spec/
|
206
|
-
- spec/quke/demo_app_spec.rb
|
180
|
+
- lib/quke_demo_app.rb
|
181
|
+
- lib/quke_demo_app/app.rb
|
182
|
+
- lib/quke_demo_app/cli.rb
|
183
|
+
- lib/quke_demo_app/concerns/can_have_search_results.rb
|
184
|
+
- lib/quke_demo_app/public/assets/css/bootstrap.min.css
|
185
|
+
- lib/quke_demo_app/public/assets/css/custom.css
|
186
|
+
- lib/quke_demo_app/public/assets/css/ie10-viewport-bug-workaround.css
|
187
|
+
- lib/quke_demo_app/public/assets/images/favicon.ico
|
188
|
+
- lib/quke_demo_app/public/assets/images/quke.png
|
189
|
+
- lib/quke_demo_app/public/assets/javascript/bootstrap.min.js
|
190
|
+
- lib/quke_demo_app/public/assets/javascript/ie10-viewport-bug-workaround.js
|
191
|
+
- lib/quke_demo_app/public/assets/javascript/jquery.min.js
|
192
|
+
- lib/quke_demo_app/version.rb
|
193
|
+
- lib/quke_demo_app/views/_partial_example.erb
|
194
|
+
- lib/quke_demo_app/views/about.erb
|
195
|
+
- lib/quke_demo_app/views/contact.erb
|
196
|
+
- lib/quke_demo_app/views/css_selector.erb
|
197
|
+
- lib/quke_demo_app/views/index.erb
|
198
|
+
- lib/quke_demo_app/views/javascript_error.erb
|
199
|
+
- lib/quke_demo_app/views/layout.erb
|
200
|
+
- lib/quke_demo_app/views/radio_button.erb
|
201
|
+
- lib/quke_demo_app/views/request.erb
|
202
|
+
- lib/quke_demo_app/views/search.erb
|
203
|
+
- spec/quke_demo_app/app_spec.rb
|
204
|
+
- spec/quke_demo_app/cli_spec.rb
|
205
|
+
- spec/quke_demo_app_spec.rb
|
207
206
|
- spec/spec_helper.rb
|
208
207
|
- spec/support/aruba.rb
|
209
208
|
- spec/support/pry.rb
|
@@ -239,12 +238,12 @@ signing_key:
|
|
239
238
|
specification_version: 4
|
240
239
|
summary: A web app used to demo Quke functionality.
|
241
240
|
test_files:
|
241
|
+
- spec/quke_demo_app/app_spec.rb
|
242
|
+
- spec/quke_demo_app/cli_spec.rb
|
242
243
|
- spec/spec_helper.rb
|
243
244
|
- spec/support/pry.rb
|
244
245
|
- spec/support/quke_demo_app.rb
|
245
246
|
- spec/support/simplecov.rb
|
246
247
|
- spec/support/rack_test.rb
|
247
248
|
- spec/support/aruba.rb
|
248
|
-
- spec/
|
249
|
-
- spec/quke/demo_app/app_spec.rb
|
250
|
-
- spec/quke/demo_app/cli_spec.rb
|
249
|
+
- spec/quke_demo_app_spec.rb
|
data/lib/quke.rb
DELETED
data/lib/quke/demo_app.rb
DELETED
data/lib/quke/demo_app/app.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# This stops the following Sinatra warning appearing when running the test suite
|
4
|
-
# or the app from bin/console (essentially any non-production environment)
|
5
|
-
#
|
6
|
-
# WARNING: If you plan to load any of ActiveSupport's core extensions to Hash,
|
7
|
-
# be sure to do so *before* loading Sinatra::Application or Sinatra::Base. If
|
8
|
-
# not, you may disregard this warning.
|
9
|
-
ENV["SINATRA_ACTIVESUPPORT_WARNING"] = "false"
|
10
|
-
|
11
|
-
require "sinatra/base"
|
12
|
-
|
13
|
-
module Quke
|
14
|
-
module DemoApp
|
15
|
-
class App < Sinatra::Base
|
16
|
-
include CanHaveSearchResults
|
17
|
-
|
18
|
-
get "/" do
|
19
|
-
@title = "Welcome to Quke"
|
20
|
-
erb :index
|
21
|
-
end
|
22
|
-
|
23
|
-
get "/about" do
|
24
|
-
@title = "About"
|
25
|
-
erb :about
|
26
|
-
end
|
27
|
-
|
28
|
-
get "/contact" do
|
29
|
-
@title = "Contact"
|
30
|
-
erb :contact
|
31
|
-
end
|
32
|
-
|
33
|
-
get "/cssselector" do
|
34
|
-
@title = "CSS selector"
|
35
|
-
erb :css_selector
|
36
|
-
end
|
37
|
-
|
38
|
-
get "/jserror" do
|
39
|
-
@title = "JavaScript error"
|
40
|
-
@results = "Open your browser's dev tools, specifically the JavaScript"\
|
41
|
-
"console. You should see an error!"
|
42
|
-
erb :javascript_error
|
43
|
-
end
|
44
|
-
|
45
|
-
get "/radiobutton" do
|
46
|
-
@title = "Radio button"
|
47
|
-
erb :radio_button
|
48
|
-
end
|
49
|
-
|
50
|
-
post "/radiobutton" do
|
51
|
-
@title = "Radio button"
|
52
|
-
@selection = params["enrollment"]["organisation_attributes"]["type"]
|
53
|
-
@result = @selection.match(/OrganisationType::([^"]*)/)[1]
|
54
|
-
|
55
|
-
erb :radio_button
|
56
|
-
end
|
57
|
-
|
58
|
-
get "/request" do
|
59
|
-
@title = "Request details"
|
60
|
-
@results = request.env
|
61
|
-
erb :request
|
62
|
-
end
|
63
|
-
|
64
|
-
get "/search" do
|
65
|
-
@title = "Search"
|
66
|
-
erb :search
|
67
|
-
end
|
68
|
-
|
69
|
-
post "/search" do
|
70
|
-
@title = "Search"
|
71
|
-
@query = params["search_input"]
|
72
|
-
|
73
|
-
@results = search_results if @query.casecmp("capybara").zero?
|
74
|
-
|
75
|
-
erb :search
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
data/lib/quke/demo_app/cli.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "thor"
|
4
|
-
|
5
|
-
module Quke
|
6
|
-
module DemoApp
|
7
|
-
class Cli < Thor
|
8
|
-
desc("execute", "Start the demo app running")
|
9
|
-
option(:port, aliases: "-p", desc: "Port to run the app on", default: "4567")
|
10
|
-
def execute
|
11
|
-
puts "Warming up the Quke Demo App. Hold on!"
|
12
|
-
Quke::DemoApp::App.set(port: options[:port])
|
13
|
-
Quke::DemoApp::App.run!
|
14
|
-
end
|
15
|
-
|
16
|
-
default_task :execute
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Quke
|
4
|
-
module DemoApp
|
5
|
-
module CanHaveSearchResults
|
6
|
-
|
7
|
-
private
|
8
|
-
|
9
|
-
def search_results
|
10
|
-
{
|
11
|
-
Capybara: "The capybara (Hydrochoerus hydrochaeris) is a large rodent "\
|
12
|
-
"of the genus Hydrochoerus of which the only other extant member is "\
|
13
|
-
"the lesser capybara (Hydrochoerus isthmius). The capybara is the "\
|
14
|
-
"largest rodent in the world. Close relatives are guinea pigs and "\
|
15
|
-
"rock cavies, and it is more distantly related to the agouti, "\
|
16
|
-
"chinchillas, and the coypu. Native to South America, the capybara "\
|
17
|
-
"inhabits savannas and dense forests and lives near bodies of water. "\
|
18
|
-
"It is a highly social species and can be found in groups as large as "\
|
19
|
-
"100 individuals, but usually lives in groups of 10-20 individuals. "\
|
20
|
-
"The capybara is not a threatened species and is hunted for its meat "\
|
21
|
-
"and hide and also for a grease from its thick fatty skin which is "\
|
22
|
-
"used in the pharmaceutical trade.",
|
23
|
-
Capybara_software: "Capybara is a web-based test automation "\
|
24
|
-
"software that simulates scenarios for user stories and automates "\
|
25
|
-
"web application testing for behavior-driven software "\
|
26
|
-
"development. It is a part of the Cucumber testing framework "\
|
27
|
-
"written in the Ruby programming language that simulates various "\
|
28
|
-
"aspects of a web browser from the perspective of a real user."
|
29
|
-
}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,153 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
module Quke
|
6
|
-
module DemoApp
|
7
|
-
RSpec.describe App do
|
8
|
-
|
9
|
-
it "includes CanHaveSearchResults" do
|
10
|
-
included_modules = described_class.ancestors.select { |ancestor| ancestor.instance_of?(Module) }
|
11
|
-
|
12
|
-
expect(included_modules)
|
13
|
-
.to include(Quke::DemoApp::CanHaveSearchResults)
|
14
|
-
end
|
15
|
-
|
16
|
-
context "/" do
|
17
|
-
it "GET displays the page" do
|
18
|
-
get "/"
|
19
|
-
|
20
|
-
expect(last_response.body).to include("Welcome to Quke")
|
21
|
-
end
|
22
|
-
|
23
|
-
it "GET returns the status 200" do
|
24
|
-
get "/"
|
25
|
-
|
26
|
-
expect(last_response).to be_ok
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context "/about" do
|
31
|
-
it "GET displays the page" do
|
32
|
-
get "/about"
|
33
|
-
|
34
|
-
expect(last_response.body).to include("The about page.")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "GET returns the status 200" do
|
38
|
-
get "/about"
|
39
|
-
|
40
|
-
expect(last_response).to be_ok
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "/contact" do
|
45
|
-
it "GET displays the page" do
|
46
|
-
get "/contact"
|
47
|
-
|
48
|
-
expect(last_response.body).to include("The contact page.")
|
49
|
-
end
|
50
|
-
|
51
|
-
it "GET returns the status 200" do
|
52
|
-
get "/contact"
|
53
|
-
|
54
|
-
expect(last_response).to be_ok
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context "/cssselector" do
|
59
|
-
it "GET displays the page" do
|
60
|
-
get "/cssselector"
|
61
|
-
|
62
|
-
expect(last_response.body).to include("rely on using CSS selectors to locate elements")
|
63
|
-
end
|
64
|
-
|
65
|
-
it "GET returns the status 200" do
|
66
|
-
get "/cssselector"
|
67
|
-
|
68
|
-
expect(last_response).to be_ok
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context "/jserror" do
|
73
|
-
it "GET displays the page" do
|
74
|
-
get "/jserror"
|
75
|
-
|
76
|
-
expect(last_response.body).to include("page with a JavaScript error")
|
77
|
-
end
|
78
|
-
|
79
|
-
it "GET returns the status 200" do
|
80
|
-
get "/jserror"
|
81
|
-
|
82
|
-
expect(last_response).to be_ok
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
context "/request" do
|
87
|
-
it "GET displays the page" do
|
88
|
-
get "/request"
|
89
|
-
|
90
|
-
expect(last_response.body).to include("checking that the request")
|
91
|
-
end
|
92
|
-
|
93
|
-
it "GET returns the status 200" do
|
94
|
-
get "/request"
|
95
|
-
|
96
|
-
expect(last_response).to be_ok
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context "/radiobutton" do
|
101
|
-
it "GET displays the page" do
|
102
|
-
get "/radiobutton"
|
103
|
-
|
104
|
-
expect(last_response.body).to include("elements like radio buttons")
|
105
|
-
end
|
106
|
-
|
107
|
-
it "GET returns the status 200" do
|
108
|
-
get "/radiobutton"
|
109
|
-
|
110
|
-
expect(last_response).to be_ok
|
111
|
-
end
|
112
|
-
|
113
|
-
it "POST to the page displays selected option" do
|
114
|
-
post "/radiobutton", "enrollment[organisation_attributes][type]=WasteExemptionsShared::OrganisationType::Partnership"
|
115
|
-
|
116
|
-
expect(last_response.body).to include("You selected <strong>Partnership</strong>")
|
117
|
-
end
|
118
|
-
|
119
|
-
it "POST returns the status 200" do
|
120
|
-
post "/radiobutton", "enrollment[organisation_attributes][type]=WasteExemptionsShared::OrganisationType::Partnership"
|
121
|
-
|
122
|
-
expect(last_response).to be_ok
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
context "/search" do
|
127
|
-
it "GET displays the page" do
|
128
|
-
get "/search"
|
129
|
-
|
130
|
-
expect(last_response.body).to include("confirming you got the right number of results")
|
131
|
-
end
|
132
|
-
|
133
|
-
it "GET returns the status 200" do
|
134
|
-
get "/search"
|
135
|
-
|
136
|
-
expect(last_response).to be_ok
|
137
|
-
end
|
138
|
-
|
139
|
-
it "POST to the page displays selected option" do
|
140
|
-
post "/search", "search_input=capybara"
|
141
|
-
|
142
|
-
expect(last_response.body).to include("Hydrochoerus hydrochaeris")
|
143
|
-
end
|
144
|
-
|
145
|
-
it "POST returns the status 200" do
|
146
|
-
post "/search", "search_input=capybara"
|
147
|
-
|
148
|
-
expect(last_response).to be_ok
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
module Quke
|
6
|
-
module DemoApp
|
7
|
-
# We make use of https://github.com/cucumber/aruba here to allow us to test
|
8
|
-
# the CLI for our demo app. Because we are kicking off a long lived process
|
9
|
-
# (Sinatra web server) we need someway to kill the process but still
|
10
|
-
# capture a result. That's what the `exit_timeout` arg does for us.
|
11
|
-
RSpec.describe Cli, type: :aruba, exit_timeout: 2 do
|
12
|
-
context "Start the demo app" do
|
13
|
-
let(:port_args) { "" }
|
14
|
-
before(:each) do
|
15
|
-
# We have to set the env var to invoke the simplecov section of our
|
16
|
-
# quke_demo_app exe file in order to capture test coverage accurately.
|
17
|
-
# set_environment_variable() is a method provided by Aruba, as is
|
18
|
-
# run_command
|
19
|
-
set_environment_variable("COVERAGE", "true")
|
20
|
-
run_command("exe/quke_demo_app #{port_args}")
|
21
|
-
end
|
22
|
-
|
23
|
-
it { expect(last_command_started).to be_successfully_executed }
|
24
|
-
it { expect(last_command_started).to have_output(/has taken the stage on 4567/) }
|
25
|
-
|
26
|
-
context "and set a custom port" do
|
27
|
-
let(:port_args) { "--port 9876" }
|
28
|
-
|
29
|
-
it { expect(last_command_started).to be_successfully_executed }
|
30
|
-
it { expect(last_command_started).to have_output(/has taken the stage on 9876/) }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|