I have a regexp in my cucumber test set up for
Then /I should see "(.*)" before "(.*)"/ do |string1, string2|
and in the following statement I say
page.body.should =~ regexp
where my regexp is
regexp = /#{string1}.*#{string2}/m
This is the scenario
Scenario: sort movies alphabetically
When I follow "Movie Title"
Then I should see "2001: A Space Odyssey" before "Aladdin"
But when I run the test I receive this error
expected: /2001: A Space Odyssey.*Aladdin/m
got: "<!DOCTYPE html>\n<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<title>Rotten Potatoes!</title>\n<link href=\"/assets/application.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\">\n<script src=\"/assets/application.js\" type=\"text/javascript\"></script>\n</head>\n<body>\n<h1 class=\"title\">Rotten Potatoes!</h1>\n<div id=\"main\">\n<h1>All Movies</h1>\n<form accept-charset=\"UTF-8\" action=\"/movies\" id=\"ratings_form\" method=\"get\">\n<div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"✓\"></div>\n<input id=\"title_sort\" name=\"title_sort\" type=\"hidden\" value=\"true\">\n\nInclude:\nG\n<input id=\"ratings_G\" name=\"ratings[G]\" type=\"checkbox\" value=\"1\">\nPG\n<input id=\"ratings_PG\" name=\"ratings[PG]\" type=\"checkbox\" value=\"1\">\nPG-13\n<input id=\"ratings_PG-13\" name=\"ratings[PG-13]\" type=\"checkbox\" value=\"1\">\nNC-17\n<input id=\"ratings_NC-17\" name=\"ratings[NC-17]\" type=\"checkbox\" value=\"1\">\nR\n<input id=\"ratings_R\" name=\"ratings[R]\" type=\"checkbox\" value=\"1\"><input id=\"ratings_submit\" name=\"commit\" type=\"submit\" value=\"Refresh\">\n</form>\n\n<table id=\"movies\">\n<thead><tr>\n<th class=\"hilite\">Movie Title</th>\n<th>Rating</th>\n<th>Release Date</th>\n<th>More Info</th>\n</tr></thead>\n<tbody id=\"movielist\"></tbody>\n</table>\nAdd new movie\n\n</div>\n</body>\n</html>\n" (using =~)
Diff:
## -1,2 +1,44 ##
-/2001: A Space Odyssey.*Aladdin/m
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Rotten Potatoes!</title>
+<link href="/assets/application.css" media="screen" rel="stylesheet" type="text/css">
+<script src="/assets/application.js" type="text/javascript"></script>
+</head>
+<body>
+<h1 class="title">Rotten Potatoes!</h1>
+<div id="main">
+<h1>All Movies</h1>
+<form accept-charset="UTF-8" action="/movies" id="ratings_form" method="get">
+<div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"></div>
+<input id="title_sort" name="title_sort" type="hidden" value="true">
+
+Include:
+G
+<input id="ratings_G" name="ratings[G]" type="checkbox" value="1">
+PG
+<input id="ratings_PG" name="ratings[PG]" type="checkbox" value="1">
+PG-13
+<input id="ratings_PG-13" name="ratings[PG-13]" type="checkbox" value="1">
+NC-17
+<input id="ratings_NC-17" name="ratings[NC-17]" type="checkbox" value="1">
+R
+<input id="ratings_R" name="ratings[R]" type="checkbox" value="1"><input id="ratings_submit" name="commit" type="submit" value="Refresh">
+</form>
+
+<table id="movies">
+<thead><tr>
+<th class="hilite">Movie Title</th>
+<th>Rating</th>
+<th>Release Date</th>
+<th>More Info</th>
+</tr></thead>
+<tbody id="movielist"></tbody>
+</table>
+Add new movie
+
+</div>
+</body>
+</html>
(RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/movie_steps.rb:33:in `/I should see "(.*)" before "(.*)"/'
features/sort_movie_list.feature:26:in `Then I should see "2001: A Space Odyssey" before "Aladdin"'
Any suggestions? I'm assuming my error is in my regexp but I cannot find a working solution.
ok, glad to have helped! Answering so I can get the Stack overflow karma... Either your template needs to list the movies or your scenario needs to populate the data you are looking for.
Related
I have seen a jelly file with f:optional block
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form" xmlns:st="jelly:stapler">
<j:choose>
<j:when test="${instance == null}">
<f:entry title="${%File}" field="file">
<input type="file" name="file" size="40" jsonAware="yes"/>
</f:entry>
</j:when>
<j:otherwise>
<f:invisibleEntry>
<f:textbox field="fileName"/>
</f:invisibleEntry>
<f:invisibleEntry>
<f:textbox field="secretBytes"/>
</f:invisibleEntry>
<f:optionalBlock title="${%upload(instance.fileName)}" inline="true">
<f:entry title="${%File}" field="file">
<input type="file" name="file" size="40" jsonAware="yes"/>
</f:entry>
</f:optionalBlock>
</j:otherwise>
</j:choose>
<st:include page="id-and-description" class="${descriptor.clazz}"/>
</j:jelly>
What is f:optional block doing here, i mean whats its significance here ?
Jelly code internally converts to simple HTML and JavaScript code.
<f:optionalBlock> block is used to display a checkbox. When you click on this checkbox, the fields inside the checkbox are displayed on the UI.
In your example, file parameter will be displayed on UI.
We can use inline and checked properties of <f:optional> block
This is my login form. If a user puts in a wrong username and does not exists on the server then how do I use md-error to display message?
E.g.
Here is the json I get back for auth from a submit:
{is_username: false, status: false}
Here is how I set up my form:
this.myForm = fb.group({
username: ['',[Validators.required]],
password: ['',[Validators.required]]
})
Here is my HTML:
<md-input-container>
<input mdInput type="email" placeholder="Username" [(ngModel)]="username" formControlName="username" style="width: 300px;outline: none;">
<md-error *ngIf="myForm.get('username').hasError('required')">Username is required</md-error>
<md-error *ngIf="myForm.get('username').hasError('username_exists')">Username does exist</md-error>
</md-input-container>
So..how do I trigger a md-error message if is_username is false?
I've been doing server side validation like this.
<md-input-container>
<input mdInput type="email" placeholder="Username" [(ngModel)]="username" formControlName="username" style="width: 300px;outline: none;">
<md-error *ngIf="myForm.get('username').hasError('required')">Username is required</md-error>
<md-error *ngIf="myForm.controls['username'].hasError('username_exists')">{{myForm.controls['username'].errors['username_exists']}}</md-error>
</md-input-container>
Then, set the error after you get the response from the server.
https://angular.io/api/forms/AbstractControl#setErrors
this.myForm.controls['username'].setErrors({
'username_exists': 'Username does exist'
});
I typically return validation error messages from the server as well, which could be used here.
Have sjg:grid in the jsp. Trying to add a column with a dropdown with options shown as =,<,> . But, in the dropdown it shows as = undefined < undefined undefined etc... .
How to get these option into the grid column dropdown.
I tried the below
<s:url var="searchUrl" action="SearchAction"/>
<s:url var="editSearchUrl" action="editSearchAction"/>
<sjg:grid
id="searchGridId"
formIds="searchFormId"
href="%{searchUrl}"
reloadTopics="reloadSearchGrid"
dataType="json"
pager="true"
gridModel="searchResults"
rowList="10,15,20"
rowNum="15"
rownumbers="true"
viewrecords="true"
autowidth="true"
editurl="%{editSearchUrl}"
editinline="true"
navigator="true"
navigatorAdd="false"
navigatorViewOptions="{height:280, width:500}"
navigatorDelete="false"
navigatorEdit="false"
navigatorRefresh="true"
navigatorSearch="false"
multiselect="false"
onSelectRowTopics="rowselect"
>
<sjg:gridColumn name="orderNumber" index="orderNumber" title="% {getText('label.orderNumber')}" key="true" sortable="true"/>
<sjg:gridColumn name="orderRange" index="orderRange" title="%{getText('label.orderRange)}" sortable="false" editable="true" edittype="select" editoptions="{value:'=:=;<:<;>:>'}"/>
</sjg:grid>
Doing this worked for me as suggested in this post
http://www.trirand.com/blog/?page_id=393/help/problem-using-colon-in-editoptions-as-value
editoptions="{dataUrl:'jsp/test.html'}"
test.html
<select role="select" id="orderRangeId" name="orderRange" size="1" class="editable">
<option role="option" value="=">=</option>
<option role="option" value="<"><</option>
<option role="option" value=">">></option>
</select>
I upgraded my application from 2.2.3 to 2.4.3. Now when I click submit on the login page, I see that the POST request to j_spring_security_check has status code 302.
Is there something I need to do after upgrading? I've tried running grails clean-all but that did not help.
I'm using this version: compile ':spring-security-core:2.0-RC3'
settings in config.groovy
grails.plugins.springsecurity.userLookup.userDomainClassName = 'com.aerstone.scanner.security.User'
grails.plugins.springsecurity.userLookup.authorityJoinClassName = 'com.aerstone.scanner.security.UserRole'
grails.plugins.springsecurity.authority.className = 'com.aerstone.scanner.security.Role'
GSP
<form action="${postUrl}" method="POST" id="loginForm" autocomplete="off">
<input type='text' name='j_username' id='username' placeholder="Username"/>
<input type='password' name='j_password' id='password' placeholder="Password"/>
<input type="submit" class="btn" value="Sign in" id="submit"/>
</form>
I had the same issue after an upgrade.
I changed the action of the login form by:
<form action='${ request.contextPath }/j_spring_security_check' method="POST">
Hope that helps
please note that the name had change in the config to be:
grails.plugin.springsecurity....
Notice 'plugin' vs 'plugins'. I've passed this problem but I'm getting invalid credentials all the time.
Besides the following, are there any HTML tag attributes that have a URL as their value?
href attribute on tags: <link>, <a>, <area>
src attribute on tags: <img>, <iframe>, <frame>, <embed>, <script>, <input>
action attribute on tags: <form>
data attribute on tags: <object>
Looking for tags in wide usage, including non-standard tags and old browsers as well as HTML 4.01, HTML 5, and XHTML.
Check out the W3C's list of HTML attributes, there's a "type" column in there and just look for URI types.
And of course the HTML 5 version of that list is useful too (edit: updated link for HTML 5.2 here)
So for HTML4 we've got:
<a href=url>
<applet codebase=url>
<area href=url>
<base href=url>
<blockquote cite=url>
<body background=url>
<del cite=url>
<form action=url>
<frame longdesc=url> and <frame src=url>
<head profile=url>
<iframe longdesc=url> and <iframe src=url>
<img longdesc=url> and <img src=url> and <img usemap=url>
<input src=url> and <input usemap=url>
<ins cite=url>
<link href=url>
<object classid=url> and <object codebase=url> and <object data=url> and <object usemap=url>
<q cite=url>
<script src=url>
HTML 5 adds a few (and HTML5 seems to not use some of the ones above as well):
<audio src=url>
<button formaction=url>
<command icon=url>
<embed src=url>
<html manifest=url>
<input formaction=url>
<source src=url>
<track src=url>
<video poster=url> and <video src=url>
These aren't necessarily simple URLs:
<img srcset="url1 resolution1, url2 resolution2">
<source srcset="url1 resolution1, url2 resolution2">
<object archive=url> or <object archive="url1 url2 url3">
<applet archive=url> or <applet archive=url1,url2,url3>
<meta http-equiv="refresh" content="seconds; url">
SVGs can also contain links to resources: <svg><image href="url" /></svg>
In addition, the style attribute can contain css declarations with one or several urls. For example: <div style="background: url(image.png)">
So you can include:
<style>
#domID {
background:url()
}
</style>