Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move common integration test methods into the helper

These methods are instance variables are useful for other tests.
Push them into the integration_test_helper so that they're not
continually written and instantiated.
  • Loading branch information...
commit d59942ceafd15d016ae323c3188ab0230a6265e7 1 parent 519ea36
@KushalP KushalP authored
Showing with 13 additions and 15 deletions.
  1. +1 −15 test/integration/api_test.rb
  2. +12 −0 test/integration_test_helper.rb
View
16 test/integration/api_test.rb
@@ -2,23 +2,9 @@
require 'gds_api/panopticon'
class ApiAcceptanceTest < ActionDispatch::IntegrationTest
- def server
- @server ||= startup_server
- end
-
- def startup_server
- server = Capybara::Server.new(Capybara.app)
- server.boot
- server
- end
-
- def create_test_user
- FactoryGirl.create(:user, name: "Test", email: "test@example.com", uid: 123)
- end
-
test "Can create an artefact via the api" do
create_test_user
- api_client = GdsApi::Panopticon.new(nil, endpoint_url: server.url(""), timeout: 5)
+ api_client = GdsApi::Panopticon.new(nil, endpoint_url: @server.url(""), timeout: 5)
artefact_fixture = {slug: "foo", name: "Foo", owning_app: "Test", kind: "custom-application", need_id: 1}
created = nil
View
12 test/integration_test_helper.rb
@@ -14,12 +14,24 @@ def setup
WebMock.allow_net_connect!
stub_request(:get, /assets\.test\.gov\.uk/).to_return(status: 404)
+
+ @server = startup_server
end
def teardown
DatabaseCleaner.clean
WebMock.reset! # Not entirely sure whether this happens anyway
end
+
+ def startup_server
+ server = Capybara::Server.new(Capybara.app)
+ server.boot
+ server
+ end
+
+ def create_test_user
+ FactoryGirl.create(:user, name: "Test", email: "test@example.com", uid: 123)
+ end
end
Capybara.app = Rack::Builder.new do
Please sign in to comment.
Something went wrong with that request. Please try again.