Sha256: f22e852ee4b52c53ac089c579a6ea5634709e168380b64dcf74cc688e300cb8f

Contents?: true

Size: 2 KB

Versions: 17

Compression:

Stored size: 2 KB

Contents

// JSpec - jQuery - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)

JSpec
.requires('jQuery', 'when using jspec.jquery.js')
.include({
  name: 'jQuery',
  
  // --- Initialize
  
  init : function() {
    jQuery.ajaxSetup({ async: false })
  },
  
  // --- Utilities
  
  utilities : {
    element:  jQuery,
    elements: jQuery,
    sandbox : function() {
      return jQuery('<div class="sandbox"></div>')
    }
  },
  
  // --- Matchers
  
  matchers : {
    have_tag      : "jQuery(expected, actual).length === 1",
    have_one      : "alias have_tag",
    have_tags     : "jQuery(expected, actual).length > 1",
    have_many     : "alias have_tags",
    have_any      : "alias have_tags",
    have_child    : "jQuery(actual).children(expected).length === 1",
    have_children : "jQuery(actual).children(expected).length > 1",
    have_text     : "jQuery(actual).text() === expected",
    have_value    : "jQuery(actual).val() === expected",
    be_enabled    : "!jQuery(actual).attr('disabled')",
    have_class    : "jQuery(actual).hasClass(expected)",
    
    be_visible : function(actual) {
      return jQuery(actual).css('display') != 'none' &&
             jQuery(actual).css('visibility') != 'hidden' &&
             jQuery(actual).attr('type') != 'hidden'
    },
    
    be_hidden : function(actual) {
      return !JSpec.does(actual, 'be_visible')
    },

    have_classes : function(actual) {
      return !JSpec.any(JSpec.toArray(arguments, 1), function(arg){
        return !JSpec.does(actual, 'have_class', arg)
      })
    },

    have_attr : function(actual, attr, value) {
      return value ? jQuery(actual).attr(attr) == value:
                     jQuery(actual).attr(attr)
    },
    
    'be disabled selected checked' : function(attr) {
      return 'jQuery(actual).attr("' + attr + '")'
    },
    
    'have type id title alt href src sel rev name target' : function(attr) {
      return function(actual, value) {
        return JSpec.does(actual, 'have_attr', attr, value)
      }
    }
  }
})

Version data entries

17 entries across 17 versions & 4 rubygems

Version Path
bootcamp-0.1.4 vendor/test_suites/jspec/lib/jspec.jquery.js
bootcamp-0.1.0 vendor/test_suites/jspec/lib/jspec.jquery.js
uki-1.1.4 frameworks/jspec/lib/jspec.jquery.js
uki-1.1.3 frameworks/jspec/lib/jspec.jquery.js
uki-1.1.2 frameworks/jspec/lib/jspec.jquery.js
jspec-steventux-3.3.2.1 lib/jspec.jquery.js
jspec-steventux-3.3.2 lib/jspec.jquery.js
uki-1.1.1 frameworks/jspec/lib/jspec.jquery.js
uki-1.1.0 frameworks/jspec/lib/jspec.jquery.js
uki-1.0.2 frameworks/jspec/lib/jspec.jquery.js
uki-1.0.1 frameworks/jspec/lib/jspec.jquery.js
jspec-4.1.0 lib/jspec.jquery.js
jspec-4.0.0 lib/jspec.jquery.js
uki-1.0.0 frameworks/jspec/lib/jspec.jquery.js
jspec-3.3.3 lib/jspec.jquery.js
jspec-3.3.2 lib/jspec.jquery.js
jspec-3.3.1 lib/jspec.jquery.js