Sha256: e0bf44d7932fd77be020e30f6253de588a90cd1e4fa80907ba3d93362ea4148e

Contents?: true

Size: 1.32 KB

Versions: 10

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'

describe Rentjuicer::Lead do
  before do
    @rentjuicer = new_rentjuicer
    @lead = Rentjuicer::Lead.new(@rentjuicer)
  end
  
  context "a successfull creation" do
    before do
      mock_get(@lead.resource, 'lead.json', :name => 'Tom Cocca')
    end
  
    it "should not return an error on create" do
      lambda {
        @lead.create('Tom Cocca')
      }.should_not raise_exception
    end
    
    it "should not return an error on create!" do
      lambda {
        @lead.create!('Tom Cocca')
      }.should_not raise_exception
    end
    
    it "should be a success?" do
      @response = @lead.create('Tom Cocca')
      @response.success?.should be_true
    end
  end
  
  
  context "unsucessful submission" do
    before do
      mock_get(@lead.resource, 'lead_error.json', :name => '')
    end
    
    it "should return an error on create!" do
      lambda {
        @lead.create!('')
      }.should raise_exception(Rentjuicer::Error, "Rentjuicer Error: invalid parameter - `name` is required (code: 3)")
    end
    
    it "should not return an error on create" do
      lambda {
        @lead.create('')
      }.should_not raise_exception
    end
    
    it "should not be a successful submission on create" do
      @result = @lead.create('')
      @result.success?.should be_false
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rentjuicer-0.8.0 spec/rentjuicer/lead_spec.rb
rentjuicer-0.7.3 spec/rentjuicer/lead_spec.rb
rentjuicer-0.7.2 spec/rentjuicer/lead_spec.rb
rentjuicer-0.7.1 spec/rentjuicer/lead_spec.rb
rentjuicer-0.6.3 spec/rentjuicer/lead_spec.rb
rentjuicer-0.6.2 spec/rentjuicer/lead_spec.rb
rentjuicer-0.6.1 spec/rentjuicer/lead_spec.rb
rentjuicer-0.6.0 spec/rentjuicer/lead_spec.rb
rentjuicer-0.5.1 spec/rentjuicer/lead_spec.rb
rentjuicer-0.5.0 spec/rentjuicer/lead_spec.rb