test/helpers/users_helper_test.rb in guts-1.0.8 vs test/helpers/users_helper_test.rb in guts-1.1.0

- old
+ new

@@ -1,17 +1,19 @@ -require "test_helper" +require 'test_helper' module Guts class UsersHelperTest < ActionView::TestCase - test "returns a gravatar image" do + test 'returns a gravatar image' do user = guts_users :admin_user - stub_request(:get, /https:\/\/secure.gravatar.com\/avatar\/.*/).to_return(body: "") - gravatar = gravatar_for user - html = Nokogiri::HTML(gravatar).xpath("//img") + stub_request(:get, %r{https:\/\/secure.gravatar.com\/avatar\/.*}).to_return(body: '') - assert_equal "gravatar", html.attr("class").value - assert_equal user.name, html.attr("alt").value - assert_equal "https://secure.gravatar.com/avatar/#{Digest::MD5::hexdigest(user.email.downcase)}", html.attr("src").value + gravatar = gravatar_for user + html = Nokogiri::HTML(gravatar).xpath('//img') + email_md5 = Digest::MD5.hexdigest(user.email.downcase) + + assert_equal 'gravatar', html.attr('class').value + assert_equal user.name, html.attr('alt').value + assert_equal "https://secure.gravatar.com/avatar/#{email_md5}", html.attr('src').value end end -end \ No newline at end of file +end