Skip to content

Instantly share code, notes, and snippets.

@Pasta
Created June 11, 2012 07:57
Show Gist options
  • Select an option

  • Save Pasta/2908993 to your computer and use it in GitHub Desktop.

Select an option

Save Pasta/2908993 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous revised this gist Jun 11, 2012. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -2,14 +2,14 @@
    context "when params are valid" do
    before { @some = Some.new(name:"Vincent", lat:48.872958, lng:2.380428) }
    it "should create an Thing position" do
    expect {
    post :create, homeless:{ name:@some.name, lat:@some.lat, lng:@some.lng }, format: :json }.to change(Some, :count).by 1
    response.body.should be_json_eql(@some.to_json)
    expect {
    post :create, homeless:{ name:@some.name, lat:@some.lat, lng:@some.lng }, format: :json }.to change(Some, :count).by 1
    response.body.should be_json_eql(@some.to_json)
    end
    end
    context "when invalid params" do
    before {post :create, some:{name: "Vincent"}, format: :json }
    subject {response} it { should eq(422) }
    its(:body) {should have_json_path("errors")}
    before {post :create, some:{name: "Vincent"}, format: :json }
    subject {response} it { should eq(422) }
    its(:body) {should have_json_path("errors")}
    end
    end
  2. @invalid-email-address Anonymous created this gist Jun 11, 2012.
    15 changes: 15 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    describe "POST create" do
    context "when params are valid" do
    before { @some = Some.new(name:"Vincent", lat:48.872958, lng:2.380428) }
    it "should create an Thing position" do
    expect {
    post :create, homeless:{ name:@some.name, lat:@some.lat, lng:@some.lng }, format: :json }.to change(Some, :count).by 1
    response.body.should be_json_eql(@some.to_json)
    end
    end
    context "when invalid params" do
    before {post :create, some:{name: "Vincent"}, format: :json }
    subject {response} it { should eq(422) }
    its(:body) {should have_json_path("errors")}
    end
    end