Sha256: 4d9543c3fc0fe417ca6f6b39af2eb35bddad54e641365f2f64d45c4e2b4b60c7

Contents?: true

Size: 738 Bytes

Versions: 1

Compression:

Stored size: 738 Bytes

Contents

require 'sinatra/base'

class FakeJenkins < Sinatra::Base
  get '/job/:job/:build_number/api/json' do
    json_response 200, "#{underscore(params['job'])}.json"
  end

  get '/job/:job/:build_number/logText/progressiveHtml' do
    content_type :html
    [200, 'console output']
  end

  private

  def underscore(camel_cased_word)
    camel_cased_word.to_s.gsub(/::/, '/')
                    .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
                    .gsub(/([a-z\d])([A-Z])/, '\1_\2')
                    .tr('-', '_')
                    .downcase
  end

  def json_response(response_code, file_name)
    content_type :json
    status response_code
    File.open(File.dirname(__FILE__) + '/fixtures/' + file_name, 'rb').read
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-jenkins-0.0.1 spec/support/fake_jenkins.rb