Skip to content

Commit

Permalink
Improve scannability for first-time readers of feature test
Browse files Browse the repository at this point in the history
I hope
  • Loading branch information
MarkyMarkMcDonald committed Apr 5, 2018
1 parent 482040a commit 26523b7
Showing 1 changed file with 35 additions and 21 deletions.
56 changes: 35 additions & 21 deletions test/links_on_a_page_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,23 @@

class LinksOnAPageTest < Minitest::Test
def test_it_does_something_useful
@external_server = WEBrick::HTTPServer.new(
BindAddress: 'localhost',
Port: 7654,
DocumentRoot: __dir__ + '/../example_external_site'
)
@server = WEBrick::HTTPServer.new(
BindAddress: 'localhost',
Port: 0,
DocumentRoot: __dir__ + '/../example_documentation_site'
)
Thread.new do
@external_server.start
end
Thread.new do
@server.start
end
@server = start_our_docs_server
@external_server = start_external_site_server

quarantine_entrance = "http://localhost:#{@server.config[:Port]}"
config = DocDoc::Configuration::Options.new(quarantine_entrance, nil)
prescription = DocDoc.prescription(config)

expected_prescription = {
assert_equal(expected_prescription(quarantine_entrance), JSON.parse(prescription.to_s))
ensure
@server.shutdown
@external_server.shutdown
end

private

def expected_prescription(quarantine_entrance)
{
"links" => [
{
"page" => quarantine_entrance,
Expand Down Expand Up @@ -60,10 +55,29 @@ def test_it_does_something_useful
}
]
}
end

assert_equal(expected_prescription, JSON.parse(prescription.to_s))
ensure
@server.shutdown
@external_server.shutdown
def start_our_docs_server
server = WEBrick::HTTPServer.new(
BindAddress: 'localhost',
Port: 0,
DocumentRoot: __dir__ + '/../example_documentation_site'
)
Thread.new do
server.start
end
server
end

def start_external_site_server
server = WEBrick::HTTPServer.new(
BindAddress: 'localhost',
Port: 7654,
DocumentRoot: __dir__ + '/../example_external_site'
)
Thread.new do
server.start
end
server
end
end

0 comments on commit 26523b7

Please sign in to comment.