2
전자 메일을 보내기 위해 작성된 rspec 테스트가 있습니다. 애플리케이션의 사용자 이름으로 채워진 동적 필드를 포함합니다. 한 텍스트에서 다른 텍스트로 텍스트를 변경하고 차이를 반영하도록 spec 파일을 업데이트했지만 이제는 통과하지 못합니다. 여기에 테스트rspec 테스트가 통과하지 못합니다. 동적 데이터 사용
require "spec_helper"
describe OrgMemberMailer do
context "when an invite email gets sent" do
before(:each) do
member = Factory(:organization_membership)
@email = OrgMemberMailer.invite(member, 'samsdungeonsanddragonsguild.com').deliver
end
it "should be delivered successfully" do
ActionMailer::Base.deliveries.should_not be_empty
@email.from.should == ["[email protected]"]
@email.subject.should == "SocialNetwork - invitation to join <ORG>"
@email.encoded.should =~ /You have been invited to join <ORG> on SocialNetwork/
@email.encoded.should =~ /samsdungeonsanddragonsguild.com\/organization\/accept/
end
end
end
의 'SocialNetwork'정적 텍스트하지만 RSpec에 파일에 코딩 데이터 mailer.rb와 하드 모두에 의해 대체된다. 방금 위의 자리 표시 자로 사용했습니다. 내가 테스트를 실행하면
, 내가 얻을 : 나에게
OrgMemberMailer when an invite email gets sent should be delivered successfully
Failure/Error: @email.subject.should == "SocialNetwork - invitation to join <ORG>"
expected: "SocialNetwork - invitation to join <ORG>"
got: "SocialNetwork - invitation to join <ORG>" (using ==)
# ./spec/org_member_mailer_spec.rb:13:in `block (3 levels) in <top (required)>'
이 모든 것이 잘 보인다. 왜 지나쳐서는 안되는 지 알 수 없습니다. 대신 EQL한다
지정한에 숨어 소문자가 있었다 것 같다 ==한다. 그런 다음 라인 : @ email.encoded.should = ~ 당신이 SocialNetwork에 에 초대 된// 로 변경해야했다 : 당신이 초대받은 email.encoded.match (/ @ 가 에 가입 SocialNetwork /에서) should_not be_nil 이제 모든 것이 통과됩니다! 예! –
skipZero