Commit cf0eab50 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add feature tests for builds status badge

parent eb7721e1
Feature: Project Builds Badge
Background:
Given project exists in some group namespace
And project has CI enabled
And project has a recent build
Scenario: I want to see a badge for successfully built project
Given recent build is successfull
When I display builds badge for a master branch
Then I should see a build success badge
And build badge is a svg image
Scenario: I want to see a badge for project with filed builds
Given recent build failed
When I display builds badge for a master branch
Then I should see a build failed badge
And build badge is a svg image
class Spinach::Features::ProjectBuildsBadge < Spinach::FeatureSteps
include SharedProject
include SharedBuilds
include RepoHelpers
step 'I display builds badge for a master branch' do
visit badge_namespace_project_builds_path(@project.namespace, @project, ref: :master, format: :svg)
end
step 'I should see a build success badge' do
expect(svg.at('text:contains("success")')).to be_truthy
end
step 'I should see a build failed badge' do
expect(svg.at('text:contains("failed")')).to be_truthy
end
step 'build badge is a svg image' do
expect(page.response_headers).to include('Content-Type' => 'image/svg+xml')
end
def svg
Nokogiri::HTML.parse(page.body)
end
end
...@@ -6,8 +6,16 @@ module SharedBuilds ...@@ -6,8 +6,16 @@ module SharedBuilds
end end
step 'project has a recent build' do step 'project has a recent build' do
ci_commit = create :ci_commit, project: @project, sha: sample_commit.id @ci_commit = create(:ci_commit, project: @project, sha: @project.commit.sha)
@build = create :ci_build, commit: ci_commit @build = create(:ci_build, commit: @ci_commit)
end
step 'recent build is successfull' do
@build.update_column(:status, 'success')
end
step 'recent build failed' do
@build.update_column(:status, 'failed')
end end
step 'I visit recent build details page' do step 'I visit recent build details page' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment