BigW Consortium Gitlab

build.rb 942 Bytes
Newer Older
1
class Spinach::Features::ProjectBadgesBuild < Spinach::FeatureSteps
2
  include SharedAuthentication
3 4 5 6 7
  include SharedProject
  include SharedBuilds
  include RepoHelpers

  step 'I display builds badge for a master branch' do
8
    visit build_namespace_project_badges_path(@project.namespace, @project, ref: :master, format: :svg)
9 10 11
  end

  step 'I should see a build success badge' do
12
    expect_badge('success')
13 14 15
  end

  step 'I should see a build failed badge' do
16
    expect_badge('failed')
17 18
  end

19 20
  step 'I should see a build running badge' do
    expect_badge('running')
21 22
  end

23 24 25 26
  step 'I should see a badge that has not been cached' do
    expect(page.response_headers).to include('Cache-Control' => 'no-cache')
  end

27
  def expect_badge(status)
28
    svg = Nokogiri::XML.parse(page.body)
29 30 31
    expect(page.response_headers).to include('Content-Type' => 'image/svg+xml')
    expect(svg.at(%Q{text:contains("#{status}")})).to be_truthy
  end
32
end