Sha256: 944e6b6a2cd56a40d27718641142f5914c42f2a26347a50ffcda594403b05bd2

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

require File.dirname(__FILE__) + '/../../../spec_helper.rb'
require 'stringio'

context "HtmlFormatter" do
  specify "should produce HTML identical to the one we designed manually" do
    root = File.expand_path(File.dirname(__FILE__) + '/../../../..')
    expected_file = File.dirname(__FILE__) + "/html_formatted-#{VERSION}.html"
    expected_html = File.read(expected_file)
    raise "There should be no absolute paths in html_formatted.html!!" if expected_html =~ /\/Users/n
    
    ['--diff', '--dry-run'].each do |opt|
      Dir.chdir(root) do
        args = ['failing_examples/mocking_example.rb', 'failing_examples/diffing_spec.rb', 'examples/stubbing_example.rb', '--format', 'html', opt]
        err = StringIO.new
        out = StringIO.new
        Spec::Runner::CommandLine.run(
          args,
          err,
          out,
          false
        )

        seconds = /\d+\.\d+ seconds/
        html = out.string.gsub seconds, 'x seconds'
        expected_html.gsub! seconds, 'x seconds'

        if opt == '--diff'
          # Uncomment this line temporarily in order to overwrite the expected with actual.
          # Use with care!!!
          # File.open(expected_file, 'w') {|io| io.write(html)}

          html.should == expected_html
        else
          html.should =~ /This was a dry-run/m
        end
      end
    end
  end
  
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
riess-0.0.8 vendor/rspec-0.8.2/spec/spec/runner/formatter/html_formatter_spec.rb
rspec-0.8.0 spec/spec/runner/formatter/html_formatter_spec.rb
rspec-0.8.1 spec/spec/runner/formatter/html_formatter_spec.rb
rspec-0.8.2 spec/spec/runner/formatter/html_formatter_spec.rb