2

也许这是新手问题,但我被困住了。我尝试用 capybara 查询 html 电子邮件,但没有运气。这是规格

# encoding: utf-8
require "spec_helper"
require "resque"
require "resque_spec"

describe 'MailerUtils in action'  do
  include MailerMacros

  let(:service_provider_email) { FactoryGirl.create(:service_provider_email) }
  let(:service_provider) { service_provider_email.service_provider }
  let(:service_provider_email_list) { service_provider_email.service_provider_email_list   }

  before :all do
    Resque.inline = true
  end

  describe 'send one marketing email and unsubscribe' do
    before :each do
      reset_email
      PromotionActions.perform :too_low_profile_score, service_provider.id
    end

    it "should have unsubscribe link" do
      last_email.body.should have_content("отписаться от рассылки")
    end

    it "should have correct city in link" do
      last_email.body.find(:xpath, "//a[@id=\"unsubscribe_link\"][@href=\"http://#{service_provider.city.name}.#{service_provider.country.domain}/#{service_provider.code}?uncheck=marketing]")
      end
    end
  end

最后一个例子失败。如何从电子邮件中查询 html?

4

1 回答 1

8
Capybara.string(last_email.body).find(...)
于 2012-06-22T12:25:04.467 回答