version-one 0.0.2

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.
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+ require 'lib/common'
3
+ require 'version-one/query'
4
+
5
+ describe VersionOne::Asset do
6
+ include_context 'configured'
7
+
8
+ let(:meta) { VersionOne::Meta.new(load_xml('story_meta')) }
9
+
10
+ before :each do
11
+ allow(VersionOne::Meta).to receive(:get).and_return(meta)
12
+ end
13
+
14
+ shared_examples 'new' do
15
+
16
+ it 'should succeed' do
17
+ expect(subject).not_to be_nil
18
+ end
19
+
20
+ it 'should provide attribute readers from meta' do
21
+ expect(subject).to respond_to :estimate, :number, :order
22
+ end
23
+
24
+ it 'should provide attribute writers from meta' do
25
+ expect(subject).to respond_to :estimate=
26
+ end
27
+
28
+ it 'should reject using attribute writers from meta for read-only after init' do
29
+ expect(subject).to respond_to :number=
30
+ expect(lambda{ subject.number = '12345' }).to raise_error(/Can't set read-only/)
31
+ end
32
+
33
+ it 'should provide relation readers from meta' do
34
+ expect(subject).to respond_to :security_scope, :status
35
+ end
36
+
37
+ it 'should provide relation writers from meta' do
38
+ expect(subject).to respond_to :security_scope=, :status=
39
+ end
40
+
41
+ end
42
+
43
+ describe 'new from xml' do
44
+ subject { described_class.from_xml(load_xml('story')) }
45
+
46
+ include_examples 'new'
47
+
48
+ it 'should set attribute values from xml' do
49
+ expect(subject.number).to eq 'B-01027'
50
+ expect(subject.order).to eq -1071957351
51
+ end
52
+
53
+ it 'should provide attribute readers for queried attributes' do
54
+ expect(subject).to respond_to :security_scope_name
55
+ end
56
+
57
+ end
58
+
59
+ describe 'new' do
60
+ subject { described_class.new(type: 'Story') }
61
+
62
+ include_examples 'new'
63
+ end
64
+
65
+ describe 'save' do
66
+ subject { described_class.new(type: 'Story') }
67
+ let(:project) { VersionOne::Query.projects.find(config['test']['scope']) }
68
+
69
+ include_examples 'new'
70
+
71
+ it 'should save and update a new item' do
72
+ subject.name = 'IGNORE. This is a V1 automation unit test.'
73
+ subject.description = "<p><b>IGNORE.</b> This is a unit test.</p>"
74
+ subject.scope = project
75
+ expect(subject.save).to be_truthy
76
+ expect(subject.id).to match /^Story(:\d{1,6})+$/
77
+ expect(subject.href).to be_a String
78
+
79
+ new_item = VersionOne::Query.primary_work_items.find(subject.id)
80
+ expect(new_item).to_not be_nil
81
+ expect(new_item.number).to match /^B-\d{5,6}$/
82
+ expect(new_item.description).to eq subject.description
83
+ new_item.description = "<p>Description update</p>"
84
+ expect(new_item.save).to be_truthy
85
+
86
+ final_item = VersionOne::Query.primary_work_items.find(subject.id)
87
+ expect(final_item.description).to eq new_item.description
88
+ end
89
+
90
+ end
91
+
92
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'libxml'
3
+ require 'yaml'
4
+ require 'base64'
5
+
6
+ shared_context 'configured' do
7
+ CONFIG_FILE = File.expand_path('../../v1config.yml', __FILE__)
8
+
9
+ before(:all) do
10
+ VersionOne.config.load config['config']
11
+ end
12
+
13
+ def config
14
+ unless @config
15
+ raise "#{CONFIG_FILE} does not exist. Please see v1config.template.yml" unless File.exist?(CONFIG_FILE)
16
+ @config = YAML.load_file(CONFIG_FILE)
17
+ raise "Config load problem!!!" unless @config.is_a?(Hash)
18
+ @config['config']['password'] = Base64.decode64(config['config']['password'])
19
+ end
20
+ @config
21
+ end
22
+
23
+ def load_fixture(name)
24
+ File.read(File.expand_path('../../fixtures/' + name, __FILE__))
25
+ end
26
+
27
+ def load_xml(name)
28
+ XML::Document.string(load_fixture(name + '.xml')).root
29
+ end
30
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+ require 'lib/common'
3
+
4
+ describe VersionOne::Meta do
5
+ include_context 'configured'
6
+
7
+ describe 'get' do
8
+
9
+ before :all do
10
+ @meta = described_class.get('Story')
11
+ end
12
+
13
+ it 'should get meta data' do
14
+ expect(@meta).not_to be_nil
15
+ end
16
+
17
+ it 'should have parsed attributes' do
18
+ expect(@meta.attributes).not_to be_empty
19
+ @meta.attributes.each do |a|
20
+ expect(a).to be_a VersionOne::AttributeDefinition
21
+ expect(a.name).to be_a String
22
+ expect(a.type).to be_a Symbol
23
+ end
24
+
25
+ attrib = @meta['Estimate']
26
+ expect(attrib).not_to be_nil
27
+ expect(attrib.type).to eq :numeric
28
+ expect(attrib.readonly?).to eq false
29
+ expect(attrib.multivalue?).to eq false
30
+ end
31
+
32
+ it 'should have a name' do
33
+ expect(@meta.name).to eq 'Story'
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+ require 'lib/common'
3
+
4
+ describe VersionOne::Query do
5
+ include_context 'configured'
6
+
7
+
8
+ end
@@ -0,0 +1,72 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, make a
10
+ # separate helper file that requires this one and then use it only in the specs
11
+ # that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ require File.expand_path('../../lib/version-one', __FILE__)
18
+
19
+ RSpec.configure do |config|
20
+ config.filter_run :focus
21
+ config.run_all_when_everything_filtered = true
22
+
23
+ # Many RSpec users commonly either run the entire suite or an individual
24
+ # file, and it's useful to allow more verbose output when running an
25
+ # individual spec file.
26
+ if config.files_to_run.one?
27
+ # Use the documentation formatter for detailed output,
28
+ # unless a formatter has already been configured
29
+ # (e.g. via a command-line flag).
30
+ config.default_formatter = 'doc'
31
+ end
32
+
33
+ # Print the 10 slowest examples and example groups at the
34
+ # end of the spec run, to help surface which specs are running
35
+ # particularly slow.
36
+ config.profile_examples = 10
37
+
38
+ # Run specs in random order to surface order dependencies. If you find an
39
+ # order dependency and want to debug it, you can fix the order by providing
40
+ # the seed, which is printed after each run.
41
+ # --seed 1234
42
+ config.order = :random
43
+
44
+ # Seed global randomization in this process using the `--seed` CLI option.
45
+ # Setting this allows you to use `--seed` to deterministically reproduce
46
+ # test failures related to randomization by passing the same `--seed` value
47
+ # as the one that triggered the failure.
48
+ Kernel.srand config.seed
49
+
50
+ # rspec-expectations config goes here. You can use an alternate
51
+ # assertion/expectation library such as wrong or the stdlib/minitest
52
+ # assertions if you prefer.
53
+ config.expect_with :rspec do |expectations|
54
+ # Enable only the newer, non-monkey-patching expect syntax.
55
+ # For more details, see:
56
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
57
+ expectations.syntax = :expect
58
+ end
59
+
60
+ # rspec-mocks config goes here. You can use an alternate test double
61
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
62
+ config.mock_with :rspec do |mocks|
63
+ # Enable only the newer, non-monkey-patching expect syntax.
64
+ # For more details, see:
65
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
66
+ mocks.syntax = :expect
67
+
68
+ # Prevents you from mocking or stubbing a method that does not exist on
69
+ # a real object. This is generally recommended.
70
+ mocks.verify_partial_doubles = true
71
+ end
72
+ end
@@ -0,0 +1,11 @@
1
+ #
2
+ # Copy this file to v1config.yml and enter appropriate values
3
+ # Do NOT checkin v1config.yml
4
+ #
5
+ config:
6
+ user: YOUR_USERNAME
7
+ password: YOUR_PASSWORD_BASE64
8
+ service_uri: FULL_BASE_SERVICE_URI
9
+
10
+ test:
11
+ scope: TBD
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'version-one/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "version-one"
8
+ spec.version = VersionOne::VERSION
9
+ spec.authors = ["Dan Drew"]
10
+ spec.email = ["ddrew555@hotmail.com"]
11
+ spec.summary = %q{VersionOne integration gem.}
12
+ spec.description = %q{VersionOne integration gem.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'libxml-ruby'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake"
25
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: version-one
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dan Drew
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-09-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: libxml-ruby
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.6'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.6'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: VersionOne integration gem.
63
+ email:
64
+ - ddrew555@hotmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - .rspec
71
+ - .ruby-version
72
+ - Gemfile
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - lib/version-one.rb
77
+ - lib/version-one/asset.rb
78
+ - lib/version-one/asset_ref.rb
79
+ - lib/version-one/client.rb
80
+ - lib/version-one/config.rb
81
+ - lib/version-one/meta.rb
82
+ - lib/version-one/meta/attribute_definition.rb
83
+ - lib/version-one/query.rb
84
+ - lib/version-one/relation_multi_value.rb
85
+ - lib/version-one/time.rb
86
+ - lib/version-one/version.rb
87
+ - lib/version-one/version.rb~
88
+ - spec/fixtures/story.xml
89
+ - spec/fixtures/story_meta.xml
90
+ - spec/lib/asset_spec.rb
91
+ - spec/lib/common.rb
92
+ - spec/lib/meta_spec.rb
93
+ - spec/lib/query_spec.rb
94
+ - spec/spec_helper.rb
95
+ - spec/v1config.template.yml
96
+ - version-one.gemspec
97
+ homepage: ''
98
+ licenses:
99
+ - MIT
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 1.8.23
119
+ signing_key:
120
+ specification_version: 3
121
+ summary: VersionOne integration gem.
122
+ test_files:
123
+ - spec/fixtures/story.xml
124
+ - spec/fixtures/story_meta.xml
125
+ - spec/lib/asset_spec.rb
126
+ - spec/lib/common.rb
127
+ - spec/lib/meta_spec.rb
128
+ - spec/lib/query_spec.rb
129
+ - spec/spec_helper.rb
130
+ - spec/v1config.template.yml