Skip to content

Commit

Permalink
updateing based on latest gogivens
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcorbyeaglen committed Jan 24, 2018
1 parent b74bbf5 commit 59c2cd3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 5 additions & 2 deletions generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/corbym/gogiven/generator"
"github.com/corbym/htmlspec"
"testing"
"bytes"
)

var html string
Expand Down Expand Up @@ -43,7 +44,7 @@ func TestTestOutputGenerator_GenerateConcurrently(testing *testing.T) {
}

func TestTestOutputGenerator_FileExtension(t *testing.T) {
AssertThat(t, underTest.FileExtension(), is.EqualTo(".html"))
AssertThat(t, underTest.ContentType(), is.EqualTo("text/html"))
}

func TestTestOutputGenerator_Panics(t *testing.T) {
Expand All @@ -56,7 +57,9 @@ func TestTestOutputGenerator_Panics(t *testing.T) {
}

func fileIsConvertedToHtml() {
html = underTest.Generate(newPageData(true, true))
buffer := new(bytes.Buffer)
buffer.ReadFrom(underTest.Generate(newPageData(true, true)))
html = buffer.String()
}

func newPageData(skipped bool, failed bool) *generator.PageData {
Expand Down
9 changes: 5 additions & 4 deletions htmlgenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"html/template"
"os"
"path/filepath"
"io"
)

const goPathEnvKey = "GOPATH"
Expand Down Expand Up @@ -36,18 +37,18 @@ func NewTestOutputGenerator() *TestOutputGenerator {
}

// FileExtension for the output generated.
func (outputGenerator *TestOutputGenerator) FileExtension() string {
return ".html"
func (outputGenerator *TestOutputGenerator) ContentType() string {
return "text/html"
}

// Generate generates html output for a test. The return string contains the html
// that goes into the output file generated in gogivens.GenerateTestOutput().
// The function panics if the template cannot be generated.
func (outputGenerator *TestOutputGenerator) Generate(pageData *generator.PageData) string {
func (outputGenerator *TestOutputGenerator) Generate(pageData *generator.PageData) io.Reader {
var buffer = new(bytes.Buffer)
err := outputGenerator.template.ExecuteTemplate(buffer, baseTemplateName, pageData)
if err != nil {
panic(err.Error())
}
return buffer.String()
return buffer
}

0 comments on commit 59c2cd3

Please sign in to comment.