diff --git a/.gitignore b/.gitignore index c1bb12e..fac89ce 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ .idea /service_broker/manifest.yml /example_app/manifest.yml +.envrc +.rake_t_cache diff --git a/.travis.yml b/.travis.yml index 68ed704..4666be7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,13 @@ branches: only: - - develop - - master - + - develop + - master language: ruby rvm: - - 2.0.0 - +- 2.6.7 before_script: - - chmod +x ci.sh +- chmod +x ci.sh script: ./ci.sh +env: + global: + secure: UwZfR1zlq+42af+6PACVJ+e9qcaHo2ibXiEbFQHQXkCj9cG0DLmdJ6LrhZ9WO0Za/HlB5Lv9988xWV/VGkH10K3n1e59xzEggDYCLpaR3L+YsPHbvX6q9GHKowePo+eztmwI5Vx65zHMMM+9G2mwzzyQBt3yOIG/k90+dUbGtPs= diff --git a/README.md b/README.md index d033a34..00ca0d9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ github-service-broker-ruby ========================== -##Build Status +## Build Status [![Build Status](https://travis-ci.org/cloudfoundry-samples/github-service-broker-ruby.png?branch=develop)](https://travis-ci.org/cloudfoundry-samples/github-service-broker-ruby) (develop branch) @@ -10,13 +10,13 @@ github-service-broker-ruby ## Introduction -A Service Broker is required to integrate any service with a Cloud Foundry instance (for brevity, we'll refer to such an instance simply as "Cloud Foundry") as a [Managed Service](http://docs.cloudfoundry.com/docs/running/architecture/services/#managed). +A Service Broker is required to integrate any service with a Cloud Foundry instance (for brevity, we'll refer to such an instance simply as "Cloud Foundry") as a [Managed Service](http://docs.cloudfoundry.org/services/). -This repo contains a service broker written as standalone ruby application (based on [Sinatra](https://github.com/sinatra/sinatra)) that implements the [v2.0 Service Broker API (aka Services API, or Broker API)](http://docs.cloudfoundry.com/docs/running/architecture/services/api-v2.0.html). +This repo contains a service broker written as standalone ruby application (based on [Sinatra](https://github.com/sinatra/sinatra)) that implements the [v2.0 Service Broker API (aka Services API, or Broker API)](http://docs.cloudfoundry.org/services/api.html). Generally, a Service Broker can be a standalone application that communicates with one or more services, or can be implemented as a component of a service itself. I.e. if the service itself is a Ruby on Rails application, the code in this repository could be added into the application (either copied in, or added as a Rails engine). -This Service Broker is intended to provide a simple yet functional, readable example of how Cloud Foundry service brokers operate. Even if you are developing a broker in another language, this should clearly demonstrate the API endpoints you will need to implement. This broker is not meant as an example of best practices for Ruby software design nor does it demonstrate BOSH packaging; for an example of these concepts see [cf-mysql-release](https://github.com/cloudfoundry/cf-mysql-release). +This Service Broker is intended to provide a simple yet functional, readable example of how Cloud Foundry service brokers operate. Even if you are developing a broker in another language, this should clearly demonstrate the API endpoints you will need to implement. This broker is not meant as an example of best practices for Ruby software design nor does it demonstrate BOSH packaging; for an example of these concepts see [cf-mysql-release](https://github.com/cloudfoundry/cf-mysql-release). ## Repo Contents @@ -26,13 +26,13 @@ The service broker has been written to be as simple to read as possible. There a * service_broker_app.rb - This is the service broker. * github_service_helper.rb - This is how the broker interfaces with GitHub. -* config/settings.yml - The config file contains the service catalog advertised by the broker, credentials used by Cloud Foundry to authenticate with the broker, and credentials used by the broker to authenticate with GitHub. +* config/settings.yml - The config file contains the service catalog advertised by the broker, credentials used by Cloud Foundry to authenticate with the broker, and credentials used by the broker to authenticate with GitHub. ## The GitHub repo service In this example, the service provided is the management of repositories inside a single GitHub account owned by the service administrator. -The Service Broker provides 5 basic functions (see general description in the [API documentation](http://docs.cloudfoundry.com/docs/running/architecture/services/api.html#api-overview)): +The Service Broker provides 5 basic functions (see [API documentation](http://docs.cloudfoundry.org/services/api.html)): Function | Resulting action | -------- | :--------------- | @@ -42,7 +42,7 @@ bind | Generates a GitHub deploy key which gives write access to the repository, unbind | Destroys the deploy key bound to the service instance. delete | Deletes the service instance (repository). -The GitHub credentials of the GitHub account adminstrator should be specified in `settings.yml` if you are deploying your own instance of this broker application. We suggest that you create a dedicated GitHub account solely for the purpose of testing this broker (since it will create and destroy repositories). +The GitHub credentials of the GitHub account administrator should be specified in `settings.yml` if you are deploying your own instance of this broker application. We suggest that you create a dedicated GitHub account solely for the purpose of testing this broker (since it will create and destroy repositories). ## The Service Broker @@ -66,16 +66,24 @@ This service broker application can be deployed on any environment or hosting se For example, to deploy this broker application to Cloud Foundry -1. install the `cf` or `gcf` command line tool -2. log in as a cloud controller admin using `cf login` or `gcf login` +1. install the `cf` command line tool +2. log in as a cloud controller admin using `cf login` 3. fork or clone this git repository 4. add the credentials (username and access token) for the GitHub account in which you want this service broker to provide repository services in `settings.yml`. 5. edit the Basic Auth username and password in `settings.yml` 6. `cd` into the application root directory: `github-service-broker-ruby/service_broker/` -7. run `cf push github-broker` or `gcf push github-broker` to deploy the application to Cloud Foundry -8. register the service broker with CF (instructions [here](http://docs.cloudfoundry.com/docs/running/architecture/services/managing-service-brokers.html#add-broker)) -9. make the service plan public (instructions [here](http://docs.cloudfoundry.com/docs/running/architecture/services/managing-service-brokers.html#make-plans-public)) +7. run `cf push github-broker` to deploy the application to Cloud Foundry +8. register the service broker with CF (instructions [here](http://docs.cloudfoundry.org/services/managing-service-brokers.html#add-broker)) + ```bash + $ cf create-service-broker github-repo admin password http://github-broker. + ``` + +9. make the service plan public (instructions [here](http://docs.cloudfoundry.org/services/access-control.html#enable-access)) + + ```bash + $ cf enable-service-access github-repo + ``` ## The GitHub Service Consumer example application @@ -89,24 +97,13 @@ With `cf`: ``` $ cd github-service-broker-ruby/example_app/ $ cf push github-consumer -$ cf create-service github-repo github-repo-1 --plan public -$ cf bind-service github-repo-1 github-consumer +$ cf create-service github-repo public github-repo-1 +$ cf bind-service github-consumer github-repo-1 $ cf services # can be used to verify the binding was created $ cf restart github-consumer ``` -With `gcf`: - -``` -$ cd github-service-broker-ruby/example_app/ -$ gcf push github-consumer -$ gcf create-service github-repo public github-repo-1 -$ gcf bind-service github-consumer github-repo-1 -$ gcf services # can be used to verify the binding was created -$ gcf restart github-consumer -``` - -Point your web browser at `http://github-consumer.` and you should see the example app's interface. If the app has not been bound to a service instance of the github-repo service, you will see a meaningful error. Once the app has been bound and restarted you can click a submit button to make empty commits to the repo represented by the bound service instance. +Point your web browser at `http://github-consumer.` and you should see the example app's interface. If the app has not been bound to a service instance of the github-repo service, you will see a meaningful error. Once the app has been bound and restarted you can click a submit button to make empty commits to the repo represented by the bound service instance. ### Testing the example app @@ -115,4 +112,3 @@ The integration tests verify that the application can make commits and push them To run the tests, you'll need to create a test account on GitHub, and store the credentials in environment variables (see `example_app/test/integration/github_integration_test.rb` for details) The integration tests can be run by `bundle exec rake integration_test`. - diff --git a/ci.sh b/ci.sh old mode 100644 new mode 100755 diff --git a/example_app/.ruby-version b/example_app/.ruby-version index 33de1dc..e261122 100644 --- a/example_app/.ruby-version +++ b/example_app/.ruby-version @@ -1 +1 @@ -ruby-2.0.0-p353 \ No newline at end of file +2.6.7 diff --git a/example_app/Gemfile b/example_app/Gemfile index a545e37..866a865 100644 --- a/example_app/Gemfile +++ b/example_app/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' -ruby "2.0.0" +ruby '2.6.7' gem 'sinatra' gem 'rack-flash3' @@ -14,4 +14,4 @@ group :test do gem 'capybara_minitest_spec' gem 'octokit' gem 'pry' -end \ No newline at end of file +end diff --git a/example_app/Gemfile.lock b/example_app/Gemfile.lock index e9949ae..0ffbabf 100644 --- a/example_app/Gemfile.lock +++ b/example_app/Gemfile.lock @@ -1,66 +1,87 @@ GEM remote: https://rubygems.org/ specs: - addressable (2.3.5) - capybara (2.2.1) - mime-types (>= 1.16) + addressable (2.8.0) + public_suffix (>= 2.0.2, < 5.0) + capybara (2.15.1) + addressable + mini_mime (>= 0.1.3) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - capybara_minitest_spec (1.0.1) + capybara_minitest_spec (1.0.6) capybara (>= 2) - minitest (>= 2) - cf-app-utils (0.2) - coderay (1.1.0) - faraday (0.8.8) - multipart-post (~> 1.2.0) - ffi (1.9.3) - listen (1.0.3) - rb-fsevent (>= 0.9.3) - rb-inotify (>= 0.9) - rb-kqueue (>= 0.2) - metaclass (0.0.1) - method_source (0.8.2) - mime-types (2.0) - mini_portile (0.5.2) - minitest (5.2.1) - mocha (0.14.0) + minitest (>= 4) + cf-app-utils (0.6) + coderay (1.1.2) + faraday (1.5.1) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0.1) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.1) + faraday-patron (~> 1.0) + multipart-post (>= 1.2, < 3) + ruby2_keywords (>= 0.0.4) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-httpclient (1.0.1) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.2.0) + faraday-patron (1.0.0) + ffi (1.15.0) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + metaclass (0.0.4) + method_source (0.9.0) + mini_mime (0.1.4) + mini_portile2 (2.5.1) + minitest (5.10.3) + mocha (1.3.0) metaclass (~> 0.0.1) - multipart-post (1.2.0) - nokogiri (1.6.1) - mini_portile (~> 0.5.0) - octokit (2.7.0) - sawyer (~> 0.5.2) - pry (0.9.12.4) - coderay (~> 1.0) - method_source (~> 0.8) - slop (~> 3.4) - rack (1.5.2) + multipart-post (2.1.1) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + nokogiri (1.11.4) + mini_portile2 (~> 2.5.0) + racc (~> 1.4) + octokit (4.7.0) + sawyer (~> 0.8.0, >= 0.5.3) + pry (0.11.1) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + public_suffix (4.0.6) + racc (1.5.2) + rack (2.2.3) rack-flash3 (1.0.5) rack - rack-protection (1.5.1) + rack-protection (2.0.2) rack - rack-test (0.6.2) - rack (>= 1.0) - rake (10.1.1) - rb-fsevent (0.9.4) - rb-inotify (0.9.3) - ffi (>= 0.5.0) - rb-kqueue (0.2.0) - ffi (>= 0.5.0) - rerun (0.8.2) - listen (~> 1.0.3) - sawyer (0.5.2) - addressable (~> 2.3.5) - faraday (~> 0.8, < 0.10) - sinatra (1.4.4) - rack (~> 1.4) - rack-protection (~> 1.4) - tilt (~> 1.3, >= 1.3.4) - slop (3.4.7) - tilt (1.4.1) - xpath (2.0.0) + rack-test (0.7.0) + rack (>= 1.0, < 3) + rake (12.3.3) + rb-fsevent (0.10.2) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) + rerun (0.11.0) + listen (~> 3.0) + ruby2_keywords (0.0.4) + ruby_dep (1.5.0) + sawyer (0.8.2) + addressable (>= 2.3.5) + faraday (> 0.8, < 2.0) + sinatra (2.0.2) + mustermann (~> 1.0) + rack (~> 2.0) + rack-protection (= 2.0.2) + tilt (~> 2.0) + tilt (2.0.10) + xpath (2.1.0) nokogiri (~> 1.3) PLATFORMS @@ -78,3 +99,9 @@ DEPENDENCIES rake rerun sinatra + +RUBY VERSION + ruby 2.6.7p197 + +BUNDLED WITH + 1.17.2 diff --git a/example_app/Rakefile b/example_app/Rakefile index 527be16..28810d2 100644 --- a/example_app/Rakefile +++ b/example_app/Rakefile @@ -7,3 +7,5 @@ end Rake::TestTask.new(:integration_test) do |t| t.pattern = "test/integration/*_test.rb" end + +task default: :test diff --git a/example_app/github_repo_helper.rb b/example_app/github_repo_helper.rb index f5dca99..ca7013c 100644 --- a/example_app/github_repo_helper.rb +++ b/example_app/github_repo_helper.rb @@ -54,10 +54,11 @@ def shell_create_and_push_commit(repo_credentials, application_name) private_key = repo_credentials["private_key"] repo_name = repo_credentials["name"] repo_ssh_url = repo_credentials["ssh_url"] - keys_dir = "/tmp/github_keys" + temp_dir = Dir.mktmpdir + keys_dir = "#{temp_dir}/github_keys" key_file_name = "#{keys_dir}/#{repo_name}.key" - git_ssh_script = "/tmp/#{repo_name}_ssh_script.sh" - known_hosts_file = "/tmp/github_known_hosts" + git_ssh_script = "#{temp_dir}/#{repo_name}_ssh_script.sh" + known_hosts_file = "#{temp_dir}/github_known_hosts" # Create directory for storing key file, and set permissions `if [ ! -d #{keys_dir} ]; then mkdir #{keys_dir}; fi` @@ -87,14 +88,14 @@ def shell_create_and_push_commit(repo_credentials, application_name) end commands = [ - "cd /tmp; GIT_SSH=#{git_ssh_script} git clone #{repo_ssh_url} 2>&1", - "cd /tmp/#{repo_name} && git config user.name '#{application_name}' 2>&1", - "cd /tmp/#{repo_name} && git commit --allow-empty -m 'auto generated empty commit' 2>&1", - "cd /tmp/#{repo_name} && git log --pretty=format:\"%h%x09%ad%x09%s\" 2>&1", - "cd /tmp/#{repo_name}; GIT_SSH=#{git_ssh_script} git push origin master 2>&1" + "cd #{temp_dir}; GIT_SSH=#{git_ssh_script} git clone #{repo_ssh_url} 2>&1", + "cd #{temp_dir}/#{repo_name} && git config user.name '#{application_name}' 2>&1", + "cd #{temp_dir}/#{repo_name} && git config user.email '#{application_name}@example.com' 2>&1", + "cd #{temp_dir}/#{repo_name} && git commit --allow-empty -m 'auto generated empty commit' 2>&1", + "cd #{temp_dir}/#{repo_name} && git log --pretty=format:\"%h%x09%ad%x09%s\" 2>&1", + "cd #{temp_dir}/#{repo_name}; GIT_SSH=#{git_ssh_script} git push origin master 2>&1" ] - return_code = 0 output = "" @@ -109,7 +110,7 @@ def shell_create_and_push_commit(repo_credentials, application_name) cleanup_commands = [ "rm #{key_file_name}", "rm #{git_ssh_script}", - "rm -rf /tmp/#{repo_name}" + "rm -rf #{temp_dir}/#{repo_name}" ] cleanup_commands.each do |command| @@ -131,4 +132,4 @@ def credentials_are_present?(credentials) blank?(credentials["ssh_url"]) || blank?(credentials["private_key"])) end -end \ No newline at end of file +end diff --git a/example_app/service_consumer_app.rb b/example_app/service_consumer_app.rb index 54f4912..3c0719f 100644 --- a/example_app/service_consumer_app.rb +++ b/example_app/service_consumer_app.rb @@ -77,6 +77,7 @@ def service_name end def credentials_of_all_repos - CF::App::Credentials.find_all_by_service_label(service_name) + @credentials ||= CF::App::Credentials.new({'VCAP_SERVICES' => vcap_services}) + @credentials.find_all_by_service_label(service_name) end -end \ No newline at end of file +end diff --git a/example_app/test/integration/github_integration_test.rb b/example_app/test/integration/github_integration_test.rb index 377ff18..a4fa77a 100644 --- a/example_app/test/integration/github_integration_test.rb +++ b/example_app/test/integration/github_integration_test.rb @@ -5,7 +5,7 @@ before do ensure_env_vars_exist - @vcap_services_value = < 0.9.0) - faraday (0.8.8) - multipart-post (~> 1.2.0) - json (1.8.1) - metaclass (0.0.1) - method_source (0.8.2) - mocha (0.14.0) + addressable (2.8.0) + public_suffix (>= 2.0.2, < 5.0) + coderay (1.1.2) + crack (0.4.3) + safe_yaml (~> 1.0.0) + faraday (1.5.1) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0.1) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.1) + faraday-patron (~> 1.0) + multipart-post (>= 1.2, < 3) + ruby2_keywords (>= 0.0.4) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-httpclient (1.0.1) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.2.0) + faraday-patron (1.0.0) + hashdiff (0.3.6) + json (2.3.0) + metaclass (0.0.4) + method_source (0.9.0) + minitest (5.10.3) + mocha (1.3.0) metaclass (~> 0.0.1) - multipart-post (1.2.0) - octokit (2.6.3) - sawyer (~> 0.5.1) - pry (0.9.12.4) - coderay (~> 1.0) - method_source (~> 0.8) - slop (~> 3.4) - rack (1.5.2) - rack-protection (1.5.1) + multipart-post (2.1.1) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + octokit (4.7.0) + sawyer (~> 0.8.0, >= 0.5.3) + pry (0.11.1) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + public_suffix (4.0.6) + rack (2.2.3) + rack-protection (2.0.2) rack - rack-test (0.6.2) - rack (>= 1.0) - rake (10.1.1) - safe_yaml (0.9.7) - sawyer (0.5.1) - addressable (~> 2.3.5) - faraday (~> 0.8, < 0.10) - sinatra (1.4.4) - rack (~> 1.4) - rack-protection (~> 1.4) - tilt (~> 1.3, >= 1.3.4) - slop (3.4.7) - sshkey (1.6.1) - tilt (1.4.1) - webmock (1.16.0) - addressable (>= 2.2.7) + rack-test (0.7.0) + rack (>= 1.0, < 3) + rake (12.3.3) + ruby2_keywords (0.0.4) + safe_yaml (1.0.4) + sawyer (0.8.2) + addressable (>= 2.3.5) + faraday (> 0.8, < 2.0) + sinatra (2.0.2) + mustermann (~> 1.0) + rack (~> 2.0) + rack-protection (= 2.0.2) + tilt (~> 2.0) + sshkey (1.9.0) + tilt (2.0.10) + webmock (3.0.1) + addressable (>= 2.3.6) crack (>= 0.3.2) + hashdiff PLATFORMS ruby DEPENDENCIES json + minitest mocha octokit pry @@ -53,3 +76,9 @@ DEPENDENCIES sinatra sshkey webmock + +RUBY VERSION + ruby 2.6.7p197 + +BUNDLED WITH + 1.17.2 diff --git a/service_broker/Rakefile b/service_broker/Rakefile index 32a4f7f..686288a 100644 --- a/service_broker/Rakefile +++ b/service_broker/Rakefile @@ -3,3 +3,5 @@ require 'rake/testtask' Rake::TestTask.new do |t| t.pattern = "test/*_test.rb" end + +task default: :test diff --git a/service_broker/github_service_helper.rb b/service_broker/github_service_helper.rb index 7de38c1..5d2abfc 100644 --- a/service_broker/github_service_helper.rb +++ b/service_broker/github_service_helper.rb @@ -28,7 +28,7 @@ def create_github_repo(name) # error due to unknown reason, pass the original error message upstream raise GithubServiceHelper::GithubError.new("GitHub returned an error - #{e.message}") end - rescue Faraday::Error::TimeoutError + rescue Faraday::Error::TimeoutError, Faraday::ConnectionFailed raise GithubServiceHelper::GithubUnreachableError end @@ -40,7 +40,7 @@ def delete_github_repo(name) octokit_client.delete_repository(full_repo_name(name)) rescue Octokit::Error => e raise GithubServiceHelper::GithubError.new("GitHub returned an error - #{e.message}") - rescue Faraday::Error::TimeoutError + rescue Faraday::Error::TimeoutError, Faraday::ConnectionFailed raise GithubServiceHelper::GithubUnreachableError end end @@ -88,7 +88,7 @@ def get_deploy_keys(full_repo_name) raise GithubServiceHelper::GithubResourceNotFoundError rescue Octokit::Error => e raise GithubServiceHelper::GithubError.new("GitHub returned an error - #{e.message}") - rescue Faraday::Error::TimeoutError + rescue Faraday::Error::TimeoutError, Faraday::ConnectionFailed raise GithubServiceHelper::GithubUnreachableError end end @@ -98,7 +98,7 @@ def add_deploy_key(deploy_key_title, full_repo_name, public_key) octokit_client.add_deploy_key(full_repo_name, deploy_key_title, public_key) rescue Octokit::Error => e raise GithubServiceHelper::GithubError.new("GitHub returned an error - #{e.message}") - rescue Faraday::Error::TimeoutError + rescue Faraday::Error::TimeoutError, Faraday::ConnectionFailed raise GithubServiceHelper::GithubUnreachableError end end @@ -108,7 +108,7 @@ def remove_deploy_key(full_repo_name, deploy_key_id) octokit_client.remove_deploy_key(full_repo_name, deploy_key_id) rescue Octokit::Error => e raise GithubServiceHelper::GithubError.new("GitHub returned an error - #{e.message}") - rescue Faraday::Error::TimeoutError + rescue Faraday::Error::TimeoutError, Faraday::ConnectionFailed raise GithubServiceHelper::GithubUnreachableError end end @@ -129,4 +129,3 @@ def octokit_client ::Octokit::Client.new(access_token: @access_token) end end - diff --git a/service_broker/test/github_service_helper_test.rb b/service_broker/test/github_service_helper_test.rb index bb396da..82f0f3d 100644 --- a/service_broker/test/github_service_helper_test.rb +++ b/service_broker/test/github_service_helper_test.rb @@ -85,8 +85,8 @@ def stub_successful_deploy_key_list_request(repo_name, empty = false) GithubServiceHelper.new('octocat', 'access-token').create_github_repo("Hello-World") }.must_raise GithubServiceHelper::GithubError - expected_exception.message.must_match /GitHub returned an error/ - expected_exception.message.must_match /Semantically Invalid/ + expected_exception.message.must_match(/GitHub returned an error/) + expected_exception.message.must_match(/Semantically Invalid/) end end @@ -110,8 +110,8 @@ def stub_successful_deploy_key_list_request(repo_name, empty = false) GithubServiceHelper.new('octocat', 'access-token').create_github_repo("Hello-World") }.must_raise GithubServiceHelper::GithubError - expected_exception.message.must_match /GitHub returned an error/ - expected_exception.message.must_match /Validation Failed/ + expected_exception.message.must_match(/GitHub returned an error/) + expected_exception.message.must_match(/Validation Failed/) end end @@ -184,8 +184,8 @@ def stub_key_pair_generation GithubServiceHelper.new('octocat', 'access-token').create_github_deploy_key(repo_name: @repo_name, deploy_key_title: @key_title) }.must_raise GithubServiceHelper::GithubError - expected_exception.message.must_match /GitHub returned an error/ - expected_exception.message.must_match /some error message/ + expected_exception.message.must_match(/GitHub returned an error/) + expected_exception.message.must_match(/some error message/) end end @@ -285,8 +285,8 @@ def stub_key_pair_generation GithubServiceHelper.new('octocat', 'access-token').create_github_deploy_key(repo_name: @repo_name, deploy_key_title: @key_title) }.must_raise GithubServiceHelper::GithubError - expected_exception.message.must_match /GitHub returned an error/ - expected_exception.message.must_match /key is invalid. Ensure you've copied the file correctly/ + expected_exception.message.must_match(/GitHub returned an error/) + expected_exception.message.must_match(/key is invalid. Ensure you've copied the file correctly/) end end @@ -403,8 +403,8 @@ def stub_key_pair_generation remove_github_deploy_key(repo_name: @repo_name, deploy_key_title: @key_title) }.must_raise GithubServiceHelper::GithubError - expected_exception.message.must_match /GitHub returned an error/ - expected_exception.message.must_match /some error message/ + expected_exception.message.must_match(/GitHub returned an error/) + expected_exception.message.must_match(/some error message/) end end end @@ -515,8 +515,8 @@ def stub_key_pair_generation remove_github_deploy_key(repo_name: @repo_name, deploy_key_title: @key_title) }.must_raise GithubServiceHelper::GithubError - expected_exception.message.must_match /GitHub returned an error/ - expected_exception.message.must_match /some error message/ + expected_exception.message.must_match(/GitHub returned an error/) + expected_exception.message.must_match(/some error message/) end end @@ -596,8 +596,8 @@ def stub_key_pair_generation GithubServiceHelper.new('octocat', 'access-token').delete_github_repo(@repo_name) }.must_raise GithubServiceHelper::GithubError - expected_exception.message.must_match /GitHub returned an error/ - expected_exception.message.must_match /some error message/ + expected_exception.message.must_match(/GitHub returned an error/) + expected_exception.message.must_match(/some error message/) end end diff --git a/service_broker/test/test_helper.rb b/service_broker/test/test_helper.rb index 54901ac..ea37305 100644 --- a/service_broker/test/test_helper.rb +++ b/service_broker/test/test_helper.rb @@ -1,4 +1,5 @@ ENV['RACK_ENV'] = 'test' + require 'minitest/autorun' require 'minitest/spec' require 'rack/test' @@ -9,4 +10,4 @@ SETTINGS_FILENAME = "test/config/settings.yml" require File.expand_path '../../service_broker_app.rb', __FILE__ -require File.expand_path '../../github_service_helper.rb', __FILE__ \ No newline at end of file +require File.expand_path '../../github_service_helper.rb', __FILE__