diff options
author | Jeroen van Baarsen <jeroenvanbaarsen@gmail.com> | 2015-02-12 19:17:35 +0100 |
---|---|---|
committer | Jeroen van Baarsen <jeroenvanbaarsen@gmail.com> | 2015-02-12 19:17:35 +0100 |
commit | 0c4a70a306b871899bf87ce4673918abfee4d95f (patch) | |
tree | c7a702fb511209ffe0eceba245d1ffea71dce1aa /spec/models/hooks | |
parent | de1c450abd6b367390a1295cac402344f500d41d (diff) | |
download | gitlab-ce-0c4a70a306b871899bf87ce4673918abfee4d95f.tar.gz |
Updated rspec to rspec 3.x syntax
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
Diffstat (limited to 'spec/models/hooks')
-rw-r--r-- | spec/models/hooks/service_hook_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/hooks/system_hook_spec.rb | 20 | ||||
-rw-r--r-- | spec/models/hooks/web_hook_spec.rb | 30 |
3 files changed, 26 insertions, 26 deletions
diff --git a/spec/models/hooks/service_hook_spec.rb b/spec/models/hooks/service_hook_spec.rb index 6ec82438dfe..96bf74d45da 100644 --- a/spec/models/hooks/service_hook_spec.rb +++ b/spec/models/hooks/service_hook_spec.rb @@ -19,6 +19,6 @@ require "spec_helper" describe ServiceHook do describe "Associations" do - it { should belong_to :service } + it { is_expected.to belong_to :service } end end diff --git a/spec/models/hooks/system_hook_spec.rb b/spec/models/hooks/system_hook_spec.rb index 8deb732de9c..810b311a40b 100644 --- a/spec/models/hooks/system_hook_spec.rb +++ b/spec/models/hooks/system_hook_spec.rb @@ -26,32 +26,32 @@ describe SystemHook do it "project_create hook" do Projects::CreateService.new(create(:user), name: 'empty').execute - WebMock.should have_requested(:post, @system_hook.url).with(body: /project_create/).once + expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /project_create/).once end it "project_destroy hook" do user = create(:user) project = create(:empty_project, namespace: user.namespace) Projects::DestroyService.new(project, user, {}).execute - WebMock.should have_requested(:post, @system_hook.url).with(body: /project_destroy/).once + expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /project_destroy/).once end it "user_create hook" do create(:user) - WebMock.should have_requested(:post, @system_hook.url).with(body: /user_create/).once + expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /user_create/).once end it "user_destroy hook" do user = create(:user) user.destroy - WebMock.should have_requested(:post, @system_hook.url).with(body: /user_destroy/).once + expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /user_destroy/).once end it "project_create hook" do user = create(:user) project = create(:project) project.team << [user, :master] - WebMock.should have_requested(:post, @system_hook.url).with(body: /user_add_to_team/).once + expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /user_add_to_team/).once end it "project_destroy hook" do @@ -59,12 +59,12 @@ describe SystemHook do project = create(:project) project.team << [user, :master] project.project_members.destroy_all - WebMock.should have_requested(:post, @system_hook.url).with(body: /user_remove_from_team/).once + expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /user_remove_from_team/).once end it 'group create hook' do create(:group) - WebMock.should have_requested(:post, @system_hook.url).with( + expect(WebMock).to have_requested(:post, @system_hook.url).with( body: /group_create/ ).once end @@ -72,7 +72,7 @@ describe SystemHook do it 'group destroy hook' do group = create(:group) group.destroy - WebMock.should have_requested(:post, @system_hook.url).with( + expect(WebMock).to have_requested(:post, @system_hook.url).with( body: /group_destroy/ ).once end @@ -81,7 +81,7 @@ describe SystemHook do group = create(:group) user = create(:user) group.add_user(user, Gitlab::Access::MASTER) - WebMock.should have_requested(:post, @system_hook.url).with( + expect(WebMock).to have_requested(:post, @system_hook.url).with( body: /user_add_to_group/ ).once end @@ -91,7 +91,7 @@ describe SystemHook do user = create(:user) group.add_user(user, Gitlab::Access::MASTER) group.group_members.destroy_all - WebMock.should have_requested(:post, @system_hook.url).with( + expect(WebMock).to have_requested(:post, @system_hook.url).with( body: /user_remove_from_group/ ).once end diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb index e9c04ee89cb..67ec9193ad7 100644 --- a/spec/models/hooks/web_hook_spec.rb +++ b/spec/models/hooks/web_hook_spec.rb @@ -19,25 +19,25 @@ require 'spec_helper' describe ProjectHook do describe "Associations" do - it { should belong_to :project } + it { is_expected.to belong_to :project } end describe "Mass assignment" do end describe "Validations" do - it { should validate_presence_of(:url) } + it { is_expected.to validate_presence_of(:url) } context "url format" do - it { should allow_value("http://example.com").for(:url) } - it { should allow_value("https://excample.com").for(:url) } - it { should allow_value("http://test.com/api").for(:url) } - it { should allow_value("http://test.com/api?key=abc").for(:url) } - it { should allow_value("http://test.com/api?key=abc&type=def").for(:url) } + it { is_expected.to allow_value("http://example.com").for(:url) } + it { is_expected.to allow_value("https://excample.com").for(:url) } + it { is_expected.to allow_value("http://test.com/api").for(:url) } + it { is_expected.to allow_value("http://test.com/api?key=abc").for(:url) } + it { is_expected.to allow_value("http://test.com/api?key=abc&type=def").for(:url) } - it { should_not allow_value("example.com").for(:url) } - it { should_not allow_value("ftp://example.com").for(:url) } - it { should_not allow_value("herp-and-derp").for(:url) } + it { is_expected.not_to allow_value("example.com").for(:url) } + it { is_expected.not_to allow_value("ftp://example.com").for(:url) } + it { is_expected.not_to allow_value("herp-and-derp").for(:url) } end end @@ -53,22 +53,22 @@ describe ProjectHook do it "POSTs to the web hook URL" do @project_hook.execute(@data) - WebMock.should have_requested(:post, @project_hook.url).once + expect(WebMock).to have_requested(:post, @project_hook.url).once end it "POSTs the data as JSON" do json = @data.to_json @project_hook.execute(@data) - WebMock.should have_requested(:post, @project_hook.url).with(body: json).once + expect(WebMock).to have_requested(:post, @project_hook.url).with(body: json).once end it "catches exceptions" do - WebHook.should_receive(:post).and_raise("Some HTTP Post error") + expect(WebHook).to receive(:post).and_raise("Some HTTP Post error") - lambda { + expect { @project_hook.execute(@data) - }.should raise_error + }.to raise_error end end end |