Sha256: 1b213bf7ec782833de2ae57f6bd7078954d870a0ae52a360b7cc0fd31614f94f

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 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

3 entries across 3 versions & 1 rubygems

Version Path
rentjuicer-0.10.1 spec/rentjuicer/lead_spec.rb
rentjuicer-0.10.0 spec/rentjuicer/lead_spec.rb
rentjuicer-0.9.0 spec/rentjuicer/lead_spec.rb