peteshow 0.7.6 → 0.7.7
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.
- checksums.yaml +15 -0
 - data/dist/peteshow.js +42 -23
 - data/dist/peteshow.min.js +2 -2
 - data/lib/assets/javascripts/peteshow.js +42 -23
 - data/lib/assets/javascripts/peteshow.min.js +2 -2
 - data/package.json +1 -1
 - data/peteshow.gemspec +3 -3
 - data/src/peteshow-core.js +40 -21
 - data/src/peteshow-helpers.js +1 -1
 - data/src/peteshow.js +1 -1
 - data/tests/index.html +5 -3
 - data/tests/suite/core.js +23 -13
 - data/tests/suite/helpers.js +14 -13
 - data/tests/suite/keybindings.js +46 -4
 - data/tests/suite/localstorage.js +6 -0
 - data/tests/suite/options.js +43 -0
 - metadata +7 -8
 - data/vendor/peteshow.plugin.js +0 -33
 
    
        data/package.json
    CHANGED
    
    
    
        data/peteshow.gemspec
    CHANGED
    
    | 
         @@ -4,13 +4,13 @@ package = open('package.json').read 
     | 
|
| 
       4 
4 
     | 
    
         
             
            json = JSON.parse(package)
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       7 
     | 
    
         
            -
              s.name        = json['name'] 
     | 
| 
      
 7 
     | 
    
         
            +
              s.name        = json['name']
         
     | 
| 
       8 
8 
     | 
    
         
             
              s.version     = json['version']
         
     | 
| 
       9 
9 
     | 
    
         
             
              s.author      = json['author']['name']
         
     | 
| 
       10 
10 
     | 
    
         
             
              s.email       = json['author']['email']
         
     | 
| 
       11 
     | 
    
         
            -
              s.summary     = 'Javascript plugin for filling out forms with fake data 
     | 
| 
      
 11 
     | 
    
         
            +
              s.summary     = 'Javascript plugin for filling out forms with fake data'
         
     | 
| 
       12 
12 
     | 
    
         
             
              s.description = 'Javascript plugin for filling out forms with fake data for testing purposes'
         
     | 
| 
       13 
     | 
    
         
            -
              s.homepage    = json['homepage'] 
     | 
| 
      
 13 
     | 
    
         
            +
              s.homepage    = json['homepage']
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
              s.files           = `git ls-files`.split($\)
         
     | 
| 
       16 
16 
     | 
    
         
             
              s.require_paths   = ['lib']
         
     | 
    
        data/src/peteshow-core.js
    CHANGED
    
    | 
         @@ -6,7 +6,7 @@ 
     | 
|
| 
       6 
6 
     | 
    
         
             
                  'input[type=email], input[name*=email]'       : Peteshow.randomEmail(),
         
     | 
| 
       7 
7 
     | 
    
         
             
                  'input[name*=number], input[type=number]'     : Peteshow.randomNumber(8),
         
     | 
| 
       8 
8 
     | 
    
         
             
                  'input[class*=number], input[class*=decimal]' : Peteshow.randomNumber(8),
         
     | 
| 
       9 
     | 
    
         
            -
                  'input[ 
     | 
| 
      
 9 
     | 
    
         
            +
                  'input[type=date]'                            : Peteshow.randomDate(),
         
     | 
| 
       10 
10 
     | 
    
         
             
                  'input[name*=phone]'                          : Faker.PhoneNumber.phoneNumberFormat(5),
         
     | 
| 
       11 
11 
     | 
    
         
             
                  'input[name*=first_name]'                     : Faker.Name.firstName(),
         
     | 
| 
       12 
12 
     | 
    
         
             
                  'input[name*=last_name]'                      : Faker.Name.lastName(),
         
     | 
| 
         @@ -39,10 +39,31 @@ 
     | 
|
| 
       39 
39 
     | 
    
         | 
| 
       40 
40 
     | 
    
         
             
                $('body').append($div)
         
     | 
| 
       41 
41 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
                 
     | 
| 
      
 42 
     | 
    
         
            +
                initCommands()
         
     | 
| 
       43 
43 
     | 
    
         
             
              }
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
       45 
     | 
    
         
            -
              Peteshow. 
     | 
| 
      
 45 
     | 
    
         
            +
              Peteshow.destroy = function() {
         
     | 
| 
      
 46 
     | 
    
         
            +
                Peteshow.hide()
         
     | 
| 
      
 47 
     | 
    
         
            +
                $div.remove();
         
     | 
| 
      
 48 
     | 
    
         
            +
              }
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
              Peteshow.hide = function() {
         
     | 
| 
      
 51 
     | 
    
         
            +
                $div.hide()
         
     | 
| 
      
 52 
     | 
    
         
            +
                $div.removeClass('active')
         
     | 
| 
      
 53 
     | 
    
         
            +
              }
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
              Peteshow.toggle = function() {
         
     | 
| 
      
 56 
     | 
    
         
            +
                $tools.toggle()
         
     | 
| 
      
 57 
     | 
    
         
            +
                $div.toggleClass('active')
         
     | 
| 
      
 58 
     | 
    
         
            +
              }
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              Peteshow.show = function() {
         
     | 
| 
      
 61 
     | 
    
         
            +
                $div.show()
         
     | 
| 
      
 62 
     | 
    
         
            +
                $tools.show()
         
     | 
| 
      
 63 
     | 
    
         
            +
                if(!$div.hasClass('active')) $div.addClass('active')
         
     | 
| 
      
 64 
     | 
    
         
            +
              }
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
              handleKeypress = function(e) {
         
     | 
| 
       46 
67 
     | 
    
         
             
                var key   = (typeof e.which == 'number') ? e.which : e.keyCode,
         
     | 
| 
       47 
68 
     | 
    
         
             
                    code  = String.fromCharCode(e.keyCode)
         
     | 
| 
       48 
69 
     | 
    
         | 
| 
         @@ -53,8 +74,7 @@ 
     | 
|
| 
       53 
74 
     | 
    
         
             
                if(e.metaKey) return
         
     | 
| 
       54 
75 
     | 
    
         | 
| 
       55 
76 
     | 
    
         
             
                if(e.keyCode == 192) { // `
         
     | 
| 
       56 
     | 
    
         
            -
                   
     | 
| 
       57 
     | 
    
         
            -
                  $div.toggleClass('active')
         
     | 
| 
      
 77 
     | 
    
         
            +
                  Peteshow.toggle()
         
     | 
| 
       58 
78 
     | 
    
         
             
                }
         
     | 
| 
       59 
79 
     | 
    
         | 
| 
       60 
80 
     | 
    
         
             
                var action  = $("[data-command='"+code+"']"),
         
     | 
| 
         @@ -63,7 +83,7 @@ 
     | 
|
| 
       63 
83 
     | 
    
         
             
                if(action.length > 0 && visible) action.click()
         
     | 
| 
       64 
84 
     | 
    
         
             
              }
         
     | 
| 
       65 
85 
     | 
    
         | 
| 
       66 
     | 
    
         
            -
               
     | 
| 
      
 86 
     | 
    
         
            +
              initCommands = function() {
         
     | 
| 
       67 
87 
     | 
    
         
             
                var base =  "<li><a data-command='F' href='#' id='fill-out-forms'>Fill Out Forms</a></li>"
         
     | 
| 
       68 
88 
     | 
    
         
             
                    base += "<li><a data-command='Q' href='#' id='fill-out-forms-and-submit'>Fill Out and Submit</a></li>"
         
     | 
| 
       69 
89 
     | 
    
         
             
                    base += outputLocalStorage()
         
     | 
| 
         @@ -71,16 +91,16 @@ 
     | 
|
| 
       71 
91 
     | 
    
         | 
| 
       72 
92 
     | 
    
         
             
                $div.find($commands).html(_options.commands + base)
         
     | 
| 
       73 
93 
     | 
    
         | 
| 
       74 
     | 
    
         
            -
                 
     | 
| 
      
 94 
     | 
    
         
            +
                bindEvents()
         
     | 
| 
       75 
95 
     | 
    
         
             
              }
         
     | 
| 
       76 
96 
     | 
    
         | 
| 
       77 
     | 
    
         
            -
               
     | 
| 
      
 97 
     | 
    
         
            +
              bindEvents = function() {
         
     | 
| 
       78 
98 
     | 
    
         
             
                var commands = [
         
     | 
| 
       79 
     | 
    
         
            -
                  [ $toggle,                          function() {  
     | 
| 
      
 99 
     | 
    
         
            +
                  [ $toggle,                          function() { Peteshow.toggle } ],
         
     | 
| 
       80 
100 
     | 
    
         
             
                  [ $('#fill-out-forms'),             function() { Peteshow.fillOutForms() } ],
         
     | 
| 
       81 
101 
     | 
    
         
             
                  [ $('#fill-out-forms-and-submit'),  function() { Peteshow.fillOutForms(); Peteshow.submitForm() } ],
         
     | 
| 
       82 
     | 
    
         
            -
                  [ $('#clear-localstorage'),         function() { clearLocalStorage() } ],
         
     | 
| 
       83 
     | 
    
         
            -
                  [ $('#hide-peteshow'),              function() {  
     | 
| 
      
 102 
     | 
    
         
            +
                  [ $('#clear-localstorage'),         function() { Peteshow.clearLocalStorage() } ],
         
     | 
| 
      
 103 
     | 
    
         
            +
                  [ $('#hide-peteshow'),              function() { Peteshow.hide() } ]
         
     | 
| 
       84 
104 
     | 
    
         
             
                ]
         
     | 
| 
       85 
105 
     | 
    
         | 
| 
       86 
106 
     | 
    
         
             
                $.each(commands, function() {
         
     | 
| 
         @@ -97,7 +117,7 @@ 
     | 
|
| 
       97 
117 
     | 
    
         | 
| 
       98 
118 
     | 
    
         
             
              Peteshow.submitForm = function() {
         
     | 
| 
       99 
119 
     | 
    
         
             
                $(_options.form).submit()
         
     | 
| 
       100 
     | 
    
         
            -
                $('.simple_form'). 
     | 
| 
      
 120 
     | 
    
         
            +
                $('form[name*=registration], .simple_form').submit()
         
     | 
| 
       101 
121 
     | 
    
         
             
                $('form').last().submit()
         
     | 
| 
       102 
122 
     | 
    
         
             
              };
         
     | 
| 
       103 
123 
     | 
    
         | 
| 
         @@ -123,7 +143,7 @@ 
     | 
|
| 
       123 
143 
     | 
    
         
             
                // apply rules
         
     | 
| 
       124 
144 
     | 
    
         
             
                var rules     = $.extend(true, getDefaultRules(), _options.rules || {})
         
     | 
| 
       125 
145 
     | 
    
         
             
                    reused    = {},
         
     | 
| 
       126 
     | 
    
         
            -
                    ls        = getLocalStorage(),
         
     | 
| 
      
 146 
     | 
    
         
            +
                    ls        = Peteshow.getLocalStorage(),
         
     | 
| 
       127 
147 
     | 
    
         
             
                    local     = (ls != null || ls != undefined) ? ls : {}
         
     | 
| 
       128 
148 
     | 
    
         | 
| 
       129 
149 
     | 
    
         
             
                // apply value to rule element, if visible and not in ignore list
         
     | 
| 
         @@ -162,7 +182,7 @@ 
     | 
|
| 
       162 
182 
     | 
    
         | 
| 
       163 
183 
     | 
    
         
             
                // apply localstorage rule values if they exist and on the right page
         
     | 
| 
       164 
184 
     | 
    
         
             
                if(localStorage.peteshow != undefined || localStorage.peteshow != null) {
         
     | 
| 
       165 
     | 
    
         
            -
                  $.each(getLocalStorage(), function(element,v) {
         
     | 
| 
      
 185 
     | 
    
         
            +
                  $.each(Peteshow.getLocalStorage(), function(element,v) {
         
     | 
| 
       166 
186 
     | 
    
         
             
                    var url = _options.reuse[element]
         
     | 
| 
       167 
187 
     | 
    
         | 
| 
       168 
188 
     | 
    
         
             
                    if(window.location.href.indexOf(url) > -1)
         
     | 
| 
         @@ -170,7 +190,7 @@ 
     | 
|
| 
       170 
190 
     | 
    
         
             
                  })
         
     | 
| 
       171 
191 
     | 
    
         | 
| 
       172 
192 
     | 
    
         
             
                  // reinit menu
         
     | 
| 
       173 
     | 
    
         
            -
                   
     | 
| 
      
 193 
     | 
    
         
            +
                  initCommands()
         
     | 
| 
       174 
194 
     | 
    
         
             
                }
         
     | 
| 
       175 
195 
     | 
    
         
             
              }
         
     | 
| 
       176 
196 
     | 
    
         | 
| 
         @@ -179,7 +199,7 @@ 
     | 
|
| 
       179 
199 
     | 
    
         
             
                if(localStorage.peteshow != undefined || localStorage.peteshow != null) {
         
     | 
| 
       180 
200 
     | 
    
         
             
                  base += "<li class='list'>"
         
     | 
| 
       181 
201 
     | 
    
         
             
                    base += "<div class='inner'>"
         
     | 
| 
       182 
     | 
    
         
            -
                      $.each(getLocalStorage(), function(k,v) {
         
     | 
| 
      
 202 
     | 
    
         
            +
                      $.each(Peteshow.getLocalStorage(), function(k,v) {
         
     | 
| 
       183 
203 
     | 
    
         
             
                        base += '<div>' + k + '<span>' + v + '</span></div>'
         
     | 
| 
       184 
204 
     | 
    
         
             
                      })
         
     | 
| 
       185 
205 
     | 
    
         
             
                    base += "</div>"
         
     | 
| 
         @@ -190,13 +210,13 @@ 
     | 
|
| 
       190 
210 
     | 
    
         
             
                return base
         
     | 
| 
       191 
211 
     | 
    
         
             
              }
         
     | 
| 
       192 
212 
     | 
    
         | 
| 
       193 
     | 
    
         
            -
              getLocalStorage = function() {
         
     | 
| 
      
 213 
     | 
    
         
            +
              Peteshow.getLocalStorage = function() {
         
     | 
| 
       194 
214 
     | 
    
         
             
                return JSON.parse(localStorage.getItem('peteshow'))
         
     | 
| 
       195 
215 
     | 
    
         
             
              }
         
     | 
| 
       196 
216 
     | 
    
         | 
| 
       197 
     | 
    
         
            -
              clearLocalStorage = function() {
         
     | 
| 
      
 217 
     | 
    
         
            +
              Peteshow.clearLocalStorage = function() {
         
     | 
| 
       198 
218 
     | 
    
         
             
                localStorage.removeItem('peteshow')
         
     | 
| 
       199 
     | 
    
         
            -
                 
     | 
| 
      
 219 
     | 
    
         
            +
                initCommands()
         
     | 
| 
       200 
220 
     | 
    
         
             
              }
         
     | 
| 
       201 
221 
     | 
    
         | 
| 
       202 
222 
     | 
    
         
             
              randomSelectValue = function(i,select) {
         
     | 
| 
         @@ -235,6 +255,5 @@ 
     | 
|
| 
       235 
255 
     | 
    
         
             
                })
         
     | 
| 
       236 
256 
     | 
    
         
             
              }
         
     | 
| 
       237 
257 
     | 
    
         | 
| 
       238 
     | 
    
         
            -
              $(document).keydown( 
     | 
| 
       239 
     | 
    
         
            -
             
     | 
| 
      
 258 
     | 
    
         
            +
              $(document).keydown(handleKeypress);
         
     | 
| 
       240 
259 
     | 
    
         
             
            }(jQuery)
         
     | 
    
        data/src/peteshow-helpers.js
    CHANGED
    
    | 
         @@ -31,7 +31,7 @@ 
     | 
|
| 
       31 
31 
     | 
    
         
             
              }
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
              Peteshow.randomDate = function(format) {
         
     | 
| 
       34 
     | 
    
         
            -
                if(typeof format === 'undefined' || format === null) format = 'mm 
     | 
| 
      
 34 
     | 
    
         
            +
                if(typeof format === 'undefined' || format === null) format = 'yy-mm-dd'
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
36 
     | 
    
         
             
                var start   = new Date(1942, 1, 1),
         
     | 
| 
       37 
37 
     | 
    
         
             
                    end     = new Date(1970, 1, 1)
         
     | 
    
        data/src/peteshow.js
    CHANGED
    
    
    
        data/tests/index.html
    CHANGED
    
    | 
         @@ -9,14 +9,15 @@ 
     | 
|
| 
       9 
9 
     | 
    
         
             
              <body>
         
     | 
| 
       10 
10 
     | 
    
         
             
                <div id='qunit'></div>
         
     | 
| 
       11 
11 
     | 
    
         
             
                <div id='qunit-fixture'>
         
     | 
| 
       12 
     | 
    
         
            -
                  <form  
     | 
| 
      
 12 
     | 
    
         
            +
                  <form name='random'>
         
     | 
| 
       13 
13 
     | 
    
         
             
                    <input name='password' type='password' />
         
     | 
| 
       14 
14 
     | 
    
         
             
                    <input name='text' type='text' />
         
     | 
| 
       15 
15 
     | 
    
         
             
                    <input name='email' type='email' />
         
     | 
| 
      
 16 
     | 
    
         
            +
                    <input name='email2' type='text' />
         
     | 
| 
       16 
17 
     | 
    
         
             
                    <input name='number' type='number' >
         
     | 
| 
      
 18 
     | 
    
         
            +
                    <input name='date ' type='date' >
         
     | 
| 
       17 
19 
     | 
    
         
             
                    <input name='decimal' type='text' >
         
     | 
| 
       18 
20 
     | 
    
         
             
                    <input name='number' type='text' >
         
     | 
| 
       19 
     | 
    
         
            -
                    <input name='date' type='text' />
         
     | 
| 
       20 
21 
     | 
    
         
             
                    <input name='phone' type='text' />
         
     | 
| 
       21 
22 
     | 
    
         
             
                    <input name='tel' type='tel' >
         
     | 
| 
       22 
23 
     | 
    
         
             
                    <input name='first_name' type='text /'>
         
     | 
| 
         @@ -48,11 +49,12 @@ 
     | 
|
| 
       48 
49 
     | 
    
         
             
                  <script src='../src/peteshow.js'></script>
         
     | 
| 
       49 
50 
     | 
    
         
             
                  <script src='../src/peteshow-core.js'></script>
         
     | 
| 
       50 
51 
     | 
    
         
             
                  <script src='../src/peteshow-helpers.js'></script>
         
     | 
| 
       51 
     | 
    
         
            -
                  <script src='../vendor/peteshow.plugin.js'></script>
         
     | 
| 
       52 
52 
     | 
    
         | 
| 
       53 
53 
     | 
    
         
             
                  <script src='./suite/core.js'></script>
         
     | 
| 
       54 
54 
     | 
    
         
             
                  <script src='./suite/helpers.js'></script>
         
     | 
| 
       55 
55 
     | 
    
         
             
                  <script src='./suite/keybindings.js'></script>
         
     | 
| 
      
 56 
     | 
    
         
            +
                  <script src='./suite/options.js'></script>
         
     | 
| 
      
 57 
     | 
    
         
            +
                  <script src='./suite/localstorage.js'></script>
         
     | 
| 
       56 
58 
     | 
    
         
             
                </div>
         
     | 
| 
       57 
59 
     | 
    
         
             
              </body>
         
     | 
| 
       58 
60 
     | 
    
         
             
            </html>
         
     | 
    
        data/tests/suite/core.js
    CHANGED
    
    | 
         @@ -1,20 +1,29 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            module('core plugin', {
         
     | 
| 
      
 2 
     | 
    
         
            +
              setup: function() {
         
     | 
| 
      
 3 
     | 
    
         
            +
                Peteshow.init({
         
     | 
| 
      
 4 
     | 
    
         
            +
                  rules  : {'input[name*=zip]' : '60611', }
         
     | 
| 
      
 5 
     | 
    
         
            +
                });
         
     | 
| 
      
 6 
     | 
    
         
            +
              },
         
     | 
| 
      
 7 
     | 
    
         
            +
              teardown: function() {
         
     | 
| 
      
 8 
     | 
    
         
            +
                Peteshow.destroy();
         
     | 
| 
      
 9 
     | 
    
         
            +
              }
         
     | 
| 
      
 10 
     | 
    
         
            +
            });
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            test('should have been added to the dom', function() {
         
     | 
| 
      
 13 
     | 
    
         
            +
              equal(1, $('#peteshow').length, 'peteshow exists')
         
     | 
| 
       4 
14 
     | 
    
         
             
            });
         
     | 
| 
       5 
15 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 16 
     | 
    
         
            +
            test('should have valid values after filling out forms', function() {
         
     | 
| 
       7 
17 
     | 
    
         
             
              Peteshow.fillOutForms();
         
     | 
| 
       8 
18 
     | 
    
         | 
| 
       9 
19 
     | 
    
         
             
              NUMBER_REGEX        = /^[0-9]*$/
         
     | 
| 
       10 
     | 
    
         
            -
              TEXT_REGEX          = /^[a-zA-Z0-9 
     | 
| 
      
 20 
     | 
    
         
            +
              TEXT_REGEX          = /^[a-zA-Z0-9.',\/_ -]+$/
         
     | 
| 
       11 
21 
     | 
    
         
             
              EMAIL_REGEX         = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i
         
     | 
| 
       12 
     | 
    
         
            -
              DATE_REGEX          =  
     | 
| 
      
 22 
     | 
    
         
            +
              DATE_REGEX          = /^(19|20)\d\d([- /.])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$/
         
     | 
| 
       13 
23 
     | 
    
         
             
              PHONE_NUMBER_REGEX  = /\(\d{3}\)\d{3}-\d{4}/
         
     | 
| 
       14 
24 
     | 
    
         | 
| 
       15 
25 
     | 
    
         
             
              // from plugin
         
     | 
| 
       16 
     | 
    
         
            -
               
     | 
| 
       17 
     | 
    
         
            -
              assert.equal(true, TEXT_REGEX.test($('input[name*=county]').val()), 'rule loaded from plugin, function');
         
     | 
| 
      
 26 
     | 
    
         
            +
              equal('60611', $('input[name*=zip]').val(), 'rule loaded from plugin, string');
         
     | 
| 
       18 
27 
     | 
    
         | 
| 
       19 
28 
     | 
    
         
             
              // from defaults
         
     | 
| 
       20 
29 
     | 
    
         
             
              var fields = {
         
     | 
| 
         @@ -22,8 +31,8 @@ QUnit.test('fill out form functionality', function(assert) { 
     | 
|
| 
       22 
31 
     | 
    
         
             
                'input[type=text]'                            : TEXT_REGEX,
         
     | 
| 
       23 
32 
     | 
    
         
             
                'input[type=email], input[name*=email]'       : EMAIL_REGEX,
         
     | 
| 
       24 
33 
     | 
    
         
             
                'input[name*=number], input[type=number]'     : NUMBER_REGEX,
         
     | 
| 
       25 
     | 
    
         
            -
                'input[name*=date]'                           : DATE_REGEX,
         
     | 
| 
       26 
34 
     | 
    
         
             
                'input[name*=phone]'                          : PHONE_NUMBER_REGEX,
         
     | 
| 
      
 35 
     | 
    
         
            +
                'input[type=date]'                            : DATE_REGEX,
         
     | 
| 
       27 
36 
     | 
    
         
             
                'input[name*=first_name]'                     : TEXT_REGEX,
         
     | 
| 
       28 
37 
     | 
    
         
             
                'input[name*=last_name]'                      : TEXT_REGEX,
         
     | 
| 
       29 
38 
     | 
    
         
             
                'input[name*=company]'                        : TEXT_REGEX,
         
     | 
| 
         @@ -41,9 +50,10 @@ QUnit.test('fill out form functionality', function(assert) { 
     | 
|
| 
       41 
50 
     | 
    
         
             
              }
         
     | 
| 
       42 
51 
     | 
    
         | 
| 
       43 
52 
     | 
    
         
             
              $.each(fields, function(k,v) {
         
     | 
| 
       44 
     | 
    
         
            -
                if(v.hasOwnProperty('source'))
         
     | 
| 
       45 
     | 
    
         
            -
                   
     | 
| 
       46 
     | 
    
         
            -
                else
         
     | 
| 
       47 
     | 
    
         
            -
                   
     | 
| 
      
 53 
     | 
    
         
            +
                if(v.hasOwnProperty('source')) { // is a regex
         
     | 
| 
      
 54 
     | 
    
         
            +
                  equal(true, v.test($(k).val()), 'testing ' + k + ' regex');
         
     | 
| 
      
 55 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 56 
     | 
    
         
            +
                  equal(v, $(k).val(), 'testing ' + k + ' string');
         
     | 
| 
      
 57 
     | 
    
         
            +
                }
         
     | 
| 
       48 
58 
     | 
    
         
             
              });
         
     | 
| 
       49 
59 
     | 
    
         
             
            });
         
     | 
    
        data/tests/suite/helpers.js
    CHANGED
    
    | 
         @@ -1,18 +1,19 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            module('helpers');
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            test('peteshow functions exist', function() {
         
     | 
| 
      
 4 
     | 
    
         
            +
              equal(true, $.isPlainObject(Peteshow), 'window.Peteshow exists');
         
     | 
| 
       3 
5 
     | 
    
         | 
| 
       4 
6 
     | 
    
         
             
              // helpers exist
         
     | 
| 
       5 
     | 
    
         
            -
               
     | 
| 
       6 
     | 
    
         
            -
               
     | 
| 
       7 
     | 
    
         
            -
               
     | 
| 
       8 
     | 
    
         
            -
               
     | 
| 
       9 
     | 
    
         
            -
               
     | 
| 
       10 
     | 
    
         
            -
               
     | 
| 
       11 
     | 
    
         
            -
               
     | 
| 
      
 7 
     | 
    
         
            +
              equal(true, $.isFunction(Peteshow.randomChars), 'randomChars helper is a function');
         
     | 
| 
      
 8 
     | 
    
         
            +
              equal(true, $.isFunction(Peteshow.randomLetters), 'randomLetershelper is a function');
         
     | 
| 
      
 9 
     | 
    
         
            +
              equal(true, $.isFunction(Peteshow.randomNumberRange), 'randomNumberRange helper is a function');
         
     | 
| 
      
 10 
     | 
    
         
            +
              equal(true, $.isFunction(Peteshow.randomNumber), 'randomNumber helper is a function');
         
     | 
| 
      
 11 
     | 
    
         
            +
              equal(true, $.isFunction(Peteshow.randomDate), 'randomDate helper is a function');
         
     | 
| 
      
 12 
     | 
    
         
            +
              equal(true, $.isFunction(Peteshow.randomEmail), 'randomEmail helper is a function');
         
     | 
| 
      
 13 
     | 
    
         
            +
              equal(true, $.isFunction(Peteshow.formatDate), 'formatDate helper is a function');
         
     | 
| 
       12 
14 
     | 
    
         | 
| 
       13 
15 
     | 
    
         
             
              // core exists
         
     | 
| 
       14 
     | 
    
         
            -
               
     | 
| 
       15 
     | 
    
         
            -
               
     | 
| 
       16 
     | 
    
         
            -
               
     | 
| 
      
 16 
     | 
    
         
            +
              equal(true, $.isFunction(Peteshow.init), 'init helper is a function');
         
     | 
| 
      
 17 
     | 
    
         
            +
              equal(true, $.isFunction(Peteshow.fillOutForms), 'fillOutForms helper is a function');
         
     | 
| 
      
 18 
     | 
    
         
            +
              equal(true, $.isFunction(Peteshow.submitForm), 'submitForm helper is a function');
         
     | 
| 
       17 
19 
     | 
    
         
             
            });
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
    
        data/tests/suite/keybindings.js
    CHANGED
    
    | 
         @@ -1,13 +1,55 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            module('keybindings', {
         
     | 
| 
      
 2 
     | 
    
         
            +
              setup: function() {
         
     | 
| 
      
 3 
     | 
    
         
            +
                Peteshow.init();
         
     | 
| 
      
 4 
     | 
    
         
            +
                Peteshow.show();
         
     | 
| 
      
 5 
     | 
    
         
            +
              },
         
     | 
| 
      
 6 
     | 
    
         
            +
              teardown: function() {
         
     | 
| 
      
 7 
     | 
    
         
            +
                Peteshow.destroy();
         
     | 
| 
      
 8 
     | 
    
         
            +
              }
         
     | 
| 
      
 9 
     | 
    
         
            +
            });
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            test('should show when backtick is pressed', function() {
         
     | 
| 
      
 12 
     | 
    
         
            +
              ok($('#peteshow').hasClass('active'));
         
     | 
| 
      
 13 
     | 
    
         
            +
            });
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            test('should fill out forms when F is pressed', function() {
         
     | 
| 
       2 
16 
     | 
    
         
             
              var event = $.Event('keydown');
         
     | 
| 
       3 
17 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
              event.keyCode =  
     | 
| 
      
 18 
     | 
    
         
            +
              event.keyCode = 70;
         
     | 
| 
       5 
19 
     | 
    
         
             
              $(document).trigger(event);
         
     | 
| 
       6 
20 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
               
     | 
| 
      
 21 
     | 
    
         
            +
              ok($('form input').first().val() != '')
         
     | 
| 
      
 22 
     | 
    
         
            +
            });
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            test('should clear localstorage when R is pressed', function() {
         
     | 
| 
      
 25 
     | 
    
         
            +
              var event = $.Event('keydown');
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              event.keyCode = 82;
         
     | 
| 
      
 28 
     | 
    
         
            +
              $(document).trigger(event);
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              ok(localStorage.getItem('peteshow') == null)
         
     | 
| 
      
 31 
     | 
    
         
            +
            });
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            test('should fill out forms and submit when Q is pressed', function() {
         
     | 
| 
      
 34 
     | 
    
         
            +
              expect(1);
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              var event = $.Event('keydown');
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              $('form').on('submit', function() {
         
     | 
| 
      
 39 
     | 
    
         
            +
                ok(true, 'form submitted')
         
     | 
| 
      
 40 
     | 
    
         
            +
                return false;
         
     | 
| 
      
 41 
     | 
    
         
            +
              });
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              event.keyCode = 81;
         
     | 
| 
      
 44 
     | 
    
         
            +
              $(document).trigger(event);
         
     | 
| 
      
 45 
     | 
    
         
            +
            });
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            test('should hide when H is pressed', function() {
         
     | 
| 
      
 48 
     | 
    
         
            +
              var event = $.Event('keydown');
         
     | 
| 
       8 
49 
     | 
    
         | 
| 
       9 
50 
     | 
    
         
             
              event.keyCode = 72;
         
     | 
| 
       10 
51 
     | 
    
         
             
              $(document).trigger(event);
         
     | 
| 
       11 
52 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
               
     | 
| 
      
 53 
     | 
    
         
            +
              equal(false, $('#peteshow').is(':visible'));
         
     | 
| 
       13 
54 
     | 
    
         
             
            });
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,43 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module('options', {
         
     | 
| 
      
 2 
     | 
    
         
            +
              setup: function() {
         
     | 
| 
      
 3 
     | 
    
         
            +
                Peteshow.init({
         
     | 
| 
      
 4 
     | 
    
         
            +
                  form          : '#random',
         
     | 
| 
      
 5 
     | 
    
         
            +
                  emailPrefix   : 'pete-',
         
     | 
| 
      
 6 
     | 
    
         
            +
                  emailDomain   : 'peteshow.com',
         
     | 
| 
      
 7 
     | 
    
         
            +
                  blur          : 'true'
         
     | 
| 
      
 8 
     | 
    
         
            +
                });
         
     | 
| 
      
 9 
     | 
    
         
            +
              },
         
     | 
| 
      
 10 
     | 
    
         
            +
              teardown: function() {
         
     | 
| 
      
 11 
     | 
    
         
            +
                Peteshow.destroy();
         
     | 
| 
      
 12 
     | 
    
         
            +
              }
         
     | 
| 
      
 13 
     | 
    
         
            +
            });
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            test('should set email options', function() {
         
     | 
| 
      
 16 
     | 
    
         
            +
              Peteshow.fillOutForms();
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              var email = $('input[name*=email]').val().split('@')
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              equal(true, /pete-/.test(email[0]), 'emailPrefix can be set')
         
     | 
| 
      
 21 
     | 
    
         
            +
              equal('peteshow.com', email[1], 'emailDomain can be set')
         
     | 
| 
      
 22 
     | 
    
         
            +
            });
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            test('should blur after filling out if true', function() {
         
     | 
| 
      
 25 
     | 
    
         
            +
              expect(1);
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              $('input[type=email]').on('blur', function() {
         
     | 
| 
      
 28 
     | 
    
         
            +
                ok(true, 'blur functionality works');
         
     | 
| 
      
 29 
     | 
    
         
            +
              });
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              Peteshow.fillOutForms();
         
     | 
| 
      
 32 
     | 
    
         
            +
            });
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            test('should fill out custom form name', function() {
         
     | 
| 
      
 35 
     | 
    
         
            +
              expect(1);
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              $('form[name*=random]').on('submit', function() {
         
     | 
| 
      
 38 
     | 
    
         
            +
                ok(true, 'submit form works');
         
     | 
| 
      
 39 
     | 
    
         
            +
                return false
         
     | 
| 
      
 40 
     | 
    
         
            +
              });
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
              Peteshow.submitForm();
         
     | 
| 
      
 43 
     | 
    
         
            +
            });
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,15 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: peteshow
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.7. 
     | 
| 
       5 
     | 
    
         
            -
              prerelease: 
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.7.7
         
     | 
| 
       6 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       8 
7 
     | 
    
         
             
            - Pete Brousalis
         
     | 
| 
       9 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2014-07- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-07-17 00:00:00.000000000 Z
         
     | 
| 
       13 
12 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       14 
13 
     | 
    
         
             
            description: Javascript plugin for filling out forms with fake data for testing purposes
         
     | 
| 
       15 
14 
     | 
    
         
             
            email: brousapg@gmail.com
         
     | 
| 
         @@ -43,34 +42,34 @@ files: 
     | 
|
| 
       43 
42 
     | 
    
         
             
            - tests/suite/core.js
         
     | 
| 
       44 
43 
     | 
    
         
             
            - tests/suite/helpers.js
         
     | 
| 
       45 
44 
     | 
    
         
             
            - tests/suite/keybindings.js
         
     | 
| 
      
 45 
     | 
    
         
            +
            - tests/suite/localstorage.js
         
     | 
| 
      
 46 
     | 
    
         
            +
            - tests/suite/options.js
         
     | 
| 
       46 
47 
     | 
    
         
             
            - vendor/faker.js
         
     | 
| 
       47 
48 
     | 
    
         
             
            - vendor/jquery.formatdatetime.js
         
     | 
| 
       48 
     | 
    
         
            -
            - vendor/peteshow.plugin.js
         
     | 
| 
       49 
49 
     | 
    
         
             
            - vendor/qunit/jquery.js
         
     | 
| 
       50 
50 
     | 
    
         
             
            - vendor/qunit/qunit.css
         
     | 
| 
       51 
51 
     | 
    
         
             
            - vendor/qunit/qunit.js
         
     | 
| 
       52 
52 
     | 
    
         
             
            homepage: http://github.com/brousalis/peteshow/
         
     | 
| 
       53 
53 
     | 
    
         
             
            licenses: []
         
     | 
| 
      
 54 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
       54 
55 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       55 
56 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       56 
57 
     | 
    
         
             
            require_paths:
         
     | 
| 
       57 
58 
     | 
    
         
             
            - lib
         
     | 
| 
       58 
59 
     | 
    
         
             
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
       59 
     | 
    
         
            -
              none: false
         
     | 
| 
       60 
60 
     | 
    
         
             
              requirements:
         
     | 
| 
       61 
61 
     | 
    
         
             
              - - ! '>='
         
     | 
| 
       62 
62 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       63 
63 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       64 
64 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       65 
     | 
    
         
            -
              none: false
         
     | 
| 
       66 
65 
     | 
    
         
             
              requirements:
         
     | 
| 
       67 
66 
     | 
    
         
             
              - - ! '>='
         
     | 
| 
       68 
67 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       69 
68 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       70 
69 
     | 
    
         
             
            requirements: []
         
     | 
| 
       71 
70 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       72 
     | 
    
         
            -
            rubygems_version:  
     | 
| 
      
 71 
     | 
    
         
            +
            rubygems_version: 2.2.2
         
     | 
| 
       73 
72 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       74 
     | 
    
         
            -
            specification_version:  
     | 
| 
      
 73 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
       75 
74 
     | 
    
         
             
            summary: Javascript plugin for filling out forms with fake data
         
     | 
| 
       76 
75 
     | 
    
         
             
            test_files: []
         
     | 
    
        data/vendor/peteshow.plugin.js
    DELETED
    
    | 
         @@ -1,33 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            var options = {
         
     | 
| 
       2 
     | 
    
         
            -
              email : {
         
     | 
| 
       3 
     | 
    
         
            -
                domain: 'onstride.co.uk',
         
     | 
| 
       4 
     | 
    
         
            -
              },
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              rules : {
         
     | 
| 
       7 
     | 
    
         
            -
                'input[name*=zip]'      : 'PL25 3JR',
         
     | 
| 
       8 
     | 
    
         
            -
                'input[name*=county]'   : Faker.Address.ukCounty()
         
     | 
| 
       9 
     | 
    
         
            -
              },
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              reuse : {
         
     | 
| 
       12 
     | 
    
         
            -
                'input[name*=first_name]' : 'contract',
         
     | 
| 
       13 
     | 
    
         
            -
                'input[name*=last_name]'  : 'contract',
         
     | 
| 
       14 
     | 
    
         
            -
                'input[name*=birth]'      : 'contract'
         
     | 
| 
       15 
     | 
    
         
            -
              },
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
              ignore : [ 'registration_coupon_code' ],
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
              blur : true,
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
              force : {
         
     | 
| 
       22 
     | 
    
         
            -
                'input[name*=building_name]'        : Peteshow.randomLetters(8),
         
     | 
| 
       23 
     | 
    
         
            -
                'input[name*=line1]'                : Faker.Address.streetName(),
         
     | 
| 
       24 
     | 
    
         
            -
                'input[name*=card_brand]'            : 'visa',
         
     | 
| 
       25 
     | 
    
         
            -
                '#registration_city'                : Faker.Address.city(),
         
     | 
| 
       26 
     | 
    
         
            -
              },
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
              filter: ['unemployed', 'self_employment', 'retired_benefits'],
         
     | 
| 
       29 
     | 
    
         
            -
            }
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
            $(function() {
         
     | 
| 
       32 
     | 
    
         
            -
              Peteshow.init(options)
         
     | 
| 
       33 
     | 
    
         
            -
            });
         
     |