2017-03-27 50 views
0

我正在從RSpec 2遷移到RSpec 3.儘管試圖使用Rspec 2.99.2刪除所有的棄用,我已解決所有其他棄用。除,如何解決RSpec中不匹配的元素棄用2.99.2

stubbing implementations with mismatched arity is deprecated. Called from /path/to/file.rb:60:in `block in deliver_grouped_system_event_notification'. 
stubbing implementations with mismatched arity is deprecated. Called from /path/to/file.rb:26:in `send_notification'. 

這是文件:60

supports.each{ |support, system_events| Mailer.grouped_system_event_email(support, system_events).deliver_now } 

這是原來的方法

def grouped_system_event_email(support, system_events) 
    @recipients = support.email 
    @subject  = "[ #{ENVIRONMENT_NAME} Grouped System Event List] #{system_events.first.customer.symbol}" 
    @system_events = system_events 

    mail(to: @recipients, subject: @subject) 

這是它是存根

 Mailer.stub :grouped_system_event_email, &@email_spy 

拉姆達& @email_spy

@email_spy = lambda do 
    @email_sent = true 
    stub = OpenStruct.new 
    stub.stub :deliver_now 
    stub 
end 

回答

0

我只是跑 'transpec' 它轉換RSpec的2個語法的RSpec的3

gem install transpec 
myproject$ transpec 

這實際上給了更多的錯誤見解。

from: Klass.any_instance.stub(:message) 
to: allow_any_instance_of(Klass).to receive(:message) 

運行transpec後,下面是過渡

Mailer.stub :system_event_email, &@email_spy 

allow(Mailer).to receive :system_event_email, &@email_spy