Skip to content

Commit

Permalink
Fixed a regression in the HTML formatter's #embed implementation. Closes
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Jun 6, 2011
1 parent 39891e2 commit 45c74e3
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 19 deletions.
5 changes: 5 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
== 0.10.6 (2011-06-07)

=== Bugfixes
* Fixed a regression in the HTML formatter's #embed implementation (#77 Aslak Hellesøy)

== 0.10.5 (2011-06-06)

(0.10.4 was forgotten!)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions fixtures/self_test/features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'base64'
begin require 'rspec/expectations'; rescue LoadError; require 'spec/expectations'; end
$KCODE = 'u' unless Cucumber::RUBY_1_9

Expand All @@ -16,3 +17,10 @@
After('@background_tagged_before_on_outline') do
@cukes.should == '888'
end

After do
png = IO.read(File.join(File.dirname(__FILE__), 'bubble_256x256.png'))
encoded_img = Base64.encode64(png).gsub(/\n/, '')
embed("data:image/png;base64,#{encoded_img}", 'image/png')
end

2 changes: 1 addition & 1 deletion legacy_features/announce.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: Delayed message
end
Given /^I use multiple putss$/ do x=1
announce("Multiple")
puts("Multiple")
puts("Announce","Me")
end
Expand Down
61 changes: 44 additions & 17 deletions legacy_features/html_formatter/a.html

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion lib/cucumber/formatter/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def initialize(step_mother, path_or_io, options)
@step_number = 0
@header_red = nil
@delayed_messages = []
@img_id = 0
end

def embed(src, mime_type, label)
Expand All @@ -31,7 +32,8 @@ def embed(src, mime_type, label)
end

def embed_image(src, label)
id = file.hash
id = "img_#{@img_id}"
@img_id += 1
@builder.span(:class => 'embed') do |pre|
pre << %{<a href="" onclick="img=document.getElementById('#{id}'); img.style.display = (img.style.display == 'none' ? 'block' : 'none');return false">#{label}</a><br>&nbsp;
<img id="#{id}" style="display: none" src="#{src}"/>}
Expand Down

0 comments on commit 45c74e3

Please sign in to comment.