# RSpec vs Jasmine ## A very basic intro to Jasmine tests for those familiar with RSpec ### let/before ```ruby let(:post) { Post.new("My Title", "My Content") } ``` ```javascript var post beforeEach(function() { post = new Post("My Title", "My Content") }) ``` ### describe ```ruby describe Post do end ``` ```javascript describe("Post", function() { // setup a post with a before block }) ``` ### it ```ruby it "should have a title" do expect(post.title).to eq("My Title") end ``` ```javascript it("should have a title", function() { expect(post.title).toEqual("My Title") }) ``` ### stub ```ruby before do Blog.stub(:add).and_return(true) end ``` ```javascript var blog beforeEach(function() { blog = new Blog() spyOn(blog, "add").andReturn(true) }) ``` ### be_a ```ruby expect(blog.posts.first).to be_a(Post) ``` ```javascript expect(blog.posts[0]).toEqual(jasmine.any(Post)) ```