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 online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
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)