Skip to content

Add rspec, versioning tests, and a debug flag #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--format progress
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: ruby
rvm:
- 1.9.3
- 2.0.0
- ruby-head
script:
- bundle exec rspec

branches:
only:
- master

matrix:
allow_failures:
- rvm: ruby-head

notifications:
email:
- [email protected]
11 changes: 1 addition & 10 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
source "http://rubygems.org"

gem 'her'
gem 'faraday_middleware'
gem 'multi_xml'

group :development do
gem "shoulda", ">= 0"
gem "rdoc", "~> 3.12"
gem "bundler", ">= 1.0.0"
gem "jeweler", "~> 1.8.4"
end
gemspec
44 changes: 26 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
PATH
remote: .
specs:
redmine-ruby (0.2.7)
faraday_middleware
her
multi_xml

GEM
remote: http://rubygems.org/
specs:
Expand All @@ -12,30 +20,32 @@ GEM
tzinfo (~> 0.3.37)
atomic (1.1.10)
builder (3.1.4)
faraday (0.8.8)
diff-lcs (1.2.5)
faraday (0.8.9)
multipart-post (~> 1.2.0)
faraday_middleware (0.9.0)
faraday (>= 0.7.4, < 0.9)
git (1.2.5)
her (0.6.8)
activemodel (>= 3.0.0)
activesupport (>= 3.0.0)
faraday (~> 0.8)
multi_json (~> 1.7)
i18n (0.6.4)
jeweler (1.8.4)
bundler (~> 1.0)
git (>= 1.2.5)
rake
rdoc
json (1.8.0)
json (1.8.1)
minitest (4.7.5)
multi_json (1.7.7)
multi_xml (0.5.4)
multi_xml (0.5.5)
multipart-post (1.2.0)
rake (10.1.0)
rdoc (3.12.2)
rdoc (4.1.1)
json (~> 1.4)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
shoulda (3.5.0)
shoulda-context (~> 1.0, >= 1.0.1)
shoulda-matchers (>= 1.4.1, < 3.0)
Expand All @@ -50,10 +60,8 @@ PLATFORMS
ruby

DEPENDENCIES
bundler (>= 1.0.0)
faraday_middleware
her
jeweler (~> 1.8.4)
multi_xml
rdoc (~> 3.12)
shoulda
bundler (>= 1.0)
rdoc (~> 4.1)
redmine-ruby!
rspec (~> 2.14)
shoulda (~> 3.5)
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.7
0.2.8
8 changes: 5 additions & 3 deletions lib/redmine-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@
require 'redmine-ruby/tracker.rb'

module Redmine
VERSION = "0.2.7"
VERSION = "0.2.8"

class Client
attr_accessor :url, :token, :api
attr_accessor :url, :token, :api, :debug

def initialize(url, token)
def initialize(url, token, debug=false)
self.url = url
self.token = token
self.api = Her::API.new
self.debug = debug
self.api.setup url: url, ssl: { verify: false } do |c|
c.use Faraday::Request::BasicAuthentication, token, ''
c.use Faraday::Request::UrlEncoded
c.use Faraday::Response::Logger if debug
c.use Redmine::Middleware::XmlParser
c.use Faraday::Adapter::NetHttp
end
Expand Down
40 changes: 13 additions & 27 deletions redmine-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,24 @@ Gem::Specification.new() do |s|
"LICENSE.txt",
"README.md"
]
s.files = [
".document",
"Gemfile",
"Gemfile.lock",
"LICENSE.txt",
"README.md",
"Rakefile",
"VERSION",
"lib/redmine-ruby.rb",
"lib/redmine-ruby/base.rb",
"lib/redmine-ruby/custom_field.rb",
"lib/redmine-ruby/exception.rb",
"lib/redmine-ruby/issue.rb",
"lib/redmine-ruby/middleware/xml_parser.rb",
"lib/redmine-ruby/project.rb",
"lib/redmine-ruby/time_entry.rb",
"lib/redmine-ruby/upload.rb",
"redmine-ruby.gemspec",
"test/helper.rb",
"test/test_redmine-ruby.rb"
]

s.files = `git ls-files`.split($/)
s.test_files = s.files.grep(%r{^(spec|features)})

s.homepage = "http://github.com/GeneralScripting/redmine-ruby"
s.licenses = ["MIT"]
s.require_paths = ["lib"]
s.rubygems_version = "1.8.25"
s.summary = "Ruby Redmine Client using Her"

s.add_runtime_dependency(%q<her>, [">= 0"])
s.add_runtime_dependency(%q<faraday_middleware>, [">= 0"])
s.add_runtime_dependency(%q<multi_xml>, [">= 0"])
s.add_development_dependency(%q<shoulda>, [">= 0"])
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
s.add_runtime_dependency 'her', '>= 0'
s.add_runtime_dependency 'faraday_middleware', '>= 0'
s.add_runtime_dependency 'multi_xml', '>= 0'

s.add_development_dependency 'bundler', '>= 1.0'
s.add_development_dependency 'rdoc', '~> 4.1'
s.add_development_dependency 'rspec', '~> 2.14'
s.add_development_dependency 'shoulda', '~> 3.5'

end

41 changes: 41 additions & 0 deletions spec/redmine-ruby/redmine_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require 'spec_helper'

describe Redmine do

context "versioning" do

it "should have a version constant" do
Redmine.constants.should include(:VERSION)
end

it "should have a version file" do
version_file = File.join(REDMINE_RUBY_ROOT, 'VERSION')
expect( File.exists?(version_file) ).to eq(true)
end

it "should have a version file with just one line and no newline" do
version_file = File.join(REDMINE_RUBY_ROOT, 'VERSION')
version_file_data = File.read(version_file)
lines = version_file_data.split('\n')

expect(lines.count).to eq(1)
expect(version_file_data.index("\n")).to be_nil

end

it "the VERSION constant should always equal the contents of the VERSION file" do
version_file_version = File.read(File.join(REDMINE_RUBY_ROOT, 'VERSION'))
expect(Redmine::VERSION).to eq(version_file_version)
end

end


context "resources" do



end


end
23 changes: 23 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper"` to ensure that it is only
# loaded once.
#

$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
require 'redmine-ruby'

REDMINE_RUBY_ROOT = File.expand_path('../../', __FILE__)

# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus

# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = 'random'
end
18 changes: 0 additions & 18 deletions test/helper.rb

This file was deleted.

7 changes: 0 additions & 7 deletions test/test_redmine-ruby.rb

This file was deleted.