Jasmine 2 cheat sheet for RSpec lamers

Updated . Posted . Visible to the public.

In the tradition of our PostgreSQL cheat sheet for MySQL lamers, here is a cheat sheet for Jasmine when you're used to RSpec.

Note that Jasmine syntax has changed with Jasmine 2, so if you're using Jasmine 1.x you might instead want to use an older cheat sheet Show archive.org snapshot .

Expectations

# RSpec
expect(foo).to.eq("value")
expect(foo).to_not eq("value")

# Jasmine
expect(foo).toBe("value")
expect(foo).not.toBe("value")

Mocks

# RSpec
expect(foo).to_receive(:method).twice.with('arg').and_return('value')

# Jasmine
spyOn(foo, 'method').and.returnValue('value')
expect(foo.calls.count()).toBe(2)
expect(foo.method).toHaveBeenCalledWith('arg')
Henning Koch
Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2015-01-18 16:09)