Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML Output for White Bread #81

Merged
merged 14 commits into from
Dec 18, 2016
Merged

Conversation

Dzol
Copy link
Contributor

@Dzol Dzol commented Dec 14, 2016

Nearing completion so this PR will help to review.

@meadsteve
Copy link
Collaborator

Code looks 👍 so far.
Could you add something to the README about how to switch to this kind of output?

@Dzol
Copy link
Contributor Author

Dzol commented Dec 15, 2016

Certainly! Will get this in the README soon.

Joseph Yiasemides added 2 commits December 15, 2016 10:22
Hard coded to write to ~/report.html for the time being.
Copy link

@mentels mentels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Minor suggestions.

def handle_cast({:scenario_result, {result, _}, %Scenario{name: name}}, state) when :ok == result or :failed == result do
{:noreply, %{ state | data: [ {result, name} | state.data ]}}
end

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't be a whitespace between two clauses of the same functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is from https://github.com/rrrene/elixir-style-guide:

Group function definitions. Keep the same function with different signatures together without separating blank lines. In all other cases, use blank lines to separate different functions/parts of your module (to maximize readability through "vertical white-space").

We also follow this practice in Erlang.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh: okay!

end

def terminate(_, state) do
import WhiteBread.Outputers.HTML.Formatter
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear which imported functions are used

"Nothing to report."
end

def list(elements) when is_list(elements) and length(elements) > 0 do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This head could be more concise: def list([_|_] = elements), do: list(elements,"")


test "file path fetched on initialization" do
old = Application.fetch_env! :white_bread, :path
:ok = Application.put_env :white_bread, :path, "/fu/bar.baz"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping track of/restoring an app env variable looks like something to be put into setup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ordinarily I would but it doesn't seem worth it because we only set it in this one test.

HTML.handle_cast {:scenario_result, {:ok, "ignore"}, %Scenario{name: "X"}}, %HTML{data: []}
end

test "write file on termaination" do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would actually be nice to test with a real process and sending in an exit signal - not necessary though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are system tests we can modify instead. This way we can just keep unit tests here.

s = File.stat! p
assert File.exists? p
assert s.size > 0
File.rm! p
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code could be simplified a little with:

assert {:ok, stat} = File.stat(p)
assert stat.size > 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep: don't know why I did it that way.

Joseph Yiasemides added 3 commits December 16, 2016 12:14
Thank you to Szymon Mentel for suggested improvements. This introduces
the PathError exception too.
Credo wouldn't work as it used an internal Elixir API call that was
changed.
@meadsteve meadsteve merged commit 758d9ca into meadery:master Dec 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants