Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
7c21aaf4
...
7c21aaf43efb6d6674e0bc3a8100ff759d7cb770
authored
2013-05-09 09:28:45 -0700
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #452 from EndangeredMassa/endangeredmassa/method-casing
allow uppercase http methods
2 parents
80f55a14
57f8ed97
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
1 deletions
modules/casper.js
tests/suites/casper/open.js
modules/casper.js
View file @
7c21aaf
...
...
@@ -1357,7 +1357,7 @@ Casper.prototype.open = function open(location, settings) {
// http method
// taken from https://github.com/ariya/phantomjs/blob/master/src/webpage.cpp#L302
var
methods
=
[
"get"
,
"head"
,
"put"
,
"post"
,
"delete"
];
if
(
settings
.
method
&&
(
!
utils
.
isString
(
settings
.
method
)
||
methods
.
indexOf
(
settings
.
method
)
===
-
1
))
{
if
(
settings
.
method
&&
(
!
utils
.
isString
(
settings
.
method
)
||
methods
.
indexOf
(
settings
.
method
.
toLowerCase
()
)
===
-
1
))
{
throw
new
CasperError
(
"open(): settings.method must be part of "
+
methods
.
join
(
', '
));
}
// http data
...
...
tests/suites/casper/open.js
View file @
7c21aaf
...
...
@@ -32,6 +32,25 @@ casper.test.begin('open() GET tests', 2, {
}
});
casper
.
test
.
begin
(
'open() GET casing tests'
,
2
,
{
setUp
:
setUp
,
tearDown
:
tearDown
,
test
:
function
(
test
)
{
casper
.
open
(
'tests/site/index.html'
,
{
method
:
'GET'
}).
then
(
function
()
{
test
.
pass
(
"Casper.open() can open and load a location using GET"
);
test
.
assertEquals
(
usedSettings
,
{
method
:
"GET"
},
"Casper.open() used the expected GET settings"
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
}
});
casper
.
test
.
begin
(
'open() POST tests'
,
2
,
{
setUp
:
setUp
,
tearDown
:
tearDown
,
...
...
@@ -56,6 +75,30 @@ casper.test.begin('open() POST tests', 2, {
}
});
casper
.
test
.
begin
(
'open() POST casing tests'
,
2
,
{
setUp
:
setUp
,
tearDown
:
tearDown
,
test
:
function
(
test
)
{
casper
.
open
(
'tests/site/index.html'
,
{
method
:
'POST'
,
data
:
{
plop
:
42
,
chuck
:
'norris'
}
}).
then
(
function
()
{
test
.
pass
(
"Casper.open() can open and load a location using POST"
);
test
.
assertEquals
(
usedSettings
,
{
method
:
"POST"
,
data
:
"plop=42&chuck=norris"
},
"Casper.open() used the expected POST settings"
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
}
});
casper
.
test
.
begin
(
'open() PUT tests'
,
2
,
{
setUp
:
setUp
,
tearDown
:
tearDown
,
...
...
@@ -80,6 +123,30 @@ casper.test.begin('open() PUT tests', 2, {
}
});
casper
.
test
.
begin
(
'open() PUT casing tests'
,
2
,
{
setUp
:
setUp
,
tearDown
:
tearDown
,
test
:
function
(
test
)
{
casper
.
thenOpen
(
'tests/site/index.html'
,
{
method
:
'PUT'
,
data
:
{
plop
:
42
,
chuck
:
'norris'
}
}).
then
(
function
()
{
test
.
pass
(
"Casper.open() can open and load a location using PUT"
);
test
.
assertEquals
(
usedSettings
,
{
method
:
"PUT"
,
data
:
"plop=42&chuck=norris"
},
"Casper.open() used the expected PUT settings"
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
}
});
casper
.
test
.
begin
(
'open() PUT tests'
,
2
,
{
setUp
:
setUp
,
tearDown
:
tearDown
,
...
...
Please
register
or
sign in
to post a comment