quke_demo_app 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/bin/console +1 -1
  3. data/exe/quke_demo_app +2 -2
  4. data/lib/quke_demo_app.rb +9 -0
  5. data/lib/quke_demo_app/app.rb +77 -0
  6. data/lib/quke_demo_app/cli.rb +17 -0
  7. data/lib/quke_demo_app/concerns/can_have_search_results.rb +31 -0
  8. data/lib/{quke/demo_app → quke_demo_app}/public/assets/css/bootstrap.min.css +0 -0
  9. data/lib/{quke/demo_app → quke_demo_app}/public/assets/css/custom.css +0 -0
  10. data/lib/{quke/demo_app → quke_demo_app}/public/assets/css/ie10-viewport-bug-workaround.css +0 -0
  11. data/lib/{quke/demo_app → quke_demo_app}/public/assets/images/favicon.ico +0 -0
  12. data/lib/{quke/demo_app → quke_demo_app}/public/assets/images/quke.png +0 -0
  13. data/lib/{quke/demo_app → quke_demo_app}/public/assets/javascript/bootstrap.min.js +0 -0
  14. data/lib/{quke/demo_app → quke_demo_app}/public/assets/javascript/ie10-viewport-bug-workaround.js +0 -0
  15. data/lib/{quke/demo_app → quke_demo_app}/public/assets/javascript/jquery.min.js +0 -0
  16. data/lib/quke_demo_app/version.rb +5 -0
  17. data/lib/{quke/demo_app → quke_demo_app}/views/_partial_example.erb +0 -0
  18. data/lib/{quke/demo_app → quke_demo_app}/views/about.erb +0 -0
  19. data/lib/{quke/demo_app → quke_demo_app}/views/contact.erb +0 -0
  20. data/lib/{quke/demo_app → quke_demo_app}/views/css_selector.erb +0 -0
  21. data/lib/{quke/demo_app → quke_demo_app}/views/index.erb +0 -0
  22. data/lib/{quke/demo_app → quke_demo_app}/views/javascript_error.erb +0 -0
  23. data/lib/{quke/demo_app → quke_demo_app}/views/layout.erb +0 -0
  24. data/lib/{quke/demo_app → quke_demo_app}/views/radio_button.erb +0 -0
  25. data/lib/{quke/demo_app → quke_demo_app}/views/request.erb +0 -0
  26. data/lib/{quke/demo_app → quke_demo_app}/views/search.erb +0 -0
  27. data/spec/quke_demo_app/app_spec.rb +151 -0
  28. data/spec/quke_demo_app/cli_spec.rb +33 -0
  29. data/spec/{quke/demo_app_spec.rb → quke_demo_app_spec.rb} +3 -3
  30. data/spec/support/quke_demo_app.rb +1 -1
  31. metadata +31 -32
  32. data/lib/quke.rb +0 -7
  33. data/lib/quke/demo_app.rb +0 -11
  34. data/lib/quke/demo_app/app.rb +0 -79
  35. data/lib/quke/demo_app/cli.rb +0 -19
  36. data/lib/quke/demo_app/concerns/can_have_search_results.rb +0 -33
  37. data/lib/quke/demo_app/version.rb +0 -7
  38. data/spec/quke/demo_app/app_spec.rb +0 -153
  39. 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: cabf745d9fc13fba2f47ae6691caa47ae36f2c704ec98fd0851bc7f39fce9fe5
4
- data.tar.gz: fae1a5be8390ab2083ebf05c8931617e0afe5f71f8b33c14f1e473305bd598d7
3
+ metadata.gz: 559a330920d858658c3c69d768d24654c7c076a24cd78acfe849ff36f46e5b2c
4
+ data.tar.gz: 7d2e81a6001d9bf827e554aad9238bc3b3fc1040799ef6a9b741a64823824c2b
5
5
  SHA512:
6
- metadata.gz: 6e13cff86d126727aa472884cb9830693c3e624185894fa4a2e91c75f9fc88735ffa3cd1b4a3a43d499df7296d71665c8bdc126219330c29fbb76388c153dff7
7
- data.tar.gz: 9e7c046d35b64fa1d4114f09aecb5c249b4be29f410d31dbe290331e13d1cf3e7259f764122f4a348687a3e9fc69c7e12f8c56efc7ab1b3835b9dc3a17b770e8
6
+ metadata.gz: 242170ba2eab636d88c8248c32fe673c3df87a78e9a66ad1ee76a8e15389585d08645b3c5a6efcf47c84651ffbf5c87d43960490926f8d7b4e3e9b0f7632c903
7
+ data.tar.gz: eeb6b3abaf2eec973dced9a79350354f17054201b1767a26e05fa2c949b9387e88faa4198e8e0a32755c2a51fcde1b0b2ffb5d12e2051627f82dfa8dd7cd10ce
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "quke"
4
+ require "quke_demo_app"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -38,6 +38,6 @@ if ENV["COVERAGE"]
38
38
  SimpleCov.start
39
39
  end
40
40
 
41
- require_relative "../lib/quke/demo_app"
41
+ require_relative "../lib/quke_demo_app"
42
42
 
43
- Quke::DemoApp::Cli.start
43
+ QukeDemoApp::Cli.start
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "quke_demo_app/concerns/can_have_search_results"
4
+ require_relative "quke_demo_app/app"
5
+ require_relative "quke_demo_app/cli"
6
+
7
+ module QukeDemoApp
8
+
9
+ end
@@ -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
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module QukeDemoApp
4
+ VERSION = "0.2.0"
5
+ end
@@ -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 Quke::DemoApp do
5
+ RSpec.describe QukeDemoApp do
6
6
  describe "VERSION" do
7
7
  it "is a version string in the correct format" do
8
- expect(Quke::DemoApp::VERSION).to be_a(String)
9
- expect(Quke::DemoApp::VERSION).to match(/\d+\.\d+\.\d+/)
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Need to require our actual code files.
4
- require "quke/demo_app"
4
+ require "quke_demo_app"
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.1.1
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-09 00:00:00.000000000 Z
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/quke.rb
181
- - lib/quke/demo_app.rb
182
- - lib/quke/demo_app/app.rb
183
- - lib/quke/demo_app/cli.rb
184
- - lib/quke/demo_app/concerns/can_have_search_results.rb
185
- - lib/quke/demo_app/public/assets/css/bootstrap.min.css
186
- - lib/quke/demo_app/public/assets/css/custom.css
187
- - lib/quke/demo_app/public/assets/css/ie10-viewport-bug-workaround.css
188
- - lib/quke/demo_app/public/assets/images/favicon.ico
189
- - lib/quke/demo_app/public/assets/images/quke.png
190
- - lib/quke/demo_app/public/assets/javascript/bootstrap.min.js
191
- - lib/quke/demo_app/public/assets/javascript/ie10-viewport-bug-workaround.js
192
- - lib/quke/demo_app/public/assets/javascript/jquery.min.js
193
- - lib/quke/demo_app/version.rb
194
- - lib/quke/demo_app/views/_partial_example.erb
195
- - lib/quke/demo_app/views/about.erb
196
- - lib/quke/demo_app/views/contact.erb
197
- - lib/quke/demo_app/views/css_selector.erb
198
- - lib/quke/demo_app/views/index.erb
199
- - lib/quke/demo_app/views/javascript_error.erb
200
- - lib/quke/demo_app/views/layout.erb
201
- - lib/quke/demo_app/views/radio_button.erb
202
- - lib/quke/demo_app/views/request.erb
203
- - lib/quke/demo_app/views/search.erb
204
- - spec/quke/demo_app/app_spec.rb
205
- - spec/quke/demo_app/cli_spec.rb
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/quke/demo_app_spec.rb
249
- - spec/quke/demo_app/app_spec.rb
250
- - spec/quke/demo_app/cli_spec.rb
249
+ - spec/quke_demo_app_spec.rb
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "quke/demo_app"
4
-
5
- module Quke
6
-
7
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "demo_app/concerns/can_have_search_results"
4
- require_relative "demo_app/app"
5
- require_relative "demo_app/cli"
6
-
7
- module Quke
8
- module DemoApp
9
- # The DemoApp namespace
10
- end
11
- end
@@ -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
@@ -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,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Quke
4
- module DemoApp
5
- VERSION = "0.1.1"
6
- end
7
- 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