Skip to content

Instantly share code, notes, and snippets.

@kevbuchanan
Last active July 27, 2016 14:53
Show Gist options
  • Save kevbuchanan/6611072 to your computer and use it in GitHub Desktop.
Save kevbuchanan/6611072 to your computer and use it in GitHub Desktop.

Revisions

  1. @KevinBuch KevinBuch revised this gist Sep 25, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion rspec_jasmine.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    ## A very basic intro to Jasmine tests for those familiar with RSpec

    ### let
    ### let/before
    ```ruby
    let(:post) { Post.new("My Title", "My Content") }
    ```
  2. @KevinBuch KevinBuch revised this gist Sep 18, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion rspec_jasmine.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # RSpec vs Jasmine

    ## A basic intro to Jasmine tests for those familiar with RSpec
    ## A very basic intro to Jasmine tests for those familiar with RSpec

    ### let
    ```ruby
  3. @KevinBuch KevinBuch created this gist Sep 18, 2013.
    60 changes: 60 additions & 0 deletions rspec_jasmine.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@
    # RSpec vs Jasmine

    ## A basic intro to Jasmine tests for those familiar with RSpec

    ### let
    ```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))
    ```