ruby-fogbugz 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZTNkNWU5YzM0YTQyYWU5MDFmYTE0MjU3MzI1NmExNTU1YzVkMzgxZA==
5
- data.tar.gz: !binary |-
6
- MmU5NGZjNDcyNmY2N2U3NjEwMGFlYjhlZTkxNDM0ZDFiOThhNzRlNg==
2
+ SHA1:
3
+ metadata.gz: 352b6a67807235b44b144aced01c080032de2214
4
+ data.tar.gz: 6261c2949588dba54e55ad1a7aee9d3818a63fe4
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MDk3MmY3OGRlNTA2NDliNDVjYzIzMDI5MzQ0NTg3NzNkMDRhMTFkNGM4NWFl
10
- ZDg2NjBmM2RhM2UwZDMzYzU4ZmM4MDc0NjYxMWMwZGE3OTU3Nzg0ZjMyZDcy
11
- ZWYwOWZiNTUzMWJkMzA3ZjJhNDhkY2JkOTMzYzIyZjFlNGM5MDg=
12
- data.tar.gz: !binary |-
13
- Mjc2OTEzZTg4MGYwMzg4YTg3NDk3YmNlOGUwOGEzZjNmNDc5NWNmM2M0Mjgy
14
- ZWVkODMzNGRhMDBhZDFiNDY3M2VjY2NiY2UwZGVmZWZiMmNiYTJiODZhOWM1
15
- NGFjMjIyZGMwNTdkZjI4YjMwNmE4YTM5NzlmNDBmNDE1M2ZlNTQ=
6
+ metadata.gz: 3ae11a0493259f3a499142ebf932a2467e1dbe38f3d300dce9373f2c8f73db0b1fbed110f8894eb0961da035370eb1137284e82c747d82f6cc80b3931fa1e8af
7
+ data.tar.gz: 16887e6937561c60f533f06901c5036455bd62b8645dbfc5108cd6af9c66d0a204a157f92aca537622fa9a780d008060ad1fcc42f1aca5a41e6fe9ba4d3a26c5
@@ -0,0 +1,9 @@
1
+ engines:
2
+ rubocop:
3
+ enabled: true
4
+ fixme:
5
+ enabled: true
6
+ ratings:
7
+ paths:
8
+ - "lib/**"
9
+ - "**.rb"
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ spec/examples.txt
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,11 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+
4
+ Style/SignalException:
5
+ Enabled: false
6
+
7
+ Metrics/LineLength:
8
+ Enabled: false
9
+
10
+ Metrics/MethodLength:
11
+ Enabled: false
@@ -1,11 +1,15 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0-p647
4
- - 2.1.7
5
- - 2.2.3
3
+ - 2.0.0-p648
4
+ - 2.1.10
5
+ - 2.2.6
6
+ - 2.3.3
6
7
  - jruby-9.0.0.0
7
8
  sudo: false
8
9
 
10
+ after_success:
11
+ - bundle exec codeclimate-test-reporter
12
+
9
13
  addons:
10
14
  code_climate:
11
15
  repo_token: ef52b4659b14e65b70be219cf870eaffcef8ee9c260b767b26694e2c7f59e88c
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in ruby-fogbugz.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -1,6 +1,14 @@
1
- [![Build Status](https://travis-ci.org/firmafon/ruby-fogbugz.svg)](https://travis-ci.org/firmafon/ruby-fogbugz)
2
- [![Code Climate](https://codeclimate.com/github/firmafon/ruby-fogbugz/badges/gpa.svg)](https://codeclimate.com/github/firmafon/ruby-fogbugz)
3
- [![Test Coverage](https://codeclimate.com/github/firmafon/ruby-fogbugz/badges/coverage.svg)](https://codeclimate.com/github/firmafon/ruby-fogbugz/coverage)
1
+ [![Gem Version](https://img.shields.io/gem/v/ruby-fogbugz.svg)][gem]
2
+ [![Build Status](https://img.shields.io/travis/firmafon/ruby-fogbugz.svg)][travis]
3
+ [![Dependency Status](https://img.shields.io/gemnasium/firmafon/ruby-fogbugz.svg)][gemnasium]
4
+ [![Code Climate](https://img.shields.io/codeclimate/github/firmafon/ruby-fogbugz.svg)][codeclimate]
5
+ [![Test Coverage](https://img.shields.io/codeclimate/coverage/github/firmafon/ruby-fogbugz.svg)][coverage]
6
+
7
+ [gem]: https://rubygems.org/gems/ruby-fogbugz
8
+ [travis]: https://travis-ci.org/firmafon/ruby-fogbugz
9
+ [gemnasium]: https://gemnasium.com/firmafon/ruby-fogbugz
10
+ [codeclimate]: https://codeclimate.com/github/firmafon/ruby-fogbugz
11
+ [coverage]: https://codeclimate.com/github/firmafon/ruby-fogbugz/coverage
4
12
 
5
13
  # ruby-fogbugz
6
14
 
@@ -84,7 +92,16 @@ Run the script, and initialize with the returned token:
84
92
  fogbugz = Fogbugz::Interface.new(:token => "some token to use from now on", :uri => 'https://company.fogbugz.com') # remember to use https!
85
93
  ```
86
94
 
95
+ ### Attachments
96
+
97
+ This library supports multipart file uploads to include attachments in your API request. A multipart request body is created (using the [multipart-post][mpp] gem) if `File1` is found in the command parameters. Files can be attached as follows:
98
+
99
+ ```ruby
100
+ fogbugz.command(:new, sProject: "SomeProject", sArea: "someArea", sTitle: "Case title", File1: UploadIO.new(f, "text/plain", "someFile.rb"))
101
+ ```
102
+
87
103
  [fad]:http://fogbugz.stackexchange.com/fogbugz-xml-api
104
+ [mpp]:https://github.com/nicksieger/multipart-post
88
105
 
89
106
  ## License
90
107
 
data/Rakefile CHANGED
@@ -1,11 +1,7 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
- require 'rake/testtask'
5
- Rake::TestTask.new do |t|
6
- t.libs << "lib"
7
- t.libs << "test"
8
- t.pattern = "test/**/*_test.rb"
9
- end
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
10
6
 
11
- task :default => [:test]
7
+ task default: [:spec]
@@ -8,7 +8,7 @@ module Fogbugz
8
8
  end
9
9
 
10
10
  self.adapter = {
11
- :xml => Adapter::XML::Cracker,
12
- :http => Adapter::HTTP::NetHttp
11
+ xml: Adapter::XML::Cracker,
12
+ http: Adapter::HTTP::NetHttp
13
13
  }
14
14
  end
@@ -1,5 +1,6 @@
1
1
  require 'cgi'
2
2
  require 'net/https'
3
+ require 'net/http/post/multipart'
3
4
 
4
5
  module Fogbugz
5
6
  module Adapter
@@ -9,24 +10,32 @@ module Fogbugz
9
10
 
10
11
  def initialize(options = {})
11
12
  @root_url = options[:uri]
13
+ @ca_file = options[:ca_file]
14
+ end
15
+
16
+ def build_request(uri, params)
17
+ return Net::HTTP::Post::Multipart.new(uri.request_uri, params) if params.key? :File1
18
+
19
+ request = Net::HTTP::Post.new(uri.request_uri)
20
+ request.set_form_data(params)
21
+ request
12
22
  end
13
23
 
14
24
  def request(action, options)
15
25
  uri = URI("#{@root_url}/api.asp")
16
26
 
17
- params = {
18
- 'cmd' => action
19
- }
27
+ params = { 'cmd' => action }
20
28
  params.merge!(options[:params])
21
29
 
22
- # build up the form request
23
- request = Net::HTTP::Post.new(uri.request_uri)
24
- request.set_form_data(params)
30
+ request = build_request(uri, params)
25
31
 
26
32
  http = Net::HTTP.new(uri.host, uri.port)
27
- http.use_ssl = @root_url.start_with? 'https'
28
-
29
- response = http.start {|http| http.request(request) }
33
+ if @root_url.start_with? 'https'
34
+ http.use_ssl = true
35
+ http.ca_file = @ca_file
36
+ end
37
+
38
+ response = http.start { |h| h.request(request) }
30
39
  response.body
31
40
  end
32
41
  end
@@ -6,7 +6,7 @@ module Fogbugz
6
6
  module XML
7
7
  class Cracker
8
8
  def self.parse(xml)
9
- Crack::XML.parse(xml)["response"]
9
+ Crack::XML.parse(xml)['response']
10
10
  end
11
11
  end
12
12
  end
@@ -2,34 +2,31 @@ module Fogbugz
2
2
  class Interface
3
3
  class RequestError < StandardError; end
4
4
  class InitializationError < StandardError; end
5
-
5
+
6
6
  attr_accessor :options, :http, :xml, :token
7
7
 
8
8
  def initialize(options = {})
9
9
  @options = {}.merge(options)
10
10
 
11
- raise InitializationError, "Must supply URI (e.g. https://fogbugz.company.com)" unless options[:uri]
11
+ raise InitializationError, 'Must supply URI (e.g. https://fogbugz.company.com)' unless options[:uri]
12
12
  @token = options[:token] if options[:token]
13
- @http = Fogbugz.adapter[:http].new(:uri => options[:uri])
13
+ @http = Fogbugz.adapter[:http].new(uri: options[:uri], ca_file: options[:ca_file])
14
14
  @xml = Fogbugz.adapter[:xml]
15
15
  end
16
16
 
17
17
  def authenticate
18
- response = @http.request :logon, {
19
- :params => {
20
- :email => @options[:email],
21
- :password => @options[:password]
22
- }
23
- }
18
+ response = @http.request :logon,
19
+ params: {
20
+ email: @options[:email],
21
+ password: @options[:password]
22
+ }
24
23
  begin
25
- @token ||= @xml.parse(response)["token"]
24
+ @token ||= @xml.parse(response)['token']
26
25
  if @token.nil? || @token == ''
27
- raise Fogbugz::AuthenticationException.new(@xml.parse(response)["error"])
26
+ raise Fogbugz::AuthenticationException, @xml.parse(response)['error']
28
27
  end
29
- rescue REXML::ParseException => e
30
- # Probably an issue with the auth information
31
- # p response
32
- raise Fogbugz::AuthenticationException.new("Looks like there was an issue with authentication (to #{@options[:uri]} as #{@options[:email]}) - probably the host/url.")
28
+ rescue REXML::ParseException
29
+ raise Fogbugz::AuthenticationException, "Looks like there was an issue with authentication (to #{@options[:uri]} as #{@options[:email]}) - probably the host/url."
33
30
  end
34
31
  @token
35
32
  end
@@ -38,14 +35,12 @@ module Fogbugz
38
35
  raise RequestError, 'No token available, #authenticate first' unless @token
39
36
  parameters[:token] = @token
40
37
 
41
- response = @http.request action, {
42
- :params => parameters.merge(options[:params] || {})
43
- }
38
+ response = @http.request action, params: parameters.merge(options[:params] || {})
44
39
 
45
40
  @xml.parse(response)
46
41
  end
47
42
  end
48
-
43
+
49
44
  class AuthenticationException < Exception
50
45
  end
51
46
  end
@@ -1,3 +1,3 @@
1
1
  module Fogbugz
2
- VERSION = '0.2.1'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -1,29 +1,30 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "ruby_fogbugz/version"
2
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ require 'ruby_fogbugz/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = "ruby-fogbugz"
6
+ s.name = 'ruby-fogbugz'
7
7
  s.version = Fogbugz::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ['Simon Hørup Eskildsen', 'Jared Szechy']
10
10
  s.email = ['sirup@sirupsen.com', 'jared.szechy@gmail.com']
11
11
  s.homepage = 'https://github.com/firmafon/ruby-fogbugz'
12
- s.summary = %q{Ruby wrapper for the Fogbugz API }
13
- s.description = %q{A simple Ruby wrapper for the Fogbugz XML API}
12
+ s.summary = 'Ruby wrapper for the Fogbugz API'
13
+ s.description = 'A simple Ruby wrapper for the Fogbugz XML API'
14
14
  s.license = 'MIT'
15
15
 
16
- s.rubyforge_project = "ruby-fogbugz"
16
+ s.rubyforge_project = 'ruby-fogbugz'
17
17
 
18
18
  s.add_dependency 'crack', '~> 0.4'
19
+ s.add_dependency 'multipart-post', '~> 2.0'
19
20
 
20
- s.add_development_dependency 'rake', '~> 10.1'
21
- s.add_development_dependency 'minitest', '~> 5.8'
22
- s.add_development_dependency 'mocha', '~> 1.1'
23
- s.add_development_dependency 'codeclimate-test-reporter'
21
+ s.add_development_dependency 'rake', '< 11.0'
22
+ s.add_development_dependency 'webmock', '~> 1.21'
23
+ s.add_development_dependency 'rspec', '~> 3.3'
24
+ s.add_development_dependency 'codeclimate-test-reporter', '~> 1.0.0'
24
25
 
25
26
  s.files = `git ls-files`.split("\n")
26
27
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
28
- s.require_paths = ["lib"]
28
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
29
+ s.require_paths = ['lib']
29
30
  end
@@ -0,0 +1,26 @@
1
+ RSpec.describe 'Cracker' do
2
+ context 'valid response xml' do
3
+ let(:xml) { %q(<?xml version="1.0" encoding="UTF-8"?>
4
+ <response>
5
+ <version>2</version>
6
+ </response>) }
7
+
8
+ it 'parses the response' do
9
+ expect(parse_xml(xml)).to eq({ 'version' => '2' })
10
+ end
11
+ end
12
+
13
+ context 'invalid response xml' do
14
+ let(:xml) { %q(<html><head><title>Object moved</title></head><body>
15
+ <h2>Object moved to <a href="http://example.fogbugz.com:84/internalError.asp?aspxerrorpath=/api.asp">here</a>.</h2>
16
+ </body></html>) }
17
+
18
+ it 'returns nil' do
19
+ expect(parse_xml(xml)).to be_nil
20
+ end
21
+ end
22
+
23
+ def parse_xml(xml)
24
+ Fogbugz::Adapter::XML::Cracker.parse(xml)
25
+ end
26
+ end
@@ -0,0 +1,51 @@
1
+ RSpec.describe 'Interface' do
2
+ let(:credentials) { { email: 'test@example.com', password: 'seekrit', uri: 'https://fogbugz.example.com' } }
3
+
4
+ context 'initialization' do
5
+ it 'options are publicly available' do
6
+ fogbugz = Fogbugz::Interface.new(credentials)
7
+ expect(fogbugz.options).to eq(credentials)
8
+ end
9
+
10
+ it 'raises exception without URI' do
11
+ expect { Fogbugz::Interface.new }.to raise_error(Fogbugz::Interface::InitializationError)
12
+ end
13
+ end
14
+
15
+ context 'when credentials are valid' do
16
+ let(:fogbugz) { Fogbugz::Interface.new(credentials) }
17
+
18
+ it '#authenticate returns a token' do
19
+ token = fogbugz.authenticate
20
+ expect(token).not_to be_nil
21
+ end
22
+
23
+ it '#command returns result' do
24
+ fogbugz.token = 'abcdefabcdefabcdef'
25
+ fogbugz.command(:search, q: '1')
26
+ end
27
+ end
28
+
29
+ context 'when credentials are invalid' do
30
+ let(:credentials) { super().merge(password: 'invalid') }
31
+ let(:fogbugz) { Fogbugz::Interface.new(credentials) }
32
+
33
+ it '#authenticate raises an exception' do
34
+ expect { fogbugz.authenticate }.to raise_error(Fogbugz::AuthenticationException, 'Incorrect password or username')
35
+ end
36
+
37
+ it '#command raises an exception' do
38
+ fogbugz.token = nil
39
+ expect { fogbugz.command(:search, q: 'case') }.to raise_error(Fogbugz::Interface::RequestError)
40
+ end
41
+ end
42
+
43
+ context 'when server does not reply as expected' do
44
+ let(:credentials) { super().merge(uri: 'https://notfogbugz.example.com') }
45
+ let(:fogbugz) { Fogbugz::Interface.new(credentials) }
46
+
47
+ it '#authenticate raises an exception' do
48
+ expect { fogbugz.authenticate }.to raise_error(Fogbugz::AuthenticationException)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,52 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'webmock/rspec'
5
+ WebMock.disable_net_connect!(allow: 'codeclimate.com')
6
+
7
+ require 'fogbugz'
8
+
9
+ RSpec.configure do |config|
10
+ config.expect_with :rspec do |expectations|
11
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
12
+ end
13
+
14
+ config.mock_with :rspec do |mocks|
15
+ mocks.verify_partial_doubles = true
16
+ end
17
+
18
+ config.filter_run :focus
19
+ config.run_all_when_everything_filtered = true
20
+
21
+ config.example_status_persistence_file_path = 'spec/examples.txt'
22
+
23
+ config.disable_monkey_patching!
24
+
25
+ config.warnings = true
26
+
27
+ config.default_formatter = 'doc' if config.files_to_run.one?
28
+
29
+ # config.profile_examples = 10
30
+
31
+ config.order = :random
32
+
33
+ Kernel.srand config.seed
34
+
35
+ config.before(:each) do
36
+ stub_request(:post, 'https://fogbugz.example.com/api.asp')
37
+ .with(body: { cmd: 'logon', email: 'test@example.com', password: 'seekrit' })
38
+ .to_return(body: '<?xml version="1.0" encoding="UTF-8"?><response><token><![CDATA[abcdefabcdefabcdefabcdefabcdef]]></token></response>')
39
+
40
+ stub_request(:post, 'https://fogbugz.example.com/api.asp')
41
+ .with(body: { cmd: 'logon', email: 'test@example.com', password: 'invalid' })
42
+ .to_return(body: '<?xml version="1.0" encoding="UTF-8"?><response><error code="1"><![CDATA[Incorrect password or username]]></error></response>')
43
+
44
+ stub_request(:post, 'https://fogbugz.example.com/api.asp')
45
+ .with(body: { cmd: 'search', q: '1', token: 'abcdefabcdefabcdef' })
46
+ .to_return(body: '<?xml version="1.0" encoding="UTF-8"?><response><cases count="1"><case ixBug="1" operations="edit,reopen,email,remind"></case></cases></response>')
47
+
48
+ stub_request(:post, 'https://notfogbugz.example.com/api.asp')
49
+ .with(body: { cmd: 'logon', email: 'test@example.com', password: 'seekrit' })
50
+ .to_return(body: '<html></head></html>')
51
+ end
52
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-fogbugz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Hørup Eskildsen
@@ -9,78 +9,92 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-15 00:00:00.000000000 Z
12
+ date: 2017-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: crack
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0.4'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0.4'
28
+ - !ruby/object:Gem::Dependency
29
+ name: multipart-post
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '2.0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '2.0'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: rake
30
44
  requirement: !ruby/object:Gem::Requirement
31
45
  requirements:
32
- - - ~>
46
+ - - "<"
33
47
  - !ruby/object:Gem::Version
34
- version: '10.1'
48
+ version: '11.0'
35
49
  type: :development
36
50
  prerelease: false
37
51
  version_requirements: !ruby/object:Gem::Requirement
38
52
  requirements:
39
- - - ~>
53
+ - - "<"
40
54
  - !ruby/object:Gem::Version
41
- version: '10.1'
55
+ version: '11.0'
42
56
  - !ruby/object:Gem::Dependency
43
- name: minitest
57
+ name: webmock
44
58
  requirement: !ruby/object:Gem::Requirement
45
59
  requirements:
46
- - - ~>
60
+ - - "~>"
47
61
  - !ruby/object:Gem::Version
48
- version: '5.8'
62
+ version: '1.21'
49
63
  type: :development
50
64
  prerelease: false
51
65
  version_requirements: !ruby/object:Gem::Requirement
52
66
  requirements:
53
- - - ~>
67
+ - - "~>"
54
68
  - !ruby/object:Gem::Version
55
- version: '5.8'
69
+ version: '1.21'
56
70
  - !ruby/object:Gem::Dependency
57
- name: mocha
71
+ name: rspec
58
72
  requirement: !ruby/object:Gem::Requirement
59
73
  requirements:
60
- - - ~>
74
+ - - "~>"
61
75
  - !ruby/object:Gem::Version
62
- version: '1.1'
76
+ version: '3.3'
63
77
  type: :development
64
78
  prerelease: false
65
79
  version_requirements: !ruby/object:Gem::Requirement
66
80
  requirements:
67
- - - ~>
81
+ - - "~>"
68
82
  - !ruby/object:Gem::Version
69
- version: '1.1'
83
+ version: '3.3'
70
84
  - !ruby/object:Gem::Dependency
71
85
  name: codeclimate-test-reporter
72
86
  requirement: !ruby/object:Gem::Requirement
73
87
  requirements:
74
- - - ! '>='
88
+ - - "~>"
75
89
  - !ruby/object:Gem::Version
76
- version: '0'
90
+ version: 1.0.0
77
91
  type: :development
78
92
  prerelease: false
79
93
  version_requirements: !ruby/object:Gem::Requirement
80
94
  requirements:
81
- - - ! '>='
95
+ - - "~>"
82
96
  - !ruby/object:Gem::Version
83
- version: '0'
97
+ version: 1.0.0
84
98
  description: A simple Ruby wrapper for the Fogbugz XML API
85
99
  email:
86
100
  - sirup@sirupsen.com
@@ -89,8 +103,11 @@ executables: []
89
103
  extensions: []
90
104
  extra_rdoc_files: []
91
105
  files:
92
- - .gitignore
93
- - .travis.yml
106
+ - ".codeclimate.yml"
107
+ - ".gitignore"
108
+ - ".rspec"
109
+ - ".rubocop.yml"
110
+ - ".travis.yml"
94
111
  - Gemfile
95
112
  - README.md
96
113
  - Rakefile
@@ -100,9 +117,9 @@ files:
100
117
  - lib/ruby_fogbugz/interface.rb
101
118
  - lib/ruby_fogbugz/version.rb
102
119
  - ruby-fogbugz.gemspec
103
- - test/adapters/xml/crack_test.rb
104
- - test/interface_test.rb
105
- - test/test_helper.rb
120
+ - spec/adapters/xml/crack_spec.rb
121
+ - spec/interface_spec.rb
122
+ - spec/spec_helper.rb
106
123
  homepage: https://github.com/firmafon/ruby-fogbugz
107
124
  licenses:
108
125
  - MIT
@@ -113,21 +130,21 @@ require_paths:
113
130
  - lib
114
131
  required_ruby_version: !ruby/object:Gem::Requirement
115
132
  requirements:
116
- - - ! '>='
133
+ - - ">="
117
134
  - !ruby/object:Gem::Version
118
135
  version: '0'
119
136
  required_rubygems_version: !ruby/object:Gem::Requirement
120
137
  requirements:
121
- - - ! '>='
138
+ - - ">="
122
139
  - !ruby/object:Gem::Version
123
140
  version: '0'
124
141
  requirements: []
125
142
  rubyforge_project: ruby-fogbugz
126
- rubygems_version: 2.4.8
143
+ rubygems_version: 2.6.10
127
144
  signing_key:
128
145
  specification_version: 4
129
146
  summary: Ruby wrapper for the Fogbugz API
130
147
  test_files:
131
- - test/adapters/xml/crack_test.rb
132
- - test/interface_test.rb
133
- - test/test_helper.rb
148
+ - spec/adapters/xml/crack_spec.rb
149
+ - spec/interface_spec.rb
150
+ - spec/spec_helper.rb
@@ -1,26 +0,0 @@
1
- require 'test_helper'
2
- require 'ruby_fogbugz/adapters/xml/cracker'
3
-
4
- class Cracker < FogTest
5
- test 'should parse XML and get rid of the response namespace' do
6
- XML = <<-xml
7
- <?xml version="1.0" encoding="UTF-8"?>
8
- <response>
9
- <version>2</version>
10
- </response>
11
- xml
12
-
13
- assert_equal({"version" => "2"}, Fogbugz::Adapter::XML::Cracker.parse(XML))
14
- end
15
-
16
- # Sometimes Fogbugz returns responses like this
17
- test 'should return nil when the response is not valid' do
18
- XML = <<-xml
19
- <html><head><title>Object moved</title></head><body>
20
- <h2>Object moved to <a href="http://example.fogbugz.com:84/internalError.asp?aspxerrorpath=/api.asp">here</a>.</h2>
21
- </body></html>
22
- xml
23
-
24
- assert_equal(nil, Fogbugz::Adapter::XML::Cracker.parse(XML))
25
- end
26
- end
@@ -1,56 +0,0 @@
1
- require 'test_helper.rb'
2
-
3
- class FogTest
4
- CREDENTIALS = {
5
- :email => "test@test.com",
6
- :password => 'seekrit',
7
- :uri => 'http://fogbugz.test.com'
8
- }
9
- end
10
-
11
- class BasicInterface < FogTest
12
- def setup
13
- @fogbugz = Fogbugz::Interface.new(CREDENTIALS)
14
- end
15
-
16
- test 'when instantiating options should be overwriting and be publicly available' do
17
- assert_equal CREDENTIALS, @fogbugz.options
18
- end
19
- end
20
-
21
- class InterfaceRequests < FogTest
22
- def setup
23
- #Fogbugz.adapter[:http] = mock()
24
- #Fogbugz.adapter[:http].expects(:new)
25
- end
26
-
27
- test 'authentication should send correct parameters' do
28
- fogbugz = Fogbugz::Interface.new(CREDENTIALS)
29
- fogbugz.http.expects(:request).with(:logon,
30
- :params => {
31
- :email => CREDENTIALS[:email],
32
- :password => CREDENTIALS[:password]
33
- }).returns("token")
34
-
35
- fogbugz.xml.expects(:parse).with("token").returns({"token" => "22"})
36
-
37
- fogbugz.authenticate
38
- end
39
-
40
- test 'requesting with an action should send along token and correct parameters' do
41
- fogbugz = Fogbugz::Interface.new(CREDENTIALS)
42
- fogbugz.token = 'token'
43
- fogbugz.http.expects(:request).with(:search, {:params => {:q => 'case', :token => 'token'}}).returns("omgxml")
44
- fogbugz.xml.expects(:parse).with("omgxml")
45
- fogbugz.command(:search, :q => 'case')
46
- end
47
-
48
- test 'throws an exception if #command is requested with no token' do
49
- fogbugz = Fogbugz::Interface.new(CREDENTIALS)
50
- fogbugz.token = nil
51
-
52
- assert_raises Fogbugz::Interface::RequestError do
53
- fogbugz.command(:search, :q => 'case')
54
- end
55
- end
56
- end
@@ -1,18 +0,0 @@
1
- require 'codeclimate-test-reporter'
2
- CodeClimate::TestReporter.start
3
-
4
- require 'rubygems'
5
- gem 'minitest' # ensures you're using the gem, and not the built in MT
6
- $: << File.expand_path(File.dirname(__FILE__) + "../lib")
7
-
8
- require 'minitest/autorun'
9
- require 'minitest/pride'
10
- require 'mocha/mini_test'
11
-
12
- require 'fogbugz'
13
-
14
- class FogTest < MiniTest::Unit::TestCase
15
- def self.test(description, &block)
16
- define_method("test_" + description.split.join('_').gsub(/\W/, ''), block)
17
- end
18
- end