More specs for aspect-edit.js. Initialize now fully covered.

Also, bundler upgraded our cucumber and rspec.
This commit is contained in:
Sarah Mei 2010-11-07 16:58:51 -08:00
parent d7172767ba
commit 1a4fa2713a
3 changed files with 37 additions and 21 deletions

View file

@ -151,7 +151,7 @@ GEM
columnize (0.3.2) columnize (0.3.2)
configuration (1.1.0) configuration (1.1.0)
crack (0.1.8) crack (0.1.8)
cucumber (0.9.3) cucumber (0.9.4)
builder (~> 2.1.2) builder (~> 2.1.2)
diff-lcs (~> 1.1.2) diff-lcs (~> 1.1.2)
gherkin (~> 2.2.9) gherkin (~> 2.2.9)
@ -311,18 +311,16 @@ GEM
rake (0.8.7) rake (0.8.7)
rest-client (1.6.1) rest-client (1.6.1)
mime-types (>= 1.16) mime-types (>= 1.16)
rspec (2.0.1) rspec (2.1.0)
rspec-core (~> 2.0.1) rspec-core (~> 2.1.0)
rspec-expectations (~> 2.0.1) rspec-expectations (~> 2.1.0)
rspec-mocks (~> 2.0.1) rspec-mocks (~> 2.1.0)
rspec-core (2.0.1) rspec-core (2.1.0)
rspec-expectations (2.0.1) rspec-expectations (2.1.0)
diff-lcs (>= 1.1.2) diff-lcs (~> 1.1.2)
rspec-mocks (2.0.1) rspec-mocks (2.1.0)
rspec-core (~> 2.0.1) rspec-rails (2.1.0)
rspec-expectations (~> 2.0.1) rspec (~> 2.1.0)
rspec-rails (2.0.1)
rspec (~> 2.0.0)
ruby-debug (0.10.4) ruby-debug (0.10.4)
columnize (>= 0.1) columnize (>= 0.1)
ruby-debug-base (~> 0.10.4.0) ruby-debug-base (~> 0.10.4.0)

View file

@ -14,24 +14,41 @@ describe("AspectEdit", function() {
AspectEdit.initialize(); AspectEdit.initialize();
expect($.fn.droppable).toHaveBeenCalledWith({hoverClass: 'active', drop: AspectEdit.onDropMove}); expect($.fn.droppable).toHaveBeenCalledWith({hoverClass: 'active', drop: AspectEdit.onDropMove});
expect($.fn.droppable.calls[0].object.selector).toEqual(".aspect ul.dropzone"); expect($.fn.droppable.calls[0].object.selector).toEqual(".aspect ul.dropzone");
// This would be AWESOME:
// expect($.fn.droppable)
// .toHaveBeenCalled()
// .on(".aspect ul.dropzone")
// .with({});
}); });
it("sets up the click event on .delete", function() {
spyOn($.fn, "live");
AspectEdit.initialize();
expect($.fn.live).toHaveBeenCalledWith("click", AspectEdit.deletePerson);
expect($.fn.live.calls[0].object.selector).toEqual(".delete");
});
it("sets up the focus event on aspect name", function() {
spyOn($.fn, "live");
AspectEdit.initialize();
expect($.fn.live).toHaveBeenCalledWith('focus', AspectEdit.changeName);
expect($.fn.live.calls[1].object.selector).toEqual(".aspect h3");
})
}); });
describe("startDrag", function() { describe("startDrag", function() {
beforeEach(function() {
$('#jasmine_content').html(
'<li class="person ui-draggable" data-aspect_id="4cae42e12367bca44e000005" data-guid="4cae42d32367bca44e000003" style="top: 0px; left: 0px; ">' +
' <img alt="Alexander Hamiltom" class="avatar" data-person_id="4cae42d32367bca44e000003" src="/images/user/default.png?1287542906" original-title="Alexander Hamiltom" style="height: 70px; width: 70px; opacity: 1; display: inline; ">' +
'</li>'
);
});
it("animates the image", function() { it("animates the image", function() {
$('#jasmine_content').html('<ul><li class="person ui-draggable" data-aspect_id="4cae42e12367bca44e000005" data-guid="4cae42d32367bca44e000003" style="top: 0px; left: 0px; ">' +
'<img alt="Alexander Hamiltom" class="avatar" data-person_id="4cae42d32367bca44e000003" src="/images/user/default.png?1287542906" original-title="Alexander Hamiltom" style="height: 70px; width: 70px; opacity: 1; display: inline; ">' +
'</li></ul>');
spyOn(AspectEdit, "animateImage"); spyOn(AspectEdit, "animateImage");
$.proxy(AspectEdit.startDrag, $('.person.ui-draggable'))(); $.proxy(AspectEdit.startDrag, $('.person.ui-draggable'))();
expect(AspectEdit.animateImage).toHaveBeenCalled(); expect(AspectEdit.animateImage).toHaveBeenCalled();
expect(AspectEdit.animateImage.mostRecentCall.args[0]).toHaveClass("avatar"); expect(AspectEdit.animateImage.mostRecentCall.args[0]).toHaveClass("avatar");
}); });
it("fades in the drag and drop text", function() {
spyOn($.fn, "fadeIn");
$.proxy(AspectEdit.startDrag, $('.person.ui-draggable'))();
expect($.fn.fadeIn).toHaveBeenCalledWith(100);
expect($.fn.fadeIn.mostRecentCall.object.selector).toEqual(".draggable_info");
});
}); });
describe("decrementRequestsCounter", function() { describe("decrementRequestsCounter", function() {

View file

@ -13,6 +13,7 @@
src_files: src_files:
- public/javascripts/vendor/jquery142.js - public/javascripts/vendor/jquery142.js
- public/javascripts/vendor/jquery-ui-1.8.4.custom.min.js - public/javascripts/vendor/jquery-ui-1.8.4.custom.min.js
- public/javascripts/vendor/jquery.tipsy.js
- public/javascripts/aspect-edit.js - public/javascripts/aspect-edit.js
# stylesheets # stylesheets