jasmine-fixtures 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.pairs +1 -0
- data/Gemfile +4 -3
- data/Gemfile.lock +3 -2
- data/LICENSE +1 -1
- data/Rakefile +5 -3
- data/VERSION +1 -1
- data/generators/jasmine-fixtures/jasmine_fixtures_generator.rb +2 -3
- data/generators/jasmine-fixtures/templates/INSTALL +3 -4
- data/generators/jasmine-fixtures/templates/spec/controllers/jasmine_fixture_creators.rb +23 -6
- data/generators/jasmine-fixtures/templates/spec/javascripts/helpers/jasmine-fixture-helper.js +6 -7
- data/generators/jasmine-fixtures/templates/spec/javascripts/helpers/jasmine-fixture-loader.js +2 -3
- data/generators/jasmine-fixtures/templates/spec/support/jasmine_fixture_generator_methods.rb +4 -4
- data/jasmine-fixtures.gemspec +13 -8
- metadata +43 -13
- data/generators/jasmine-fixtures/templates/spec/javascripts/helpers/jasmine-fixture-matchers.js +0 -253
data/.gitignore
CHANGED
data/.pairs
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/LICENSE
CHANGED
data/Rakefile
CHANGED
@@ -6,12 +6,14 @@ begin
|
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "jasmine-fixtures"
|
8
8
|
gem.summary = %Q{Jasmine Fixtures allow you to use real DOM to test your JavaScript}
|
9
|
-
gem.description = %Q{Dump out DOM that you want to test. Use jasmine-fixtures to load that DOM into your Jasmine specs. See github.com/mavenlink/jasmine-fixtures for more.}
|
9
|
+
gem.description = %Q{Dump out DOM that you want to test. Use jasmine-fixtures to load that DOM into your Jasmine specs. See http://github.com/mavenlink/jasmine-fixtures for more.}
|
10
10
|
gem.email = "roger@mavenlink.com"
|
11
11
|
gem.homepage = "http://github.com/mavenlink/jasmine-fixtures"
|
12
|
-
gem.authors = ["Roger Neel", "Jonathan Barnes", "JB Steadman"]
|
13
|
-
gem.add_development_dependency "rspec", "
|
12
|
+
gem.authors = ["Roger Neel", "Jonathan Barnes", "JB Steadman", "Andrew Cantino"]
|
13
|
+
gem.add_development_dependency "rspec", "~>1.3"
|
14
|
+
gem.add_development_dependency "rspec-rails", "~>1.3"
|
14
15
|
gem.add_dependency "nokogiri", ">= 1.4.0"
|
16
|
+
gem.add_dependency "jasmine", ">= 1.0.0"
|
15
17
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
18
|
end
|
17
19
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
@@ -4,8 +4,7 @@ class JasmineFixturesGenerator < Rails::Generator::Base
|
|
4
4
|
m.directory "spec/javascripts/helpers"
|
5
5
|
m.file "spec/javascripts/helpers/jasmine-fixture-helper.js", "spec/javascripts/helpers/jasmine-fixture-helper.js"
|
6
6
|
m.file "spec/javascripts/helpers/jasmine-fixture-loader.js", "spec/javascripts/helpers/jasmine-fixture-loader.js"
|
7
|
-
|
8
|
-
|
7
|
+
|
9
8
|
m.directory "spec/support"
|
10
9
|
m.file "spec/support/jasmine_fixture_generator_methods.rb", "spec/support/jasmine_fixture_generator_methods.rb"
|
11
10
|
|
@@ -14,4 +13,4 @@ class JasmineFixturesGenerator < Rails::Generator::Base
|
|
14
13
|
m.readme "INSTALL"
|
15
14
|
end
|
16
15
|
end
|
17
|
-
end
|
16
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
Jasmine Fixtures have been installed!
|
2
2
|
|
3
|
-
We copied
|
3
|
+
We copied the required files into your spec directory.
|
4
|
+
In its default configuration, Jasmine and RSpec should pick these files up.
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
Take a look at https://github.com/mavenlink/jasmine-fixtures for tips & more info.
|
6
|
+
Take a look at https://github.com/mavenlink/jasmine-fixtures for tips & more info.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
#####
|
4
4
|
# Modify this file to create new Jasmine Fixtures!
|
@@ -11,19 +11,36 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
11
11
|
#####
|
12
12
|
|
13
13
|
##### Using save_fixture
|
14
|
-
# html_for will
|
15
|
-
# to avoid nested <body> tags within the
|
14
|
+
# html_for will take the <body> tag and replace it with a <div>
|
15
|
+
# to avoid nested <body> tags within the Jasmine runner
|
16
16
|
|
17
17
|
# If you have custom responses (ajax partials, JSON, etc),
|
18
|
-
# you can subvert this and use response.body or whatever.
|
18
|
+
# you can subvert this and use response.body or whatever is appropriate.
|
19
19
|
#####
|
20
20
|
|
21
21
|
|
22
|
-
#####
|
22
|
+
##### Examples
|
23
23
|
describe UsersController do
|
24
|
+
#You need to integrate_views in each of your describes to get the content of the response
|
25
|
+
integrate_views
|
26
|
+
|
27
|
+
#Example of a standard request that would use html_for to strip <body>
|
24
28
|
it "generates a new user page" do
|
25
29
|
get :new
|
26
30
|
response.should be_success
|
27
31
|
save_fixture(html_for('body'), 'user-signup-page')
|
28
32
|
end
|
29
|
-
|
33
|
+
|
34
|
+
#Example of a logged-in ajax request that doesn't have a body tag to strip out
|
35
|
+
describe "a user's profile" do
|
36
|
+
before do
|
37
|
+
log_in users(:james)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "generates a new user profile xhr" do
|
41
|
+
xhr :get, :show, :id => users(:james).to_param
|
42
|
+
response.should be_success
|
43
|
+
save_fixture(response.body, 'user-profile-page')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/generators/jasmine-fixtures/templates/spec/javascripts/helpers/jasmine-fixture-helper.js
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
if (typeof spec === 'undefined') {
|
2
|
+
var spec = {};
|
3
|
+
}
|
4
|
+
|
1
5
|
beforeEach(function() {
|
2
6
|
$('#jasmine_content').empty();
|
3
7
|
spec.cleanupHooks();
|
@@ -7,16 +11,11 @@ afterEach(function() {
|
|
7
11
|
spec.cleanupHooks();
|
8
12
|
expect(spec.loadFixtureCount).toBeLessThan(2);
|
9
13
|
spec.loadFixtureCount = 0;
|
10
|
-
expect($('.ui-dialog').length).toEqual(0);
|
11
|
-
expect($('.ui-autocomplete-results').length).toEqual(0);
|
12
14
|
});
|
13
15
|
|
14
16
|
spec.cleanupHooks = function() {
|
15
|
-
// clearLiveEventBindings is helpful if using jQuery live events
|
16
|
-
// uncomment if you'd like
|
17
|
+
// clearLiveEventBindings is helpful if using jQuery live events, uncomment if you'd like to use it.
|
17
18
|
// spec.clearLiveEventBindings();
|
18
|
-
|
19
|
-
window.onbeforeunload = null;
|
20
19
|
};
|
21
20
|
|
22
21
|
spec.clearLiveEventBindings = function() {
|
@@ -28,4 +27,4 @@ spec.clearLiveEventBindings = function() {
|
|
28
27
|
|
29
28
|
spec.content = function() {
|
30
29
|
return $('#jasmine_content');
|
31
|
-
};
|
30
|
+
};
|
data/generators/jasmine-fixtures/templates/spec/javascripts/helpers/jasmine-fixture-loader.js
CHANGED
@@ -9,13 +9,12 @@ spec.loadFixture = function(fixtureName) {
|
|
9
9
|
// get the markup, inject it into the dom
|
10
10
|
$destination.html(spec.fixtureHtml(fixtureName) + indicatorScript);
|
11
11
|
while (uniqueLoadIndicator != "loaded") {
|
12
|
-
|
12
|
+
//
|
13
|
+
if (console) console.log("Browser wasn't ready... sleeping.");
|
13
14
|
spec.retrieveFixture(fixtureName);
|
14
15
|
}
|
15
16
|
uniqueLoadIndicator = null;
|
16
17
|
|
17
|
-
bindBehaviors();
|
18
|
-
|
19
18
|
// keep track of fixture count to fail specs that
|
20
19
|
// call loadFixture() more than once
|
21
20
|
spec.loadFixtureCount++;
|
data/generators/jasmine-fixtures/templates/spec/support/jasmine_fixture_generator_methods.rb
CHANGED
@@ -22,11 +22,11 @@ Spec::Rails::Example::ControllerExampleGroup.class_eval do
|
|
22
22
|
remove_third_party_scripts(doc)
|
23
23
|
content = doc.css(selector).first.to_s
|
24
24
|
|
25
|
-
|
25
|
+
convert_body_tag_to_div(content)
|
26
26
|
end
|
27
27
|
|
28
|
-
#
|
29
|
-
#
|
28
|
+
# Recommended that you add all body-level third party scripts inside a div called #third-party-scripts
|
29
|
+
# so that they can be removed during testing.
|
30
30
|
def remove_third_party_scripts(doc)
|
31
31
|
scripts = doc.at('#third-party-scripts')
|
32
32
|
scripts.remove if scripts
|
@@ -40,6 +40,6 @@ Spec::Rails::Example::ControllerExampleGroup.class_eval do
|
|
40
40
|
# Here we convert the body tag to a div so that we can load it into
|
41
41
|
# the document running js specs without embedding a <body> within a <body>.
|
42
42
|
def convert_body_tag_to_div(markup)
|
43
|
-
|
43
|
+
markup.gsub("<body", '<div').gsub("</body>", "</div>")
|
44
44
|
end
|
45
45
|
end
|
data/jasmine-fixtures.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{jasmine-fixtures}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Roger Neel", "Jonathan Barnes", "JB Steadman"]
|
12
|
-
s.date = %q{2010-11-
|
13
|
-
s.description = %q{Dump out DOM that you want to test. Use jasmine-fixtures to load that DOM into your Jasmine specs. See github.com/mavenlink/jasmine-fixtures for more.}
|
11
|
+
s.authors = ["Roger Neel", "Jonathan Barnes", "JB Steadman", "Andrew Cantino"]
|
12
|
+
s.date = %q{2010-11-08}
|
13
|
+
s.description = %q{Dump out DOM that you want to test. Use jasmine-fixtures to load that DOM into your Jasmine specs. See http://github.com/mavenlink/jasmine-fixtures for more.}
|
14
14
|
s.email = %q{roger@mavenlink.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
@@ -32,7 +32,6 @@ Gem::Specification.new do |s|
|
|
32
32
|
"generators/jasmine-fixtures/templates/spec/controllers/jasmine_fixture_creators.rb",
|
33
33
|
"generators/jasmine-fixtures/templates/spec/javascripts/helpers/jasmine-fixture-helper.js",
|
34
34
|
"generators/jasmine-fixtures/templates/spec/javascripts/helpers/jasmine-fixture-loader.js",
|
35
|
-
"generators/jasmine-fixtures/templates/spec/javascripts/helpers/jasmine-fixture-matchers.js",
|
36
35
|
"generators/jasmine-fixtures/templates/spec/support/jasmine_fixture_generator_methods.rb",
|
37
36
|
"jasmine-fixtures.gemspec",
|
38
37
|
"lib/jasmine-fixtures.rb",
|
@@ -55,15 +54,21 @@ Gem::Specification.new do |s|
|
|
55
54
|
s.specification_version = 3
|
56
55
|
|
57
56
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
58
|
-
s.add_development_dependency(%q<rspec>, ["
|
57
|
+
s.add_development_dependency(%q<rspec>, ["~> 1.3"])
|
58
|
+
s.add_development_dependency(%q<rspec-rails>, ["~> 1.3"])
|
59
59
|
s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.0"])
|
60
|
+
s.add_runtime_dependency(%q<jasmine>, [">= 1.0.0"])
|
60
61
|
else
|
61
|
-
s.add_dependency(%q<rspec>, ["
|
62
|
+
s.add_dependency(%q<rspec>, ["~> 1.3"])
|
63
|
+
s.add_dependency(%q<rspec-rails>, ["~> 1.3"])
|
62
64
|
s.add_dependency(%q<nokogiri>, [">= 1.4.0"])
|
65
|
+
s.add_dependency(%q<jasmine>, [">= 1.0.0"])
|
63
66
|
end
|
64
67
|
else
|
65
|
-
s.add_dependency(%q<rspec>, ["
|
68
|
+
s.add_dependency(%q<rspec>, ["~> 1.3"])
|
69
|
+
s.add_dependency(%q<rspec-rails>, ["~> 1.3"])
|
66
70
|
s.add_dependency(%q<nokogiri>, [">= 1.4.0"])
|
71
|
+
s.add_dependency(%q<jasmine>, [">= 1.0.0"])
|
67
72
|
end
|
68
73
|
end
|
69
74
|
|
metadata
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jasmine-fixtures
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Roger Neel
|
14
14
|
- Jonathan Barnes
|
15
15
|
- JB Steadman
|
16
|
+
- Andrew Cantino
|
16
17
|
autorequire:
|
17
18
|
bindir: bin
|
18
19
|
cert_chain: []
|
19
20
|
|
20
|
-
date: 2010-11-
|
21
|
+
date: 2010-11-08 00:00:00 -08:00
|
21
22
|
default_executable:
|
22
23
|
dependencies:
|
23
24
|
- !ruby/object:Gem::Dependency
|
@@ -26,20 +27,34 @@ dependencies:
|
|
26
27
|
requirement: &id001 !ruby/object:Gem::Requirement
|
27
28
|
none: false
|
28
29
|
requirements:
|
29
|
-
- -
|
30
|
+
- - ~>
|
30
31
|
- !ruby/object:Gem::Version
|
31
|
-
hash:
|
32
|
+
hash: 9
|
32
33
|
segments:
|
33
34
|
- 1
|
34
|
-
-
|
35
|
-
|
36
|
-
version: 1.2.9
|
35
|
+
- 3
|
36
|
+
version: "1.3"
|
37
37
|
type: :development
|
38
38
|
version_requirements: *id001
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
|
-
name:
|
40
|
+
name: rspec-rails
|
41
41
|
prerelease: false
|
42
42
|
requirement: &id002 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
hash: 9
|
48
|
+
segments:
|
49
|
+
- 1
|
50
|
+
- 3
|
51
|
+
version: "1.3"
|
52
|
+
type: :development
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: nokogiri
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
43
58
|
none: false
|
44
59
|
requirements:
|
45
60
|
- - ">="
|
@@ -51,8 +66,24 @@ dependencies:
|
|
51
66
|
- 0
|
52
67
|
version: 1.4.0
|
53
68
|
type: :runtime
|
54
|
-
version_requirements: *
|
55
|
-
|
69
|
+
version_requirements: *id003
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: jasmine
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 23
|
79
|
+
segments:
|
80
|
+
- 1
|
81
|
+
- 0
|
82
|
+
- 0
|
83
|
+
version: 1.0.0
|
84
|
+
type: :runtime
|
85
|
+
version_requirements: *id004
|
86
|
+
description: Dump out DOM that you want to test. Use jasmine-fixtures to load that DOM into your Jasmine specs. See http://github.com/mavenlink/jasmine-fixtures for more.
|
56
87
|
email: roger@mavenlink.com
|
57
88
|
executables: []
|
58
89
|
|
@@ -77,7 +108,6 @@ files:
|
|
77
108
|
- generators/jasmine-fixtures/templates/spec/controllers/jasmine_fixture_creators.rb
|
78
109
|
- generators/jasmine-fixtures/templates/spec/javascripts/helpers/jasmine-fixture-helper.js
|
79
110
|
- generators/jasmine-fixtures/templates/spec/javascripts/helpers/jasmine-fixture-loader.js
|
80
|
-
- generators/jasmine-fixtures/templates/spec/javascripts/helpers/jasmine-fixture-matchers.js
|
81
111
|
- generators/jasmine-fixtures/templates/spec/support/jasmine_fixture_generator_methods.rb
|
82
112
|
- jasmine-fixtures.gemspec
|
83
113
|
- lib/jasmine-fixtures.rb
|
data/generators/jasmine-fixtures/templates/spec/javascripts/helpers/jasmine-fixture-matchers.js
DELETED
@@ -1,253 +0,0 @@
|
|
1
|
-
jasmine.Matchers.prototype.toBeSameJqueryObjectAs = function(expected) {
|
2
|
-
var error_message = null;
|
3
|
-
if(!expected || !this.actual || this.actual.length != expected.length) {
|
4
|
-
error_message = "Expected to have same number of matching elements";
|
5
|
-
} else {
|
6
|
-
for(var i = 0; i < expected.length; i++) {
|
7
|
-
if (this.actual.get(i) != expected.get(i)) {
|
8
|
-
error_message = "Expected the elements to be the same but were not";
|
9
|
-
break;
|
10
|
-
}
|
11
|
-
}
|
12
|
-
}
|
13
|
-
return this.report(error_message == null, error_message);
|
14
|
-
};
|
15
|
-
|
16
|
-
jasmine.Matchers.prototype.toNotBeSameJqueryObjectAs = function(expected) {
|
17
|
-
var error_message = null;
|
18
|
-
if(!expected || !this.actual || this.actual.length != expected.length) {
|
19
|
-
error_message = "Expected to have same number of matching elements";
|
20
|
-
} else {
|
21
|
-
for(var i = 0; i < expected.length; i++) {
|
22
|
-
if (this.actual.get(i) == expected.get(i)) {
|
23
|
-
error_message = "Expected the elements to not be the same but they were";
|
24
|
-
break;
|
25
|
-
}
|
26
|
-
}
|
27
|
-
}
|
28
|
-
return this.report(error_message == null, error_message);
|
29
|
-
};
|
30
|
-
|
31
|
-
jasmine.Matchers.prototype.toBeCleared = function() {
|
32
|
-
var $form = this.actual;
|
33
|
-
expect($form).toBeSingleton();
|
34
|
-
var $textfields = $form.find('input[type=text]');
|
35
|
-
$textfields.each(function() {
|
36
|
-
expect($(this).val()).toEqual('');
|
37
|
-
});
|
38
|
-
var $textareas = $form.find('textarea');
|
39
|
-
$textareas.each(function() {
|
40
|
-
expect($(this).val()).toEqual('');
|
41
|
-
});
|
42
|
-
};
|
43
|
-
|
44
|
-
jasmine.Matchers.prototype.toBeSingleton = function() {
|
45
|
-
var $element = this.actual;
|
46
|
-
expect($element.length).toEqual(1);
|
47
|
-
};
|
48
|
-
|
49
|
-
jasmine.Matchers.prototype.toContainText = function(expected) {
|
50
|
-
var actual = $(this.actual);
|
51
|
-
return this.report(
|
52
|
-
actual.text().indexOf(expected) != -1,
|
53
|
-
"Expected $('" + actual.selector + "') to contain text " + expected
|
54
|
-
);
|
55
|
-
};
|
56
|
-
|
57
|
-
jasmine.Matchers.prototype.toNotContainText = function(expected) {
|
58
|
-
var actual = $(this.actual);
|
59
|
-
return this.report(
|
60
|
-
actual.text().indexOf(expected) == -1,
|
61
|
-
"Expected $('" + actual.selector + "') to not contain text " + expected
|
62
|
-
);
|
63
|
-
};
|
64
|
-
|
65
|
-
jasmine.Matchers.prototype.toNotBeChecked = function() {
|
66
|
-
var actual = $(this.actual);
|
67
|
-
return this.report(
|
68
|
-
!actual.is(':checked'),
|
69
|
-
"Expected $('" + actual.selector + "') to not be checked"
|
70
|
-
);
|
71
|
-
};
|
72
|
-
|
73
|
-
jasmine.Matchers.prototype.toBeChecked = function() {
|
74
|
-
var actual = $(this.actual);
|
75
|
-
return this.report(
|
76
|
-
actual.is(':checked'),
|
77
|
-
"Expected $('" + actual.selector + "') to be checked"
|
78
|
-
);
|
79
|
-
};
|
80
|
-
|
81
|
-
jasmine.Matchers.prototype.toExist = function() {
|
82
|
-
var actual = $(this.actual);
|
83
|
-
return this.report(
|
84
|
-
actual.length > 0,
|
85
|
-
"Expected $('" + actual.selector + "') to exist but didn't"
|
86
|
-
);
|
87
|
-
};
|
88
|
-
|
89
|
-
jasmine.Matchers.prototype.toNotExist = function() {
|
90
|
-
var actual = $(this.actual);
|
91
|
-
return this.report(
|
92
|
-
actual.length == 0,
|
93
|
-
"Expected $('" + actual.selector + "') to not exist but it did"
|
94
|
-
);
|
95
|
-
};
|
96
|
-
|
97
|
-
jasmine.Matchers.prototype.toContainSelector = function(expected) {
|
98
|
-
var actual = $(this.actual);
|
99
|
-
var children = actual.find(expected);
|
100
|
-
return this.report(
|
101
|
-
children.length > 0,
|
102
|
-
"Expected [" + jasmine.util.htmlEscape(actual.html()) + "] to contain selector [" + $(expected).selector + "] but didn't"
|
103
|
-
);
|
104
|
-
};
|
105
|
-
|
106
|
-
jasmine.Matchers.prototype.toNotContainSelector = function(expected) {
|
107
|
-
var actual = $(this.actual);
|
108
|
-
var children = actual.find(expected);
|
109
|
-
return this.report(
|
110
|
-
children.length == 0,
|
111
|
-
"Expected [" + jasmine.util.htmlEscape(actual.html()) + "] to not contain selector [" + $(expected).selector + "] but it did"
|
112
|
-
);
|
113
|
-
};
|
114
|
-
|
115
|
-
jasmine.Matchers.prototype.toBeVisible = function() {
|
116
|
-
var actual = $(this.actual);
|
117
|
-
var basicMessage = "be visible";
|
118
|
-
return this._reportWithNonExistant(
|
119
|
-
actual.is(':visible'),
|
120
|
-
basicMessage,
|
121
|
-
"Expected '" + actual.selector + "' to " + basicMessage + " but was not"
|
122
|
-
);
|
123
|
-
};
|
124
|
-
|
125
|
-
jasmine.Matchers.prototype.toNotBeVisible = function() {
|
126
|
-
var actual = $(this.actual);
|
127
|
-
var basicMessage = "be hidden";
|
128
|
-
return this._reportWithNonExistant(
|
129
|
-
!actual.is(':visible'),
|
130
|
-
basicMessage,
|
131
|
-
"Expected '" + actual.selector + "' to " + basicMessage + " but was not"
|
132
|
-
);
|
133
|
-
};
|
134
|
-
|
135
|
-
jasmine.Matchers.prototype.toNotBeDisplayed = function() {
|
136
|
-
var actual = $(this.actual);
|
137
|
-
var basicMessage = "be display none";
|
138
|
-
return this._reportWithNonExistant(
|
139
|
-
actual.css("display") == "none",
|
140
|
-
basicMessage,
|
141
|
-
"Expected '" + actual.selector + "' to " + basicMessage + " but was not"
|
142
|
-
);
|
143
|
-
};
|
144
|
-
|
145
|
-
jasmine.Matchers.prototype.toBeDisplayed = function() {
|
146
|
-
var actual = $(this.actual);
|
147
|
-
var basicMessage = "not be display none";
|
148
|
-
return this._reportWithNonExistant(
|
149
|
-
actual.css("display") != "none",
|
150
|
-
basicMessage,
|
151
|
-
"Expected '" + actual.selector + "' to " + basicMessage + " but was"
|
152
|
-
);
|
153
|
-
};
|
154
|
-
|
155
|
-
jasmine.Matchers.prototype.toBeEmpty= function() {
|
156
|
-
var actual = $(this.actual);
|
157
|
-
var basicMessage = "be empty";
|
158
|
-
return this._reportWithNonExistant(
|
159
|
-
actual.html() == "",
|
160
|
-
basicMessage,
|
161
|
-
"Expected '" + actual.selector + "' to " + basicMessage + " but was not"
|
162
|
-
);
|
163
|
-
};
|
164
|
-
|
165
|
-
jasmine.Matchers.prototype.toNotBeEmpty= function() {
|
166
|
-
var actual = $(this.actual);
|
167
|
-
var basicMessage = "not be empty";
|
168
|
-
return this._reportWithNonExistant(
|
169
|
-
actual.html() != "",
|
170
|
-
basicMessage,
|
171
|
-
"Expected '" + actual.selector + "' to " + basicMessage + " but it was"
|
172
|
-
);
|
173
|
-
};
|
174
|
-
|
175
|
-
jasmine.Matchers.prototype.toHaveClass= function(expected) {
|
176
|
-
var actual = $(this.actual);
|
177
|
-
var basicMessage = "have class " + expected;
|
178
|
-
return this._reportWithNonExistant(
|
179
|
-
actual.hasClass(expected),
|
180
|
-
basicMessage,
|
181
|
-
"Expected '" + actual.selector + "' to " + basicMessage + " but does not"
|
182
|
-
);
|
183
|
-
};
|
184
|
-
|
185
|
-
jasmine.Matchers.prototype.toNotHaveClass= function(expected) {
|
186
|
-
var actual = $(this.actual);
|
187
|
-
var basicMessage = "not have class " + expected;
|
188
|
-
return this._reportWithNonExistant(
|
189
|
-
!actual.hasClass(expected),
|
190
|
-
basicMessage,
|
191
|
-
"Expected '" + actual.selector + "' to " + basicMessage + " but it does"
|
192
|
-
);
|
193
|
-
};
|
194
|
-
|
195
|
-
jasmine.Matchers.prototype.toBeDisabled= function() {
|
196
|
-
var actual = $(this.actual);
|
197
|
-
var basicMessage = "be disabled";
|
198
|
-
return this._reportWithNonExistant(
|
199
|
-
actual.is(":disabled"),
|
200
|
-
basicMessage,
|
201
|
-
"Expected '" + actual.selector + "' to " + basicMessage + " but was not"
|
202
|
-
);
|
203
|
-
};
|
204
|
-
|
205
|
-
jasmine.Matchers.prototype.toBeEnabled= function() {
|
206
|
-
var actual = $(this.actual);
|
207
|
-
var basicMessage = "be enabled";
|
208
|
-
return this._reportWithNonExistant(
|
209
|
-
actual.is(":enabled"),
|
210
|
-
basicMessage,
|
211
|
-
"Expected '" + actual.selector + "' to " + basicMessage + " but was not"
|
212
|
-
);
|
213
|
-
};
|
214
|
-
|
215
|
-
jasmine.Matchers.prototype.toBeTag= function(tagName) {
|
216
|
-
var actual = $(this.actual);
|
217
|
-
var basicMessage = "be a tag of type '" + tagName + "'";
|
218
|
-
var actualTagName = "your element";
|
219
|
-
if(actual.length > 0) {
|
220
|
-
actualTagName = actual.get(0).tagName.toLowerCase();
|
221
|
-
}
|
222
|
-
return this._reportWithNonExistant(
|
223
|
-
actual.is(tagName),
|
224
|
-
basicMessage,
|
225
|
-
"Expected '" + actualTagName + "' to " + basicMessage + " but was not"
|
226
|
-
);
|
227
|
-
};
|
228
|
-
|
229
|
-
jasmine.Matchers.prototype.toHaveAttribute= function(attr, value) {
|
230
|
-
var actual = $(this.actual);
|
231
|
-
var basicMessage = "have attribute '" + attr + "' with value '" + value + "'";
|
232
|
-
var actualValue = actual.attr(attr);
|
233
|
-
return this._reportWithNonExistant(
|
234
|
-
actualValue == value,
|
235
|
-
basicMessage,
|
236
|
-
"Expected '" + actual.selector + "' to " + basicMessage + " but instead had '" + actualValue + "'"
|
237
|
-
);
|
238
|
-
};
|
239
|
-
|
240
|
-
jasmine.Matchers.prototype._reportWithNonExistant = function(test, basicMesage, fullMessage) {
|
241
|
-
var actual = $(this.actual);
|
242
|
-
if(actual.length > 0) {
|
243
|
-
return this.report(
|
244
|
-
test,
|
245
|
-
fullMessage
|
246
|
-
);
|
247
|
-
} else {
|
248
|
-
return this.report(
|
249
|
-
false,
|
250
|
-
"Expected '" + actual.selector + "' to "+ basicMesage +" but the element didn't exist."
|
251
|
-
);
|
252
|
-
}
|
253
|
-
};
|