Sha256: 954b9b7de1931253eea9d537489a2ea120aa1c9279a24e189083082659fabb13

Contents?: true

Size: 975 Bytes

Versions: 6

Compression:

Stored size: 975 Bytes

Contents

require 'spec_helper'

describe Woopy::User do
  before do 
    @token = 'foo'
    Woopy(token: @token)
  end

  describe "#save" do
    context "valid name and email" do
      before do
        ActiveResource::HttpMock.respond_to do |mock|
          mock.post( '/services/v1/users.json', request_headers(@token), user_response)
        end
        @user = Woopy::User.new(user_attributes) 
      end

      it 'saves correctly' do
        @user.save.should be_true
      end
    end
    
    context "invalid attributes" do
      before do
        ActiveResource::HttpMock.respond_to do |mock|
          mock.post('/services/v1/users.json', request_headers(@token), { errors: ["Name can't be blank"] }.to_json, 422)
        end
        @user = Woopy::User.new(user_attributes) 
      end
      
      it "should not save, with errors" do
        @user.save.should be_false
        @user.errors.full_messages.should include("Name can't be blank")
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
woopy-0.1.8 spec/woopy/user_spec.rb
woopy-0.1.7 spec/woopy/user_spec.rb
woopy-0.1.6 spec/woopy/user_spec.rb
woopy-0.1.5 spec/woopy/user_spec.rb
woopy-0.1.4 spec/woopy/user_spec.rb
woopy-0.1.3 spec/woopy/user_spec.rb