From 046b28312704f3131e72dcd2dbdacc5264d4aa62 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 25 Aug 2015 18:42:46 -0700 Subject: Groundwork for merging CI into CE --- spec/support/filter_spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/support') diff --git a/spec/support/filter_spec_helper.rb b/spec/support/filter_spec_helper.rb index 755964e9a3d..203117aee70 100644 --- a/spec/support/filter_spec_helper.rb +++ b/spec/support/filter_spec_helper.rb @@ -72,6 +72,6 @@ module FilterSpecHelper # Shortcut to Rails' auto-generated routes helpers, to avoid including the # module def urls - Rails.application.routes.url_helpers + Gitlab::Application.routes.url_helpers end end -- cgit v1.2.1 From 263abda3fd7ddfb826cd17ae88fb47d0e1d67fae Mon Sep 17 00:00:00 2001 From: Kirilll Zaitsev Date: Thu, 27 Aug 2015 02:58:49 +0300 Subject: Drone CI service --- spec/support/services_shared_context.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 spec/support/services_shared_context.rb (limited to 'spec/support') diff --git a/spec/support/services_shared_context.rb b/spec/support/services_shared_context.rb new file mode 100644 index 00000000000..4d007ae55ee --- /dev/null +++ b/spec/support/services_shared_context.rb @@ -0,0 +1,21 @@ +Service.available_services_names.each do |service| + shared_context service do + let(:dashed_service) { service.dasherize } + let(:service_method) { "#{service}_service".to_sym } + let(:service_klass) { "#{service}_service".classify.constantize } + let(:service_attrs_list) { service_klass.new.fields.inject([]) {|arr, hash| arr << hash[:name].to_sym } } + let(:service_attrs) do + service_attrs_list.inject({}) do |hash, k| + if k =~ /^(token*|.*_token|.*_key)/ + hash.merge!(k => 'secrettoken') + elsif k =~ /^(.*_url|url|webhook)/ + hash.merge!(k => "http://example.com") + elsif service == 'irker' && k == :recipients + hash.merge!(k => 'irc://irc.network.net:666/#channel') + else + hash.merge!(k => "someword") + end + end + end + end +end -- cgit v1.2.1 From 8820785c8fe267789a5c6edf7f4fcb196c48b4a8 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sun, 6 Sep 2015 09:42:39 -0700 Subject: Fix emoji URLs in Markdown when relative_url_root is used Also adds the ability to run rspecs with relative_url_defined on the enviornment. For example: RELATIVE_URL_ROOT=/gitlab rspec Closes #1728 --- spec/support/matchers/markdown_matchers.rb | 3 +++ spec/support/relative_url.rb | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 spec/support/relative_url.rb (limited to 'spec/support') diff --git a/spec/support/matchers/markdown_matchers.rb b/spec/support/matchers/markdown_matchers.rb index 9df226c3af8..7500d0fdf80 100644 --- a/spec/support/matchers/markdown_matchers.rb +++ b/spec/support/matchers/markdown_matchers.rb @@ -27,6 +27,9 @@ module MarkdownMatchers match do |actual| expect(actual).to have_selector('img.emoji', count: 10) + + image = actual.at_css('img.emoji') + expect(image['src'].to_s).to start_with(Gitlab.config.gitlab.url + '/assets') end end diff --git a/spec/support/relative_url.rb b/spec/support/relative_url.rb new file mode 100644 index 00000000000..72e3ccce75b --- /dev/null +++ b/spec/support/relative_url.rb @@ -0,0 +1,8 @@ +# Fix route helpers in tests (e.g. root_path, ...) +module RelativeUrl + extend ActiveSupport::Concern + + included do + default_url_options[:script_name] = Rails.application.config.relative_url_root + end +end -- cgit v1.2.1 From 76c6aeb9bc9855e9a65bb08db862e92ac923255e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 9 Sep 2015 13:37:50 +0200 Subject: Merge CI factories and CI spec/support with GitLab --- spec/support/gitlab_stubs/gitlab_ci.yml | 63 +++++++++++++++++++++ spec/support/gitlab_stubs/project_8.json | 45 +++++++++++++++ spec/support/gitlab_stubs/project_8_hooks.json | 1 + spec/support/gitlab_stubs/projects.json | 1 + spec/support/gitlab_stubs/raw_project.yml | 36 ++++++++++++ spec/support/gitlab_stubs/session.json | 20 +++++++ spec/support/gitlab_stubs/user.json | 20 +++++++ spec/support/setup_builds_storage.rb | 16 ++++++ spec/support/stub_gitlab_calls.rb | 77 ++++++++++++++++++++++++++ spec/support/stub_gitlab_data.rb | 5 ++ 10 files changed, 284 insertions(+) create mode 100644 spec/support/gitlab_stubs/gitlab_ci.yml create mode 100644 spec/support/gitlab_stubs/project_8.json create mode 100644 spec/support/gitlab_stubs/project_8_hooks.json create mode 100644 spec/support/gitlab_stubs/projects.json create mode 100644 spec/support/gitlab_stubs/raw_project.yml create mode 100644 spec/support/gitlab_stubs/session.json create mode 100644 spec/support/gitlab_stubs/user.json create mode 100644 spec/support/setup_builds_storage.rb create mode 100644 spec/support/stub_gitlab_calls.rb create mode 100644 spec/support/stub_gitlab_data.rb (limited to 'spec/support') diff --git a/spec/support/gitlab_stubs/gitlab_ci.yml b/spec/support/gitlab_stubs/gitlab_ci.yml new file mode 100644 index 00000000000..3482145404e --- /dev/null +++ b/spec/support/gitlab_stubs/gitlab_ci.yml @@ -0,0 +1,63 @@ +image: ruby:2.1 +services: + - postgres + +before_script: + - gem install bundler + - bundle install + - bundle exec rake db:create + +variables: + DB_NAME: postgres + +types: + - test + - deploy + - notify + +rspec: + script: "rake spec" + tags: + - ruby + - postgres + only: + - branches + +spinach: + script: "rake spinach" + allow_failure: true + tags: + - ruby + - mysql + except: + - tags + +staging: + script: "cap deploy stating" + type: deploy + tags: + - capistrano + - debian + except: + - stable + +production: + type: deploy + script: + - cap deploy production + - cap notify + tags: + - capistrano + - debian + only: + - master + - /^deploy-.*$/ + +dockerhub: + type: notify + script: "curl http://dockerhub/URL" + tags: + - ruby + - postgres + only: + - branches diff --git a/spec/support/gitlab_stubs/project_8.json b/spec/support/gitlab_stubs/project_8.json new file mode 100644 index 00000000000..f0a9fce859c --- /dev/null +++ b/spec/support/gitlab_stubs/project_8.json @@ -0,0 +1,45 @@ +{ + "id":8, + "description":"ssh access and repository management app for GitLab", + "default_branch":"master", + "public":false, + "visibility_level":0, + "ssh_url_to_repo":"git@demo.gitlab.com:gitlab/gitlab-shell.git", + "http_url_to_repo":"http://demo.gitlab.com/gitlab/gitlab-shell.git", + "web_url":"http://demo.gitlab.com/gitlab/gitlab-shell", + "owner": { + "id":4, + "name":"GitLab", + "created_at":"2012-12-21T13:03:05Z" + }, + "name":"gitlab-shell", + "name_with_namespace":"GitLab / gitlab-shell", + "path":"gitlab-shell", + "path_with_namespace":"gitlab/gitlab-shell", + "issues_enabled":true, + "merge_requests_enabled":true, + "wall_enabled":false, + "wiki_enabled":true, + "snippets_enabled":false, + "created_at":"2013-03-20T13:28:53Z", + "last_activity_at":"2013-11-30T00:11:17Z", + "namespace":{ + "created_at":"2012-12-21T13:03:05Z", + "description":"Self hosted Git management software", + "id":4, + "name":"GitLab", + "owner_id":1, + "path":"gitlab", + "updated_at":"2013-03-20T13:29:13Z" + }, + "permissions":{ + "project_access": { + "access_level": 10, + "notification_level": 3 + }, + "group_access": { + "access_level": 50, + "notification_level": 3 + } + } +} \ No newline at end of file diff --git a/spec/support/gitlab_stubs/project_8_hooks.json b/spec/support/gitlab_stubs/project_8_hooks.json new file mode 100644 index 00000000000..93d51406d63 --- /dev/null +++ b/spec/support/gitlab_stubs/project_8_hooks.json @@ -0,0 +1 @@ +[{}] diff --git a/spec/support/gitlab_stubs/projects.json b/spec/support/gitlab_stubs/projects.json new file mode 100644 index 00000000000..ca42c14c5d8 --- /dev/null +++ b/spec/support/gitlab_stubs/projects.json @@ -0,0 +1 @@ +[{"id":3,"description":"GitLab is open source software to collaborate on code. Create projects and repositories, manage access and do code reviews.","default_branch":"master","public":true,"visibility_level":20,"ssh_url_to_repo":"git@demo.gitlab.com:gitlab/gitlabhq.git","http_url_to_repo":"http://demo.gitlab.com/gitlab/gitlabhq.git","web_url":"http://demo.gitlab.com/gitlab/gitlabhq","owner":{"id":4,"name":"GitLab","created_at":"2012-12-21T13:03:05Z"},"name":"gitlabhq","name_with_namespace":"GitLab / gitlabhq","path":"gitlabhq","path_with_namespace":"gitlab/gitlabhq","issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":true,"wiki_enabled":true,"snippets_enabled":true,"created_at":"2012-12-21T13:06:34Z","last_activity_at":"2013-12-02T19:10:10Z","namespace":{"created_at":"2012-12-21T13:03:05Z","description":"Self hosted Git management software","id":4,"name":"GitLab","owner_id":1,"path":"gitlab","updated_at":"2013-03-20T13:29:13Z"}},{"id":4,"description":"Component of GitLab CI. Web application","default_branch":"master","public":false,"visibility_level":0,"ssh_url_to_repo":"git@demo.gitlab.com:gitlab/gitlab-ci.git","http_url_to_repo":"http://demo.gitlab.com/gitlab/gitlab-ci.git","web_url":"http://demo.gitlab.com/gitlab/gitlab-ci","owner":{"id":4,"name":"GitLab","created_at":"2012-12-21T13:03:05Z"},"name":"gitlab-ci","name_with_namespace":"GitLab / gitlab-ci","path":"gitlab-ci","path_with_namespace":"gitlab/gitlab-ci","issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":true,"wiki_enabled":true,"snippets_enabled":true,"created_at":"2012-12-21T13:06:50Z","last_activity_at":"2013-11-28T19:26:54Z","namespace":{"created_at":"2012-12-21T13:03:05Z","description":"Self hosted Git management software","id":4,"name":"GitLab","owner_id":1,"path":"gitlab","updated_at":"2013-03-20T13:29:13Z"}},{"id":5,"description":"","default_branch":"master","public":true,"visibility_level":20,"ssh_url_to_repo":"git@demo.gitlab.com:gitlab/gitlab-recipes.git","http_url_to_repo":"http://demo.gitlab.com/gitlab/gitlab-recipes.git","web_url":"http://demo.gitlab.com/gitlab/gitlab-recipes","owner":{"id":4,"name":"GitLab","created_at":"2012-12-21T13:03:05Z"},"name":"gitlab-recipes","name_with_namespace":"GitLab / gitlab-recipes","path":"gitlab-recipes","path_with_namespace":"gitlab/gitlab-recipes","issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":true,"wiki_enabled":true,"snippets_enabled":true,"created_at":"2012-12-21T13:07:02Z","last_activity_at":"2013-12-02T13:54:10Z","namespace":{"created_at":"2012-12-21T13:03:05Z","description":"Self hosted Git management software","id":4,"name":"GitLab","owner_id":1,"path":"gitlab","updated_at":"2013-03-20T13:29:13Z"}},{"id":8,"description":"ssh access and repository management app for GitLab","default_branch":"master","public":false,"visibility_level":0,"ssh_url_to_repo":"git@demo.gitlab.com:gitlab/gitlab-shell.git","http_url_to_repo":"http://demo.gitlab.com/gitlab/gitlab-shell.git","web_url":"http://demo.gitlab.com/gitlab/gitlab-shell","owner":{"id":4,"name":"GitLab","created_at":"2012-12-21T13:03:05Z"},"name":"gitlab-shell","name_with_namespace":"GitLab / gitlab-shell","path":"gitlab-shell","path_with_namespace":"gitlab/gitlab-shell","issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":false,"wiki_enabled":true,"snippets_enabled":false,"created_at":"2013-03-20T13:28:53Z","last_activity_at":"2013-11-30T00:11:17Z","namespace":{"created_at":"2012-12-21T13:03:05Z","description":"Self hosted Git management software","id":4,"name":"GitLab","owner_id":1,"path":"gitlab","updated_at":"2013-03-20T13:29:13Z"}},{"id":9,"description":null,"default_branch":"master","public":false,"visibility_level":0,"ssh_url_to_repo":"git@demo.gitlab.com:gitlab/gitlab_git.git","http_url_to_repo":"http://demo.gitlab.com/gitlab/gitlab_git.git","web_url":"http://demo.gitlab.com/gitlab/gitlab_git","owner":{"id":4,"name":"GitLab","created_at":"2012-12-21T13:03:05Z"},"name":"gitlab_git","name_with_namespace":"GitLab / gitlab_git","path":"gitlab_git","path_with_namespace":"gitlab/gitlab_git","issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":false,"wiki_enabled":true,"snippets_enabled":false,"created_at":"2013-04-28T19:15:08Z","last_activity_at":"2013-12-02T13:07:13Z","namespace":{"created_at":"2012-12-21T13:03:05Z","description":"Self hosted Git management software","id":4,"name":"GitLab","owner_id":1,"path":"gitlab","updated_at":"2013-03-20T13:29:13Z"}},{"id":10,"description":"ultra lite authorization library http://randx.github.com/six/\\r\\n ","default_branch":"master","public":true,"visibility_level":20,"ssh_url_to_repo":"git@demo.gitlab.com:sandbox/six.git","http_url_to_repo":"http://demo.gitlab.com/sandbox/six.git","web_url":"http://demo.gitlab.com/sandbox/six","owner":{"id":8,"name":"Sandbox","created_at":"2013-08-01T16:44:17Z"},"name":"Six","name_with_namespace":"Sandbox / Six","path":"six","path_with_namespace":"sandbox/six","issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":false,"wiki_enabled":true,"snippets_enabled":false,"created_at":"2013-08-01T16:45:02Z","last_activity_at":"2013-11-29T11:30:56Z","namespace":{"created_at":"2013-08-01T16:44:17Z","description":"","id":8,"name":"Sandbox","owner_id":1,"path":"sandbox","updated_at":"2013-08-01T16:44:17Z"}},{"id":11,"description":"Simple HTML5 Charts using the tag ","default_branch":"master","public":false,"visibility_level":0,"ssh_url_to_repo":"git@demo.gitlab.com:sandbox/charts-js.git","http_url_to_repo":"http://demo.gitlab.com/sandbox/charts-js.git","web_url":"http://demo.gitlab.com/sandbox/charts-js","owner":{"id":8,"name":"Sandbox","created_at":"2013-08-01T16:44:17Z"},"name":"Charts.js","name_with_namespace":"Sandbox / Charts.js","path":"charts-js","path_with_namespace":"sandbox/charts-js","issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":false,"wiki_enabled":true,"snippets_enabled":false,"created_at":"2013-08-01T16:47:29Z","last_activity_at":"2013-12-02T15:18:11Z","namespace":{"created_at":"2013-08-01T16:44:17Z","description":"","id":8,"name":"Sandbox","owner_id":1,"path":"sandbox","updated_at":"2013-08-01T16:44:17Z"}},{"id":13,"description":"","default_branch":"master","public":false,"visibility_level":0,"ssh_url_to_repo":"git@demo.gitlab.com:sandbox/afro.git","http_url_to_repo":"http://demo.gitlab.com/sandbox/afro.git","web_url":"http://demo.gitlab.com/sandbox/afro","owner":{"id":8,"name":"Sandbox","created_at":"2013-08-01T16:44:17Z"},"name":"Afro","name_with_namespace":"Sandbox / Afro","path":"afro","path_with_namespace":"sandbox/afro","issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":false,"wiki_enabled":true,"snippets_enabled":false,"created_at":"2013-11-14T17:45:19Z","last_activity_at":"2013-12-02T17:41:45Z","namespace":{"created_at":"2013-08-01T16:44:17Z","description":"","id":8,"name":"Sandbox","owner_id":1,"path":"sandbox","updated_at":"2013-08-01T16:44:17Z"}}] \ No newline at end of file diff --git a/spec/support/gitlab_stubs/raw_project.yml b/spec/support/gitlab_stubs/raw_project.yml new file mode 100644 index 00000000000..df2ce223d1f --- /dev/null +++ b/spec/support/gitlab_stubs/raw_project.yml @@ -0,0 +1,36 @@ +--- !ruby/object:OpenStruct +table: + :id: 189 + :description: Website at http://api.gitlab.org/ + :default_branch: master + :public: false + :visibility_level: 0 + :ssh_url_to_repo: dzaporozhets@localhost:gitlab/api-gitlab-org.git + :http_url_to_repo: http://localhost:3000/gitlab/api-gitlab-org.git + :web_url: http://localhost:3000/gitlab/api-gitlab-org + :owner: + id: 1 + name: GitLab + created_at: '2012-10-03T09:59:57.000Z' + :name: api.gitlab.org + :name_with_namespace: GitLab / api.gitlab.org + :path: api-gitlab-org + :path_with_namespace: gitlab/api-gitlab-org + :issues_enabled: true + :merge_requests_enabled: true + :wall_enabled: false + :wiki_enabled: false + :snippets_enabled: false + :created_at: '2013-06-06T12:29:39.000Z' + :last_activity_at: '2013-12-06T20:29:42.000Z' + :namespace: + id: 1 + name: GitLab + path: gitlab + owner_id: 1 + created_at: '2012-10-03T09:59:57.000Z' + updated_at: '2014-01-28T08:49:53.000Z' + description: Self hosted Git management software + avatar: + url: /uploads/group/avatar/1/0-vader-profile.jpg + diff --git a/spec/support/gitlab_stubs/session.json b/spec/support/gitlab_stubs/session.json new file mode 100644 index 00000000000..ce8dfe5ae75 --- /dev/null +++ b/spec/support/gitlab_stubs/session.json @@ -0,0 +1,20 @@ +{ + "id":2, + "username":"jsmith", + "email":"test@test.com", + "name":"John Smith", + "bio":"", + "skype":"aertert", + "linkedin":"", + "twitter":"", + "theme_id":2,"color_scheme_id":2, + "state":"active", + "created_at":"2012-12-21T13:02:20Z", + "extern_uid":null, + "provider":null, + "is_admin":false, + "can_create_group":false, + "can_create_project":false, + "private_token":"Wvjy2Krpb7y8xi93owUz", + "access_token":"Wvjy2Krpb7y8xi93owUz" +} \ No newline at end of file diff --git a/spec/support/gitlab_stubs/user.json b/spec/support/gitlab_stubs/user.json new file mode 100644 index 00000000000..ce8dfe5ae75 --- /dev/null +++ b/spec/support/gitlab_stubs/user.json @@ -0,0 +1,20 @@ +{ + "id":2, + "username":"jsmith", + "email":"test@test.com", + "name":"John Smith", + "bio":"", + "skype":"aertert", + "linkedin":"", + "twitter":"", + "theme_id":2,"color_scheme_id":2, + "state":"active", + "created_at":"2012-12-21T13:02:20Z", + "extern_uid":null, + "provider":null, + "is_admin":false, + "can_create_group":false, + "can_create_project":false, + "private_token":"Wvjy2Krpb7y8xi93owUz", + "access_token":"Wvjy2Krpb7y8xi93owUz" +} \ No newline at end of file diff --git a/spec/support/setup_builds_storage.rb b/spec/support/setup_builds_storage.rb new file mode 100644 index 00000000000..cafc8dee918 --- /dev/null +++ b/spec/support/setup_builds_storage.rb @@ -0,0 +1,16 @@ +RSpec.configure do |config| + def builds_path + Rails.root.join('tmp/builds_test') + end + + config.before(:each) do + FileUtils.mkdir_p(builds_path) + Ci::Settings.gitlab_ci['builds_path'] = builds_path + end + + config.after(:suite) do + Dir.chdir(builds_path) do + `ls | grep -v .gitkeep | xargs rm -r` + end + end +end diff --git a/spec/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb new file mode 100644 index 00000000000..931ef963c0f --- /dev/null +++ b/spec/support/stub_gitlab_calls.rb @@ -0,0 +1,77 @@ +module StubGitlabCalls + def stub_gitlab_calls + stub_session + stub_user + stub_project_8 + stub_project_8_hooks + stub_projects + stub_projects_owned + stub_ci_enable + end + + def stub_js_gitlab_calls + Network.any_instance.stub(:projects) { project_hash_array } + end + + private + + def gitlab_url + GitlabCi.config.gitlab_server.url + end + + def stub_session + f = File.read(Rails.root.join('spec/support/gitlab_stubs/session.json')) + + stub_request(:post, "#{gitlab_url}api/v3/session.json"). + with(:body => "{\"email\":\"test@test.com\",\"password\":\"123456\"}", + :headers => {'Content-Type'=>'application/json'}). + to_return(:status => 201, :body => f, :headers => {'Content-Type'=>'application/json'}) + end + + def stub_user + f = File.read(Rails.root.join('spec/support/gitlab_stubs/user.json')) + + stub_request(:get, "#{gitlab_url}api/v3/user?private_token=Wvjy2Krpb7y8xi93owUz"). + with(:headers => {'Content-Type'=>'application/json'}). + to_return(:status => 200, :body => f, :headers => {'Content-Type'=>'application/json'}) + + stub_request(:get, "#{gitlab_url}api/v3/user?access_token=some_token"). + with(:headers => {'Content-Type'=>'application/json'}). + to_return(:status => 200, :body => f, :headers => {'Content-Type'=>'application/json'}) + end + + def stub_project_8 + data = File.read(Rails.root.join('spec/support/gitlab_stubs/project_8.json')) + Network.any_instance.stub(:project).and_return(JSON.parse(data)) + end + + def stub_project_8_hooks + data = File.read(Rails.root.join('spec/support/gitlab_stubs/project_8_hooks.json')) + Network.any_instance.stub(:project_hooks).and_return(JSON.parse(data)) + end + + def stub_projects + f = File.read(Rails.root.join('spec/support/gitlab_stubs/projects.json')) + + stub_request(:get, "#{gitlab_url}api/v3/projects.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz"). + with(:headers => {'Content-Type'=>'application/json'}). + to_return(:status => 200, :body => f, :headers => {'Content-Type'=>'application/json'}) + end + + def stub_projects_owned + stub_request(:get, "#{gitlab_url}api/v3/projects/owned.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz"). + with(:headers => {'Content-Type'=>'application/json'}). + to_return(:status => 200, :body => "", :headers => {}) + end + + def stub_ci_enable + stub_request(:put, "#{gitlab_url}api/v3/projects/2/services/gitlab-ci.json?private_token=Wvjy2Krpb7y8xi93owUz"). + with(:headers => {'Content-Type'=>'application/json'}). + to_return(:status => 200, :body => "", :headers => {}) + end + + def project_hash_array + f = File.read(Rails.root.join('spec/support/gitlab_stubs/projects.json')) + return JSON.parse f + end +end diff --git a/spec/support/stub_gitlab_data.rb b/spec/support/stub_gitlab_data.rb new file mode 100644 index 00000000000..fa402f35b95 --- /dev/null +++ b/spec/support/stub_gitlab_data.rb @@ -0,0 +1,5 @@ +module StubGitlabData + def gitlab_ci_yaml + File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) + end +end -- cgit v1.2.1 From 10b3c85e2c7c3e794a0c79d33b1a7bc2b1b6b7c8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 10 Sep 2015 15:47:15 +0200 Subject: Fix some issues with ci models specs --- spec/support/setup_builds_storage.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/support') diff --git a/spec/support/setup_builds_storage.rb b/spec/support/setup_builds_storage.rb index cafc8dee918..1f3b12bb8d2 100644 --- a/spec/support/setup_builds_storage.rb +++ b/spec/support/setup_builds_storage.rb @@ -5,7 +5,7 @@ RSpec.configure do |config| config.before(:each) do FileUtils.mkdir_p(builds_path) - Ci::Settings.gitlab_ci['builds_path'] = builds_path + Settings.gitlab_ci['builds_path'] = builds_path end config.after(:suite) do -- cgit v1.2.1 From 9d93c567b39bc4f3e6737f1db5b1c6c2b1d59654 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 10 Sep 2015 16:04:06 +0200 Subject: Fix part of CI api tests --- spec/support/stub_gitlab_calls.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/support') diff --git a/spec/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb index 931ef963c0f..51425e3095c 100644 --- a/spec/support/stub_gitlab_calls.rb +++ b/spec/support/stub_gitlab_calls.rb @@ -16,7 +16,7 @@ module StubGitlabCalls private def gitlab_url - GitlabCi.config.gitlab_server.url + Gitlab.config.gitlab.url end def stub_session @@ -52,7 +52,7 @@ module StubGitlabCalls def stub_projects f = File.read(Rails.root.join('spec/support/gitlab_stubs/projects.json')) - + stub_request(:get, "#{gitlab_url}api/v3/projects.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz"). with(:headers => {'Content-Type'=>'application/json'}). to_return(:status => 200, :body => f, :headers => {'Content-Type'=>'application/json'}) -- cgit v1.2.1 From 4e7b47dde1077690cc90b7c8779158af0f175c9a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 10 Sep 2015 16:55:09 +0200 Subject: Convert ci features specs to v3 --- spec/support/stub_gitlab_calls.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spec/support') diff --git a/spec/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb index 51425e3095c..fadc3df412b 100644 --- a/spec/support/stub_gitlab_calls.rb +++ b/spec/support/stub_gitlab_calls.rb @@ -10,7 +10,7 @@ module StubGitlabCalls end def stub_js_gitlab_calls - Network.any_instance.stub(:projects) { project_hash_array } + allow_any_instance_of(Network).to receive(:projects) { project_hash_array } end private @@ -42,12 +42,12 @@ module StubGitlabCalls def stub_project_8 data = File.read(Rails.root.join('spec/support/gitlab_stubs/project_8.json')) - Network.any_instance.stub(:project).and_return(JSON.parse(data)) + allow_any_instance_of(Network).to receive(:project).and_return(JSON.parse(data)) end def stub_project_8_hooks data = File.read(Rails.root.join('spec/support/gitlab_stubs/project_8_hooks.json')) - Network.any_instance.stub(:project_hooks).and_return(JSON.parse(data)) + allow_any_instance_of(Network).to receive(:project_hooks).and_return(JSON.parse(data)) end def stub_projects -- cgit v1.2.1 From 4c53cc0ebac36560d806732ff1fefba9206c75f3 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Mon, 14 Sep 2015 14:37:18 +0300 Subject: rubocop satisfy --- spec/support/stub_gitlab_calls.rb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'spec/support') diff --git a/spec/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb index fadc3df412b..41e4c3e275b 100644 --- a/spec/support/stub_gitlab_calls.rb +++ b/spec/support/stub_gitlab_calls.rb @@ -23,21 +23,21 @@ module StubGitlabCalls f = File.read(Rails.root.join('spec/support/gitlab_stubs/session.json')) stub_request(:post, "#{gitlab_url}api/v3/session.json"). - with(:body => "{\"email\":\"test@test.com\",\"password\":\"123456\"}", - :headers => {'Content-Type'=>'application/json'}). - to_return(:status => 201, :body => f, :headers => {'Content-Type'=>'application/json'}) + with(body: "{\"email\":\"test@test.com\",\"password\":\"123456\"}", + headers: {'Content-Type'=>'application/json'}). + to_return(status: 201, body: f, headers: {'Content-Type'=>'application/json'}) end def stub_user f = File.read(Rails.root.join('spec/support/gitlab_stubs/user.json')) stub_request(:get, "#{gitlab_url}api/v3/user?private_token=Wvjy2Krpb7y8xi93owUz"). - with(:headers => {'Content-Type'=>'application/json'}). - to_return(:status => 200, :body => f, :headers => {'Content-Type'=>'application/json'}) + with(headers: {'Content-Type'=>'application/json'}). + to_return(status: 200, body: f, headers: {'Content-Type'=>'application/json'}) stub_request(:get, "#{gitlab_url}api/v3/user?access_token=some_token"). - with(:headers => {'Content-Type'=>'application/json'}). - to_return(:status => 200, :body => f, :headers => {'Content-Type'=>'application/json'}) + with(headers: {'Content-Type'=>'application/json'}). + to_return(status: 200, body: f, headers: {'Content-Type'=>'application/json'}) end def stub_project_8 @@ -54,24 +54,24 @@ module StubGitlabCalls f = File.read(Rails.root.join('spec/support/gitlab_stubs/projects.json')) stub_request(:get, "#{gitlab_url}api/v3/projects.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz"). - with(:headers => {'Content-Type'=>'application/json'}). - to_return(:status => 200, :body => f, :headers => {'Content-Type'=>'application/json'}) + with(headers: {'Content-Type'=>'application/json'}). + to_return(status: 200, body: f, headers: {'Content-Type'=>'application/json'}) end def stub_projects_owned stub_request(:get, "#{gitlab_url}api/v3/projects/owned.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz"). - with(:headers => {'Content-Type'=>'application/json'}). - to_return(:status => 200, :body => "", :headers => {}) + with(headers: {'Content-Type'=>'application/json'}). + to_return(status: 200, body: "", headers: {}) end def stub_ci_enable stub_request(:put, "#{gitlab_url}api/v3/projects/2/services/gitlab-ci.json?private_token=Wvjy2Krpb7y8xi93owUz"). - with(:headers => {'Content-Type'=>'application/json'}). - to_return(:status => 200, :body => "", :headers => {}) + with(headers: {'Content-Type'=>'application/json'}). + to_return(status: 200, body: "", headers: {}) end def project_hash_array f = File.read(Rails.root.join('spec/support/gitlab_stubs/projects.json')) - return JSON.parse f + JSON.parse f end end -- cgit v1.2.1 From 910bf96ec3d60194b2fe4444c1df24f141b8450b Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Mon, 14 Sep 2015 18:14:17 +0300 Subject: fix specs. Stage 2 --- spec/support/api_helpers.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'spec/support') diff --git a/spec/support/api_helpers.rb b/spec/support/api_helpers.rb index f63322776d4..1b3cafb497c 100644 --- a/spec/support/api_helpers.rb +++ b/spec/support/api_helpers.rb @@ -28,6 +28,17 @@ module ApiHelpers "&private_token=#{user.private_token}" : "") end + def ci_api(path, user = nil) + "/ci/api/v1/#{path}" + + + # Normalize query string + (path.index('?') ? '' : '?') + + + # Append private_token if given a User object + (user.respond_to?(:private_token) ? + "&private_token=#{user.private_token}" : "") + end + def json_response @_json_response ||= JSON.parse(response.body) end -- cgit v1.2.1 From e2cbb36ba9751021174fd188d1c29e736f7b5d3d Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Tue, 15 Sep 2015 15:51:03 +0300 Subject: fix specs. Stage 5 --- spec/support/stub_gitlab_calls.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'spec/support') diff --git a/spec/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb index 41e4c3e275b..5e6744afda1 100644 --- a/spec/support/stub_gitlab_calls.rb +++ b/spec/support/stub_gitlab_calls.rb @@ -24,20 +24,20 @@ module StubGitlabCalls stub_request(:post, "#{gitlab_url}api/v3/session.json"). with(body: "{\"email\":\"test@test.com\",\"password\":\"123456\"}", - headers: {'Content-Type'=>'application/json'}). - to_return(status: 201, body: f, headers: {'Content-Type'=>'application/json'}) + headers: { 'Content-Type'=>'application/json' }). + to_return(status: 201, body: f, headers: { 'Content-Type'=>'application/json' }) end def stub_user f = File.read(Rails.root.join('spec/support/gitlab_stubs/user.json')) stub_request(:get, "#{gitlab_url}api/v3/user?private_token=Wvjy2Krpb7y8xi93owUz"). - with(headers: {'Content-Type'=>'application/json'}). - to_return(status: 200, body: f, headers: {'Content-Type'=>'application/json'}) + with(headers: { 'Content-Type'=>'application/json' }). + to_return(status: 200, body: f, headers: { 'Content-Type'=>'application/json' }) stub_request(:get, "#{gitlab_url}api/v3/user?access_token=some_token"). - with(headers: {'Content-Type'=>'application/json'}). - to_return(status: 200, body: f, headers: {'Content-Type'=>'application/json'}) + with(headers: { 'Content-Type'=>'application/json' }). + to_return(status: 200, body: f, headers: { 'Content-Type'=>'application/json' }) end def stub_project_8 @@ -54,19 +54,19 @@ module StubGitlabCalls f = File.read(Rails.root.join('spec/support/gitlab_stubs/projects.json')) stub_request(:get, "#{gitlab_url}api/v3/projects.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz"). - with(headers: {'Content-Type'=>'application/json'}). - to_return(status: 200, body: f, headers: {'Content-Type'=>'application/json'}) + with(headers: { 'Content-Type'=>'application/json' }). + to_return(status: 200, body: f, headers: { 'Content-Type'=>'application/json' }) end def stub_projects_owned stub_request(:get, "#{gitlab_url}api/v3/projects/owned.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz"). - with(headers: {'Content-Type'=>'application/json'}). + with(headers: { 'Content-Type'=>'application/json' }). to_return(status: 200, body: "", headers: {}) end def stub_ci_enable stub_request(:put, "#{gitlab_url}api/v3/projects/2/services/gitlab-ci.json?private_token=Wvjy2Krpb7y8xi93owUz"). - with(headers: {'Content-Type'=>'application/json'}). + with(headers: { 'Content-Type'=>'application/json' }). to_return(status: 200, body: "", headers: {}) end -- cgit v1.2.1 From b87ca7500f174cc9a4e90b262b02aa9bf695fbee Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Tue, 15 Sep 2015 16:42:02 +0300 Subject: fix specs. Stage 7 --- spec/support/login_helpers.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'spec/support') diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index ffe30a4246c..cd9fdc6f18e 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -44,4 +44,8 @@ module LoginHelpers def logout_direct page.driver.submit :delete, '/users/sign_out', {} end + + def skip_ci_admin_auth + allow_any_instance_of(Ci::Admin::ApplicationController).to receive_messages(authenticate_admin!: true) + end end -- cgit v1.2.1 From 8d5c9935ffb8fa41f831742ac287fd010a006b42 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 15 Sep 2015 22:00:17 +0200 Subject: Fix: models/ci/project_spec.rb --- spec/support/gitlab_stubs/raw_project.yml | 36 ------------------------------- 1 file changed, 36 deletions(-) delete mode 100644 spec/support/gitlab_stubs/raw_project.yml (limited to 'spec/support') diff --git a/spec/support/gitlab_stubs/raw_project.yml b/spec/support/gitlab_stubs/raw_project.yml deleted file mode 100644 index df2ce223d1f..00000000000 --- a/spec/support/gitlab_stubs/raw_project.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- !ruby/object:OpenStruct -table: - :id: 189 - :description: Website at http://api.gitlab.org/ - :default_branch: master - :public: false - :visibility_level: 0 - :ssh_url_to_repo: dzaporozhets@localhost:gitlab/api-gitlab-org.git - :http_url_to_repo: http://localhost:3000/gitlab/api-gitlab-org.git - :web_url: http://localhost:3000/gitlab/api-gitlab-org - :owner: - id: 1 - name: GitLab - created_at: '2012-10-03T09:59:57.000Z' - :name: api.gitlab.org - :name_with_namespace: GitLab / api.gitlab.org - :path: api-gitlab-org - :path_with_namespace: gitlab/api-gitlab-org - :issues_enabled: true - :merge_requests_enabled: true - :wall_enabled: false - :wiki_enabled: false - :snippets_enabled: false - :created_at: '2013-06-06T12:29:39.000Z' - :last_activity_at: '2013-12-06T20:29:42.000Z' - :namespace: - id: 1 - name: GitLab - path: gitlab - owner_id: 1 - created_at: '2012-10-03T09:59:57.000Z' - updated_at: '2014-01-28T08:49:53.000Z' - description: Self hosted Git management software - avatar: - url: /uploads/group/avatar/1/0-vader-profile.jpg - -- cgit v1.2.1 From 2f2b9f67c21a504826595079e103f1ea9ac813f2 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 16 Sep 2015 00:00:08 +0200 Subject: Fix backup tests --- spec/support/setup_builds_storage.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'spec/support') diff --git a/spec/support/setup_builds_storage.rb b/spec/support/setup_builds_storage.rb index 1f3b12bb8d2..a3e59646187 100644 --- a/spec/support/setup_builds_storage.rb +++ b/spec/support/setup_builds_storage.rb @@ -1,10 +1,11 @@ RSpec.configure do |config| def builds_path - Rails.root.join('tmp/builds_test') + Rails.root.join('tmp/builds') end config.before(:each) do FileUtils.mkdir_p(builds_path) + FileUtils.touch(File.join(builds_path, ".gitkeep")) Settings.gitlab_ci['builds_path'] = builds_path end -- cgit v1.2.1 From ee028d9d60522f8993a0b2429ac8a0631d59229a Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 21 Sep 2015 09:46:47 +0200 Subject: Rename reply_by_email to incoming_email to prepare for the future. --- spec/support/stub_configuration.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/support') diff --git a/spec/support/stub_configuration.rb b/spec/support/stub_configuration.rb index ef3a120d44a..f40ee862df8 100644 --- a/spec/support/stub_configuration.rb +++ b/spec/support/stub_configuration.rb @@ -17,8 +17,8 @@ module StubConfiguration allow(Gitlab.config.gravatar).to receive_messages(messages) end - def stub_reply_by_email_setting(messages) - allow(Gitlab.config.reply_by_email).to receive_messages(messages) + def stub_incoming_email_setting(messages) + allow(Gitlab.config.incoming_email).to receive_messages(messages) end private -- cgit v1.2.1 From dbc05d4a62468a8b7ebbeb17da4f74edaa09f968 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Fri, 2 Oct 2015 16:25:47 +0200 Subject: Don't use "rm" for cleaning tmp/builds If this directory were to be empty this would result in warnings being printed to STDERR, cluttering spec output. Doing this in Ruby fixes this problem (and also removes the need for shell alltogether). --- spec/support/setup_builds_storage.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'spec/support') diff --git a/spec/support/setup_builds_storage.rb b/spec/support/setup_builds_storage.rb index a3e59646187..a4f21e95338 100644 --- a/spec/support/setup_builds_storage.rb +++ b/spec/support/setup_builds_storage.rb @@ -10,8 +10,10 @@ RSpec.configure do |config| end config.after(:suite) do - Dir.chdir(builds_path) do - `ls | grep -v .gitkeep | xargs rm -r` + Dir[File.join(builds_path, '*')].each do |path| + next if File.basename(path) == '.gitkeep' + + FileUtils.rm_rf(path) end end end -- cgit v1.2.1 From 19893a1c10e4e6dfbdb56ad78de1599b6c8f6981 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Fri, 2 Oct 2015 17:00:23 +0200 Subject: Basic setup for an RSpec based benchmark suite This benchmark suite uses benchmark-ips (https://github.com/evanphx/benchmark-ips) behind the scenes. Specs can be turned into benchmark specs by setting "benchmark" to "true" in the top-level describe block like so: describe SomeClass, benchmark: true do end Writing benchmarks can be done using custom RSpec matchers, for example: describe MaruTheCat, benchmark: true do describe '#jump_in_box' do it 'should run 1000 iterations per second' do maru = described_class.new expect { maru.jump_in_box }.to iterate_per_second(1000) end end end By default the "iterate_per_second" expectation requires a standard deviation under 30% (this is just an arbitrary default for now). You can change this by chaining "with_maximum_stddev" on the expectation: expect { maru.jump_in_box }.to iterate_per_second(1000) .with_maximum_stddev(10) This will change the expectation to require a maximum deviation of 10%. Alternatively you can use the it block style to write specs: describe MaruTheCat, benchmark: true do describe '#jump_in_box' do subject { -> { described_class.new } } it { is_expected.to iterate_per_second(1000) } end end Because "iterate_per_second" operates on a block, opposed to a static value, the "subject" method must return a Proc. This looks a bit goofy but I have been unable to find a nice way around this. --- spec/support/matchers/benchmark_matchers.rb | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 spec/support/matchers/benchmark_matchers.rb (limited to 'spec/support') diff --git a/spec/support/matchers/benchmark_matchers.rb b/spec/support/matchers/benchmark_matchers.rb new file mode 100644 index 00000000000..45a1d49345f --- /dev/null +++ b/spec/support/matchers/benchmark_matchers.rb @@ -0,0 +1,42 @@ +module BenchmarkMatchers + extend RSpec::Matchers::DSL + + matcher :iterate_per_second do |min_iterations| + supports_block_expectations + + match do |block| + @max_stddev ||= 30 + + @entry = benchmark(&block) + + expect(@entry.ips).to be >= min_iterations + expect(@entry.stddev_percentage).to be <= @max_stddev + end + + chain :with_maximum_stddev do |value| + @max_stddev = value + end + + description do + "run at least #{min_iterations} iterations per second" + end + + failure_message do + ips = @entry.ips.round(2) + stddev = @entry.stddev_percentage.round(2) + + "expected at least #{min_iterations} iterations per second " \ + "with a maximum stddev of #{@max_stddev}%, instead of " \ + "#{ips} iterations per second with a stddev of #{stddev}%" + end + end + + # Benchmarks the given block and returns a Benchmark::IPS::Report::Entry. + def benchmark(&block) + report = Benchmark.ips(quiet: true) do |bench| + bench.report(&block) + end + + report.entries[0] + end +end -- cgit v1.2.1 From 22506ddc50146ab56b2f114d90ab7b3270d60de1 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 5 Oct 2015 10:51:24 +0200 Subject: Added benchmark_subject method for benchmarks This class method can be used in "describe" blocks to specify the subject of a benchmark. This lets you write: benchmark_subject { Foo } instead of: benchmark_subject { -> { Foo } } --- spec/support/matchers/benchmark_matchers.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'spec/support') diff --git a/spec/support/matchers/benchmark_matchers.rb b/spec/support/matchers/benchmark_matchers.rb index 45a1d49345f..b73a53917f0 100644 --- a/spec/support/matchers/benchmark_matchers.rb +++ b/spec/support/matchers/benchmark_matchers.rb @@ -1,6 +1,10 @@ module BenchmarkMatchers extend RSpec::Matchers::DSL + def self.included(into) + into.extend(ClassMethods) + end + matcher :iterate_per_second do |min_iterations| supports_block_expectations @@ -39,4 +43,17 @@ module BenchmarkMatchers report.entries[0] end + + module ClassMethods + # Wraps around rspec's subject method so you can write: + # + # benchmark_subject { SomeClass.some_method } + # + # instead of: + # + # subject { -> { SomeClass.some_method } } + def benchmark_subject(&block) + subject { block } + end + end end -- cgit v1.2.1 From d2d2df0738f3cd8311963c34d90ebc8ce4081aa6 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 5 Oct 2015 13:12:00 +0200 Subject: Fix next round of tests --- spec/support/stub_gitlab_calls.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'spec/support') diff --git a/spec/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb index 5e6744afda1..5b3eb1bfc5f 100644 --- a/spec/support/stub_gitlab_calls.rb +++ b/spec/support/stub_gitlab_calls.rb @@ -13,6 +13,14 @@ module StubGitlabCalls allow_any_instance_of(Network).to receive(:projects) { project_hash_array } end + def stub_ci_commit_to_return_yaml_file + stub_ci_commit_yaml_file(gitlab_ci_yaml) + end + + def stub_ci_commit_yaml_file(ci_yaml) + allow_any_instance_of(Ci::Commit).to receive(:ci_yaml_file) { ci_yaml } + end + private def gitlab_url -- cgit v1.2.1 From 2fa4e2fb6a669b98ed6abc568eabc8f5f9f28e8a Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 5 Oct 2015 16:26:37 +0200 Subject: Evaluate benchmark blocks in the proper context This ensures that blocks defines using "benchmark_subject" have access to methods defined using let/subject & friends. --- spec/support/matchers/benchmark_matchers.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'spec/support') diff --git a/spec/support/matchers/benchmark_matchers.rb b/spec/support/matchers/benchmark_matchers.rb index b73a53917f0..84f655c2119 100644 --- a/spec/support/matchers/benchmark_matchers.rb +++ b/spec/support/matchers/benchmark_matchers.rb @@ -38,7 +38,9 @@ module BenchmarkMatchers # Benchmarks the given block and returns a Benchmark::IPS::Report::Entry. def benchmark(&block) report = Benchmark.ips(quiet: true) do |bench| - bench.report(&block) + bench.report do + instance_eval(&block) + end end report.entries[0] -- cgit v1.2.1