-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a new page that when requested, will output the details of the request. It was created as part of working on [Add ability to set user-agent to use](DEFRA/quke#60) in **Quke**. Along with it is a feature that provides an example of how you can then test a page for specific content. Admittedly not an amazing addition as an example, but it gives meaning for the page being there, and is a working example nonetheless.
- Loading branch information
1 parent
a41df6a
commit 3041c3d
Showing
6 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!-- Main jumbotron for a primary marketing message or call to action --> | ||
<div class="jumbotron"> | ||
<h1><%= @title %></h1> | ||
<p class="lead">This page can be used for checking that the request you formulated in <strong>Quke</strong> is as | ||
expected. It will display the details for each item in the request.</p> | ||
<p class="lead">There are examples of how to test against the data in this page, but essentially they are just | ||
using <strong>Capybara's</strong> <code>find()</code> method.</p> | ||
<ul> | ||
<li><code>features/quke/request_details.feature</code></li> | ||
<li><code>features/step_definitions/quke/request_details_steps.rb</code></li> | ||
<li><code>quke_demo_app/views/request_details.erb</code></li> | ||
</ul> | ||
</div> | ||
|
||
<div id="results"> | ||
<h2>Results</h2> | ||
<% @results.each do | key, value | %> | ||
<div><strong><%= key %></strong> <code id="<%= key %>"><%= value %></code></div> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Request details page | ||
class RequestDetailsPage < SitePrism::Page | ||
set_url '/request' | ||
|
||
element :title, 'h1' | ||
element :request_type, '#REQUEST_METHOD' | ||
element :user_agent, '#HTTP_USER_AGENT' | ||
|
||
elements :results, "div[class='result']" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Feature: Request details | ||
To demonstrate how you can use Quke | ||
As a user of Quke | ||
I want to see that the request received matches what I configured in Quke | ||
|
||
@wip | ||
Scenario: Checking for custom user agent (page objects) | ||
Given I am on the request details page | ||
Then It should show we made a "GET" request | ||
And the user agent was "Mozilla/5.0 (MSIE 10.0; Windows NT 6.1; Trident/5.0)" | ||
|
||
@wip | ||
Scenario: Checking for custom user agent (capybara) | ||
Given I'm at the request details page | ||
Then I should see we made a "GET" request | ||
And that the user agent was "Mozilla/5.0 (MSIE 10.0; Windows NT 6.1; Trident/5.0)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# The following steps use the page objects to drive the browser | ||
Given(/^I am on the request details page$/) do | ||
@app = App.new | ||
@app.request_details_page.load | ||
expect(@app.request_details_page.title.text).to eq('Request details') | ||
end | ||
|
||
Then(/^It should show we made a "([^"]*)" request$/) do |request_type| | ||
expect(@app.request_details_page.request_type.text).to eq(request_type) | ||
end | ||
|
||
And(/^the user agent was "([^"]*)"$/) do |user_agent| | ||
expect(@app.request_details_page.user_agent.text).to eq(user_agent) | ||
end | ||
|
||
# The following steps use capybara directly to drive the browser | ||
Given(/^I'm at the request details page$/) do | ||
visit 'http://localhost:4567/request' | ||
expect(page).to have_content('Request details') | ||
end | ||
|
||
Then(/^I should see we made a "([^"]*)" request$/) do |request_type| | ||
expect(find('#REQUEST_METHOD').text).to eq(request_type) | ||
end | ||
|
||
And(/^that the user agent was "([^"]*)"$/) do |user_agent| | ||
expect(find('#HTTP_USER_AGENT').text).to eq(user_agent) | ||
end |