2017-03-27 53 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