lk & sh | posts to bike index in development when creating new bike

This commit is contained in:
Loos
2015-08-06 20:29:46 -05:00
parent 66c43e57c2
commit 3224faab0e
12 changed files with 137 additions and 2 deletions
+14
View File
@@ -1,4 +1,18 @@
require 'spec_helper'
describe Bike do
it "posts to bike index" do
WebMock.stub_request(:post, "http://lvh.me:3000/api/v2/bikes?access_token=asdfklkjasfdljkd3asdfjkl2asdf")
.and_return(:status => 201, :body => {bike: {id: 1}}.to_json, :headers => {})
bike = create(:bike, bike_index_id: nil)
expect(bike.bike_index_id).to eq(1)
end
it "assigns bike_index_id after posting to bike index" do
WebMock.stub_request(:post, "http://lvh.me:3000/api/v2/bikes?access_token=asdfklkjasfdljkd3asdfjkl2asdf")
.and_return(:status => 400, :body => {error: "error"}.to_json, :headers => {})
bike = create(:bike, bike_index_id: nil)
expect(bike.bike_index_id).to_not be_present
end
end