2011-03-14 3 views
0

전자 메일 구문 분석을 테스트하기 위해 오이를 사용하는 법을 배우고 있으며 오류가 발생하고 있습니다.오이 - 단계 정의에 메서드를 사용하는 방법

(::) failed steps (::) 

undefined method `find_reply' for MailingJob:Class (NoMethodError) 
./features/step_definitions/email_steps.rb:5:in `/^a email reply from gmail$/' 
features/ingest_emails.feature:7:in `Given a email reply from gmail' 

Failing Scenarios: 
cucumber features/ingest_emails.feature:6 # Scenario: GMAIL Web App Email Reply 

나는 새로운 해요 왜, 어떤 아이디어가 내가 잘하면 그렇게 오이하기 :

Given /^a email reply from gmail$/ do 
    # Get the Raw Email 
    raw_email = File.read("#{Rails.root}/features/step_definitions/email_replies/gmail_webapp_standard_1.txt") 
    # Send it to the mailingjob to find the reply 
    parsed_email = MailingJob.find_reply(raw_email) 
    # more stuff will come once the above is working 
end 

문제와 함께이 오류입니다 다음과 같이 내 단계 정의에서

, 나는 단계 정의 명백한 것을 놓치지 않을거야! 여기 살고

에 대해서는 MailingJob : /lib/mailing_job.rb이 같은

그리고 보이는 : 당신은 클래스 메소드를 호출

답변

3

class MailingJob < Struct.new(:mailing_id) 

    include ActionView::Helpers 

    def perform 

    begin 
     ..... 
    end 
    end 


    def find_reply(body) 
    # Lots of processing blah blah 

    returns body 
    end 

감사합니다. mailing_job.rb에 따라서

는해야한다이다 :

class MailingJob < Struct.new(:mailing_id) 

    def self.find_reply(body) 
    # Lots of processing blah blah 

    returns body 
    end 
... 
end 
관련 문제