Read more

Jasmine 2 cheat sheet for RSpec lamers

Henning Koch
January 18, 2015Software engineer at makandra GmbH

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

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

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')
Posted by Henning Koch to makandra dev (2015-01-18 17:09)