Permalink
Browse files

Merge pull request #86 from bcardarella/master

Resolve href surrounded by single quote issue
  • Loading branch information...
2 parents 1d514c0 + 3aa83a2 commit 7283719066671084b90537f7f5c6032d04f674f5 @bmabey bmabey committed Dec 28, 2011
Showing with 12 additions and 2 deletions.
  1. +1 −0 Gemfile
  2. +1 −0 Rakefile
  3. +2 −1 lib/email_spec/helpers.rb
  4. +7 −0 spec/email_spec/helpers_spec.rb
  5. +1 −1 spec/spec_helper.rb
View
@@ -17,6 +17,7 @@ gem "rack-test"
gem "mail"
gem 'rails', '3.0.0.rc'
gem 'sqlite3-ruby', :require=>'sqlite3'
+gem 'nokogiri'
#gem 'email_spec', :path => '.'
gem 'capybara'
gem 'database_cleaner'
View
@@ -24,6 +24,7 @@ begin
s.rubyforge_project = 'email-spec'
s.add_runtime_dependency "mail", "~> 2.2"
s.add_runtime_dependency "rspec", "~> 2.0"
+ s.add_runtime_dependency "nokogiri"
end
rescue LoadError
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
@@ -1,4 +1,5 @@
require 'uri'
+require 'nokogiri'
require 'email_spec/deliveries'
module EmailSpec
@@ -69,7 +70,7 @@ def find_email(address, opts={})
end
def links_in_email(email)
- URI.extract(email.default_part_body.to_s, ['http', 'https'])
+ Nokogiri::HTML.parse(email.default_part_body.to_s).css('a').map { |link| link['href'] }
end
private
@@ -19,6 +19,13 @@
end
end
+ describe '#links_in_email' do
+ it "properly finds links surrounded by single quotes" do
+ email = Mail.new(:body => %{<a href='http://www.example.com/test'>Click Here</a>})
+ links_in_email(email).should include %{http://www.example.com/test}
+ end
+ end
+
describe "#set_current_email" do
it "should cope with a nil email" do
lambda do
View
@@ -13,4 +13,4 @@ def with_inspect_stub(str = "email")
RSpec.configure do |config|
config.mock_with :rspec
-end
+end

0 comments on commit 7283719

Please sign in to comment.