Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6028019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:40:37+00:00 2026-05-23T04:40:37+00:00

please help me debug this for Rails 3.1. It passes in 3.0. Thank you.

  • 0

please help me debug this for Rails 3.1. It passes in 3.0. Thank you.

$ rspec spec/models

update: escrow model

require 'transitions'

class Escrow < ActiveRecord::Base
  include ActiveRecord::Transitions
  include Amendable
  include ActsAsAsset
  include Searchable

  acts_as_taggable_on :tags

  has_many :addresses, :as => :addressable
  has_many :events, :as => :entity
  has_many :phone_numbers, :as => :phoneable
  belongs_to :property

  validates :property, :presence => true

  state_machine do
    state :open
    state :cancel
    state :close

    event :cancel do
      transitions :to => :cancel, :from => [:open]
    end

    event :close do
      transitions :to => :close, :from => [:open]
    end
  end

  def self.open
    where :state => 'open'
  end

  def all_participants
    (self.users + property.users).flatten.compact.uniq.sort +
      (self.groups + property.groups).flatten.compact.uniq.sort
  end
end

model

require 'transitions'

class Property < ActiveRecord::Base
  include ActiveRecord::Transitions
  include ActsAsAsset
  include Amendable
  include Searchable

  acts_as_taggable_on :tags

  has_many :addresses, :as => :addressable
  has_many :escrows
  has_many :events, :as => :entity
  has_many :phone_numbers, :as => :phoneable

  state_machine do
    state :pending
    state :active,  :enter => :cancel_escrow
    state :cancel,  :enter => :cancel_escrow
    state :close,   :enter => :close_escrow
    state :expire
    state :escrow,  :enter => :open_escrow

    event :active do
      transitions :to => :active, :from => [:escrow, :expire, :pending, :cancel]
    end

    event :cancel do
      transitions :to => :cancel, :from => [:active, :escrow, :pending]
    end

    event :close do
      transitions :to => :close, :from => [:escrow]
    end

    event :expire do
      transitions :to => :expire, :from => [:active]
    end

    event :escrow do
      transitions :to => :escrow, :from => [:active], :guard => :no_open_escrows
    end
  end

  def current_escrow
    self.escrows.open.first
  end

  private

    def cancel_escrow
      self.current_escrow.try(:cancel!)
    end

    def close_escrow
      self.current_escrow.try(:close!)
    end

    def no_open_escrows
      self.escrows.open.empty?
    end

    def open_escrow
      self.escrows.create!
    end
end

spec

require 'spec_helper'

describe Property do
  disconnect_sunspot

  describe 'Associations' do
    it { should have_one :pivot }
    it { should have_many :addresses }
    it { should have_many :escrows }
    it { should have_many(:events) }
    it { should have_many(:groups).through(:pivot) }
    it { should have_many :phone_numbers }
    it { should have_many(:users).through(:pivot) }
  end

  describe 'Database Columns' do
    it { should have_db_column(:state).of_type(:string) }
  end

  describe 'Factory' do
    it { Factory.build(:property).valid?.should == true }
  end

  describe 'Methods' do
    describe '#current_escrow' do
      it 'returns open escrow or none' do
        p = Factory :property, :state => 'active'
        p.escrow!
        e = p.escrows.first
        2.times { p.escrows.create :state => 'canceled' }
        p.current_escrow.should == e
      end
    end
  end

  describe 'Modules' do
    it { Property.included_modules.include?(ActsAsAsset).should == true }
    it { Property.included_modules.include?(Amendable).should == true }
  end

  describe 'State Transitions' do
    describe 'active!' do
      %w(cancel escrow expire pending).each do |state|
        it "transitions to active from #{state}" do
          p = Factory :property, :state => state
          lambda { p.active! }.should_not raise_error
        end
      end

      %w(close).each do |state|
        it "cannot transition to active from #{state}" do
          p = Factory :property, :state => state
          lambda { p.active! }.should raise_error
        end
      end

      it 'marks escrow reconciled and canceled if escrow -> active' do
        p = Factory :property, :state => 'active'
        p.escrow!
        p.active!
        p.reload
        p.send(:no_open_escrows).should == true
        p.escrows.first.state.should == 'cancel'
      end
    end

    describe 'cancel!' do
      %w(active escrow pending).each do |state|
        it "transitions to cancel from #{state}" do
          p = Factory :property, :state => state
          lambda { p.cancel! }.should_not raise_error
        end
      end

      %w(close).each do |state|
        it "cannot transition to cancel from #{state}" do
          p = Factory :property, :state => state
          lambda { p.active! }.should raise_error
        end
      end
    end

    describe 'close!' do
      %w(escrow).each do |state|
        it "transitions to close from #{state}" do
          p = Factory :property, :state => state
          lambda { p.close! }.should_not raise_error
        end
      end

      %w(expire cancel pending).each do |state|
        it "cannot transition to close from #{state}" do
          p = Factory :property, :state => state
          lambda { p.close! }.should raise_error
        end
      end
    end

    describe 'escrow!' do
      %w(active).each do |state|
        it "transitions to escrow from #{state}" do
          p = Factory :property, :state => state
          lambda { p.escrow! }.should_not raise_error
        end
      end

      %w(escrow close cancel expire pending).each do |state|
        it "cannot transition to escrow from #{state}" do
          p = Factory :property, :state => state
          lambda { p.escrow! }.should raise_error
        end
      end

      it 'creates a new escrow object on escrow!' do
        p = Factory :property, :state => 'active'
        p.escrows.empty?.should == true
        p.escrow!
        p.reload
        p.escrows.size.should == 1
      end

      it 'cannot go to escrow if another escrow is open' do
        p = Factory :property, :state => 'active'
        p.escrow!
        lambda { p.escrow! }.should raise_error
      end

      it 'can go to escrow if previous escrows are canceled' do
        p = Factory :property, :state => 'active'
        p.escrows.create
        p.reload
        p.escrows.first.update_attribute :state, 'canceled'
        lambda { p.escrow! }.should_not raise_error
      end
    end

    describe 'expire!' do
      %w(active).each do |state|
        it "transitions to expire from #{state}" do
          p = Factory :property, :state => state
          lambda { p.expire! }.should_not raise_error
        end
      end

      %w(escrow close cancel pending).each do |state|
        it "cannot transition to expire from #{state}" do
          p = Factory :property, :state => state
          lambda { p.expire! }.should raise_error
        end
      end
    end

    describe 'pending' do
      it 'has initial state pending' do
        Factory(:property).state.should == 'pending'
      end

      %w(active close escrow expire cancel).each do |state|
        it "cannot transition to pending from #{state}" do
          p = Factory :property, :state => state
          lambda { p.pending! }.should raise_error
        end
      end
    end
  end

  describe 'Tags' do
    it { Factory(:property).tags.should == [] }
  end

  describe 'Validations' do
  end
end

failures

Failures:

  1) Property Methods#current_escrow returns open escrow or none
     Failure/Error: p.escrow!
     ArgumentError:
       wrong number of arguments (0 for 1)
     # ./app/models/property.rb:60:in `no_open_escrows'
     # ./spec/models/property_spec.rb:28:in `block (4 levels) in <top (required)>'

  2) Property State Transitions active! transitions to active from cancel
     Failure/Error: lambda { p.active! }.should_not raise_error
       expected no Exception, got #<ArgumentError: wrong number of arguments (0 for 1)>
     # ./spec/models/property_spec.rb:46:in `block (5 levels) in <top (required)>'

  3) Property State Transitions active! transitions to active from escrow
     Failure/Error: lambda { p.active! }.should_not raise_error
       expected no Exception, got #<ArgumentError: wrong number of arguments (0 for 1)>
     # ./spec/models/property_spec.rb:46:in `block (5 levels) in <top (required)>'

  4) Property State Transitions active! transitions to active from expire
     Failure/Error: lambda { p.active! }.should_not raise_error
       expected no Exception, got #<ArgumentError: wrong number of arguments (0 for 1)>
     # ./spec/models/property_spec.rb:46:in `block (5 levels) in <top (required)>'

  5) Property State Transitions active! transitions to active from pending
     Failure/Error: lambda { p.active! }.should_not raise_error
       expected no Exception, got #<ArgumentError: wrong number of arguments (0 for 1)>
     # ./spec/models/property_spec.rb:46:in `block (5 levels) in <top (required)>'

  6) Property State Transitions active! marks escrow reconciled and canceled if escrow -> active
     Failure/Error: p.escrow!
     ArgumentError:
       wrong number of arguments (0 for 1)
     # ./app/models/property.rb:60:in `no_open_escrows'
     # ./spec/models/property_spec.rb:59:in `block (4 levels) in <top (required)>'

  7) Property State Transitions cancel! transitions to cancel from active
     Failure/Error: lambda { p.cancel! }.should_not raise_error
       expected no Exception, got #<ArgumentError: wrong number of arguments (0 for 1)>
     # ./spec/models/property_spec.rb:71:in `block (5 levels) in <top (required)>'

  8) Property State Transitions cancel! transitions to cancel from escrow
     Failure/Error: lambda { p.cancel! }.should_not raise_error
       expected no Exception, got #<ArgumentError: wrong number of arguments (0 for 1)>
     # ./spec/models/property_spec.rb:71:in `block (5 levels) in <top (required)>'

  9) Property State Transitions cancel! transitions to cancel from pending
     Failure/Error: lambda { p.cancel! }.should_not raise_error
       expected no Exception, got #<ArgumentError: wrong number of arguments (0 for 1)>
     # ./spec/models/property_spec.rb:71:in `block (5 levels) in <top (required)>'

  10) Property State Transitions close! transitions to close from escrow
     Failure/Error: lambda { p.close! }.should_not raise_error
       expected no Exception, got #<ArgumentError: wrong number of arguments (0 for 1)>
     # ./spec/models/property_spec.rb:87:in `block (5 levels) in <top (required)>'

  11) Property State Transitions escrow! transitions to escrow from active
     Failure/Error: lambda { p.escrow! }.should_not raise_error
       expected no Exception, got #<ArgumentError: wrong number of arguments (0 for 1)>
     # ./spec/models/property_spec.rb:103:in `block (5 levels) in <top (required)>'

  12) Property State Transitions escrow! creates a new escrow object on escrow!
     Failure/Error: p.escrow!
     ArgumentError:
       wrong number of arguments (0 for 1)
     # ./app/models/property.rb:60:in `no_open_escrows'
     # ./spec/models/property_spec.rb:117:in `block (4 levels) in <top (required)>'

  13) Property State Transitions escrow! cannot go to escrow if another escrow is open
     Failure/Error: p.escrow!
     ArgumentError:
       wrong number of arguments (0 for 1)
     # ./app/models/property.rb:60:in `no_open_escrows'
     # ./spec/models/property_spec.rb:124:in `block (4 levels) in <top (required)>'

  14) Property State Transitions escrow! can go to escrow if previous escrows are canceled
     Failure/Error: lambda { p.escrow! }.should_not raise_error
       expected no Exception, got #<ArgumentError: wrong number of arguments (0 for 1)>
     # ./spec/models/property_spec.rb:133:in `block (4 levels) in <top (required)>'

Finished in 35.44 seconds
297 examples, 14 failures, 1 pending

Failed examples:

rspec ./spec/models/property_spec.rb:26 # Property Methods#current_escrow returns open escrow or none
rspec ./spec/models/property_spec.rb:44 # Property State Transitions active! transitions to active from cancel
rspec ./spec/models/property_spec.rb:44 # Property State Transitions active! transitions to active from escrow
rspec ./spec/models/property_spec.rb:44 # Property State Transitions active! transitions to active from expire
rspec ./spec/models/property_spec.rb:44 # Property State Transitions active! transitions to active from pending
rspec ./spec/models/property_spec.rb:57 # Property State Transitions active! marks escrow reconciled and canceled if escrow -> active
rspec ./spec/models/property_spec.rb:69 # Property State Transitions cancel! transitions to cancel from active
rspec ./spec/models/property_spec.rb:69 # Property State Transitions cancel! transitions to cancel from escrow
rspec ./spec/models/property_spec.rb:69 # Property State Transitions cancel! transitions to cancel from pending
rspec ./spec/models/property_spec.rb:85 # Property State Transitions close! transitions to close from escrow
rspec ./spec/models/property_spec.rb:101 # Property State Transitions escrow! transitions to escrow from active
rspec ./spec/models/property_spec.rb:114 # Property State Transitions escrow! creates a new escrow object on escrow!
rspec ./spec/models/property_spec.rb:122 # Property State Transitions escrow! cannot go to escrow if another escrow is open
rspec ./spec/models/property_spec.rb:128 # Property State Transitions escrow! can go to escrow if previous escrows are canceled
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:40:38+00:00Added an answer on May 23, 2026 at 4:40 am

    The error is in this function, in the self.escrows.open.empty:

      def no_open_escrows
        self.escrows.open.empty?
      end
    

    The errors says: wrong number of arguments (0 for 1)

    So i guess you have defined a scope on escrow called open? And from the error it would seem that that scope now expects a parameter, which you don’t supply. Or otherwise, because open is a very generic name, it conflicts with something else in rails in the new version?

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting this error, not really sure why. Please help, this is urgent. UPDATE
Please some help on how to debug this! On my development machine I can
Please help me convert this line to C#. objManagementBaseObject.SetPropertyValue(hDefKey, CType(&H & Hex(RegistryHive.LocalMachine), Long)) Related
I need help to debug this program . // VirtualFN.cpp : Defines the entry
Related to my other question , please help me debug An unhandled exception of
I can not figure out how to fix this issue!!! Please help!! undefined method
Some one please help me out of this ::( I am using ubuntu 11.04
I can't figure out why I'm getting this error. Please help. Traceback (most recent
Please help me understand why this function throws an exception when it reaches fclose
[Update:] i know the problem... but need help to resolve this. The issue is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.