Created
June 11, 2012 07:57
-
-
Save Pasta/2908993 to your computer and use it in GitHub Desktop.
Some tests in Rspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment