password_strength 0.1.1 → 0.1.2

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.
@@ -0,0 +1,43 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <title>JavaScript unit test file</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7
+ <script src="jsunittest/jsunittest.js" type="text/javascript"></script>
8
+ <link rel="stylesheet" href="jsunittest/unittest.css" type="text/css" />
9
+
10
+ <style type="text/css" media="screen">
11
+ #logger p {
12
+ background: #ffc;
13
+ padding: 5px;
14
+ }
15
+ </style>
16
+ <script src="jquery-1.4.2.js" type="text/javascript"></script>
17
+ <script src="../lib/password_strength.js" type="text/javascript"></script>
18
+ <script src="../lib/jquery.strength.js" type="text/javascript"></script>
19
+ </head>
20
+ <body>
21
+
22
+ <div id="content">
23
+ <div id="header">
24
+ <h1>JavaScript unit test file</h1>
25
+ <p>
26
+ This file tests <strong>jquery.strength.js</strong>.
27
+ </p>
28
+ </div>
29
+
30
+ <!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
31
+ <div id="testlog"></div>
32
+
33
+ <!-- General debugger -->
34
+ <div id="logger"></div>
35
+
36
+ <!-- Put sample/test html here -->
37
+ <div id="sample">
38
+ </div>
39
+ </div>
40
+
41
+ <script src="jquery_strength_test.js" type="text/javascript"></script>
42
+ </body>
43
+ </html>
@@ -0,0 +1,74 @@
1
+ new Test.Unit.Runner({
2
+ setup: function() {
3
+ $("#sample").html('<input type="text" id="username"><input type="text" id="password">');
4
+ $("#username").val("johndoe");
5
+ $("#password").val("mypass");
6
+ },
7
+
8
+ teardown: function() {
9
+ $("#sample").empty();
10
+ },
11
+
12
+ // Respond to strength
13
+ testRespondToStrength: function() { with(this) {
14
+ assertRespondsTo("strength", jQuery);
15
+ }},
16
+
17
+ // Defaults
18
+ testDefaults: function() { with(this) {
19
+ $.strength("#username", "#password");
20
+ $("#password").trigger("keydown");
21
+
22
+ assertEqual(1, $("img.strength").length);
23
+ }},
24
+
25
+ // Custom callback
26
+ testCustomCallback: function() { with(this) {
27
+ $.strength("#username", "#password", function(username, password, strength){
28
+ assert($(username).is("#username"));
29
+ assert($(password).is("#password"));
30
+ assert("johndoe", strength.username);
31
+ assert("password", strength.password);
32
+ assert("weak", strength.status);
33
+ });
34
+
35
+ $("#password").trigger("keydown");
36
+ }},
37
+
38
+ // Apply callback when username is triggered
39
+ testApplyCallbackWhenUsernameIsTriggered: function() { with(this) {
40
+ $.strength("#username", "#password");
41
+ $("#username").trigger("keydown");
42
+
43
+ assertEqual(1, $("img.strength").length);
44
+ }},
45
+
46
+ // Apply weak status to image
47
+ testApplyWeakStatusToImage: function() { with(this) {
48
+ $.strength("#username", "#password");
49
+ $("#password").trigger("keydown");
50
+
51
+ assertEqual(1, $("img.weak").length);
52
+ assertEqual("/images/weak.png", $("img.strength").attr("src"));
53
+ }},
54
+
55
+ // Apply good status to image
56
+ testApplyGoodStatusToImage: function() { with(this) {
57
+ $("#password").val("12345asdfg");
58
+ $.strength("#username", "#password");
59
+ $("#password").trigger("keydown");
60
+
61
+ assertEqual(1, $("img.good").length);
62
+ assertEqual("/images/good.png", $("img.strength").attr("src"));
63
+ }},
64
+
65
+ // Apply strong status to image
66
+ testApplyStrongStatusToImage: function() { with(this) {
67
+ $("#password").val("^P4ssw0rd$");
68
+ $.strength("#username", "#password");
69
+ $("#password").trigger("keydown");
70
+
71
+ assertEqual(1, $("img.strong").length);
72
+ assertEqual("/images/strong.png", $("img.strength").attr("src"));
73
+ }},
74
+ });
@@ -5,6 +5,8 @@
5
5
  <title>JavaScript unit test file</title>
6
6
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7
7
  <script src="jsunittest/jsunittest.js" type="text/javascript"></script>
8
+ <script src="../lib/password_strength.js" type="text/javascript"></script>
9
+
8
10
  <link rel="stylesheet" href="jsunittest/unittest.css" type="text/css" />
9
11
 
10
12
  <style type="text/css" media="screen">
@@ -13,17 +15,6 @@
13
15
  padding: 5px;
14
16
  }
15
17
  </style>
16
- <script type="text/javascript" charset="utf-8">
17
- function log(name, message) {
18
- var tag = document.getElementById("logger");
19
- message = message.toString();
20
- message = message.replace(/&/gm, "&amp;");
21
- message = message.replace(/</gm, "&lt;");
22
- message = message.replace(/>/gm, "&gt;");
23
- tag.innerHTML += "<p><strong>" + name + ":</strong> " + message + "</p>";
24
- }
25
- </script>
26
- <script src="../lib/password_strength.js" type="text/javascript"></script>
27
18
  </head>
28
19
  <body>
29
20
 
@@ -45,6 +36,7 @@
45
36
  <div id="sample">
46
37
  </div>
47
38
  </div>
48
- <script src="password_strength_test.js" type="text/javascript" charset="utf-8"></script>
39
+
40
+ <script src="password_strength_test.js" type="text/javascript"></script>
49
41
  </body>
50
42
  </html>
@@ -17,8 +17,6 @@ new Test.Unit.Runner({
17
17
  assertNotNull(strength.status);
18
18
  }},
19
19
 
20
-
21
-
22
20
  // Good strength
23
21
  testGoodStrength: function() { with(this) {
24
22
  strength.status = "good";
@@ -58,12 +56,6 @@ new Test.Unit.Runner({
58
56
 
59
57
  // Password equals to username
60
58
  testPasswordEqualsToUsername: function() { with(this) {
61
- // @strength.password = "johndoe"
62
- // @strength.test
63
- //
64
- // assert_equal 0, @strength.score
65
- // assert_equal :weak, @strength.status
66
-
67
59
  strength.username = "johndoe";
68
60
  strength.password = "johndoe";
69
61
  strength.test();
@@ -74,12 +66,6 @@ new Test.Unit.Runner({
74
66
 
75
67
  // Strong password
76
68
  testStrongPassword: function() { with(this) {
77
- // @strength.password = "^P4ssw0rd$"
78
- // @strength.test
79
- //
80
- // assert_equal 100, @strength.score
81
- // assert_equal :strong, @strength.status
82
-
83
69
  strength.password = "^P4ssw0rd$";
84
70
  strength.test();
85
71
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: password_strength
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
@@ -34,6 +34,7 @@ extra_rdoc_files:
34
34
  files:
35
35
  - CHANGELOG.rdoc
36
36
  - README.rdoc
37
+ - lib/jquery.strength.js
37
38
  - lib/password_strength.js
38
39
  - lib/password_strength.rb
39
40
  - lib/password_strength/active_record.rb
@@ -42,6 +43,9 @@ files:
42
43
  - lib/password_strength/base.rb
43
44
  - lib/password_strength/version.rb
44
45
  - test/active_record_test.rb
46
+ - test/jquery-1.4.2.js
47
+ - test/jquery_strength_test.html
48
+ - test/jquery_strength_test.js
45
49
  - test/jsunittest/jsunittest.js
46
50
  - test/jsunittest/unittest.css
47
51
  - test/password_strength_test.html