cybercoach 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6a9a92ac6f4d0a0056b5e31ea9717363fccd5fd
4
- data.tar.gz: 37fb5abb5d3fd402380e28d2d4fcbc6754b34621
3
+ metadata.gz: 41db91dcbbadb8acccdbbd7858159b2f7477668b
4
+ data.tar.gz: e80eb36b40822ee714320acc4129571867dca169
5
5
  SHA512:
6
- metadata.gz: c737a573870e7403031a28189684e7b4947be3353a05507d087cf7b570c6e88f81228234e9f0e42d016edcef74ee24149c0fb6994827ce12792429ebc6f0eecb
7
- data.tar.gz: 86d6ede3842a3ddac0cae4cbfcb54813ce792e7437736ce52b0193cd639b96829f302e3d5d484d6b4319998ce2f4b406e295bbf90db5d973f71aa4bffe965264
6
+ metadata.gz: e34d50db5513b57d30065e3622e91b95fa25c25ec7328bbaddd7bc757d5ac0290eca1de79d1722ff873f5dd2e54eedd3e2ed0e288514c6d34e1ed968faf330e7
7
+ data.tar.gz: c2d4697eb584e4a061aba0d36b9c0f04a860b9b376a3271e6911400cfb8bb680e845b30a99e0399b4fd310536c1fa3c3cbd0d9d4b00b6e1775ecc697e1f78ff5
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cybercoach
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Leuenberger
@@ -52,65 +52,13 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '3.1'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '3.1'
69
- - !ruby/object:Gem::Dependency
70
- name: pry
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '0.10'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0.10'
83
55
  description: Wraps the CyberCoach resources and their CRUD methods.
84
56
  email:
85
57
  - manuel.leu@students.unibe.ch
86
58
  executables: []
87
59
  extensions: []
88
60
  extra_rdoc_files: []
89
- files:
90
- - ".--color"
91
- - ".gitignore"
92
- - ".rspec"
93
- - ".ruby-gemset"
94
- - ".ruby-version"
95
- - Gemfile
96
- - LICENSE.txt
97
- - README.md
98
- - Rakefile
99
- - cybercoach.gemspec
100
- - lib/cybercoach.rb
101
- - lib/cybercoach/abstract_resource.rb
102
- - lib/cybercoach/format_not_supported_error.rb
103
- - lib/cybercoach/http_error.rb
104
- - lib/cybercoach/not_implemented_error.rb
105
- - lib/cybercoach/partnership.rb
106
- - lib/cybercoach/resource.rb
107
- - lib/cybercoach/resource_page.rb
108
- - lib/cybercoach/settings.rb
109
- - lib/cybercoach/sport.rb
110
- - lib/cybercoach/user.rb
111
- - lib/cybercoach/version.rb
112
- - spec/lib/cyber_coach_spec.rb
113
- - spec/spec_helper.rb
61
+ files: []
114
62
  homepage: https://github.com/New-York-Falcons/cybercoach
115
63
  licenses:
116
64
  - MIT
@@ -134,7 +82,5 @@ rubyforge_project:
134
82
  rubygems_version: 2.2.2
135
83
  signing_key:
136
84
  specification_version: 4
137
- summary: Cybercoach proxy
138
- test_files:
139
- - spec/lib/cyber_coach_spec.rb
140
- - spec/spec_helper.rb
85
+ summary: CyberCoach proxy
86
+ test_files: []
data/.--color DELETED
File without changes
data/.gitignore DELETED
@@ -1,53 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.bundle
11
- *.so
12
- *.o
13
- *.a
14
- mkmf.log
15
-
16
- # Created by https://www.gitignore.io
17
-
18
- ### Ruby ###
19
- *.gem
20
- *.rbc
21
- /.config
22
- /coverage/
23
- /InstalledFiles
24
- /pkg/
25
- /spec/reports/
26
- /test/tmp/
27
- /test/version_tmp/
28
- /tmp/
29
-
30
- ## Specific to RubyMotion:
31
- .dat*
32
- .repl_history
33
- build/
34
-
35
- ## Documentation cache and generated files:
36
- /.yardoc/
37
- /_yardoc/
38
- /doc/
39
- /rdoc/
40
-
41
- ## Environment normalisation:
42
- /.bundle/
43
- /lib/bundler/man/
44
-
45
- # for a library or gem, you might want to ignore these files since the code is
46
- # intended to run in multiple environments; otherwise, check them in:
47
- # Gemfile.lock
48
- # .ruby-version
49
- # .ruby-gemset
50
-
51
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
52
- .rvmrc
53
-
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format documentation
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- cybercoach
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- ruby-2.1.3
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in cybercoach.gemspec
4
- gemspec
data/LICENSE.txt DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2014 NewYorkFalcons
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md DELETED
@@ -1,31 +0,0 @@
1
- # Cybercoach
2
-
3
- TODO: Write a gem description
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'cybercoach'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install cybercoach
20
-
21
- ## Usage
22
-
23
- TODO: Write usage instructions here
24
-
25
- ## Contributing
26
-
27
- 1. Fork it ( https://github.com/[my-github-username]/cybercoach/fork )
28
- 2. Create your feature branch (`git checkout -b my-new-feature`)
29
- 3. Commit your changes (`git commit -am 'Add some feature'`)
30
- 4. Push to the branch (`git push origin my-new-feature`)
31
- 5. Create a new Pull Request
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- require "bundler/gem_tasks"
2
-
data/cybercoach.gemspec DELETED
@@ -1,27 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'cybercoach/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "cybercoach"
8
- spec.version = Cybercoach::VERSION
9
- spec.authors = ["Manuel Leuenberger"]
10
- spec.email = ["manuel.leu@students.unibe.ch"]
11
- spec.summary = %q{Cybercoach proxy}
12
- spec.description = %q{Wraps the CyberCoach resources and their CRUD methods.}
13
- spec.homepage = "https://github.com/New-York-Falcons/cybercoach"
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_runtime_dependency "httparty", "~> 0.13"
22
-
23
- spec.add_development_dependency "bundler", "~> 1.7"
24
- spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "rspec", "~> 3.1"
26
- spec.add_development_dependency "pry", "~> 0.10"
27
- end
@@ -1,74 +0,0 @@
1
- require 'httparty'
2
- require 'cybercoach/http_error'
3
-
4
- module CyberCoach
5
- class AbstractResource < Object
6
- include HTTParty
7
- attr_accessor :uri
8
-
9
- headers 'Content-Type' => 'application/json' ,'Accept' => 'application/json'
10
- format :json
11
- base_uri CyberCoach::Settings::SERVER_URI
12
-
13
- def initialize
14
- super
15
- @uri = nil
16
- @options = {}
17
- end
18
-
19
- def read(options={})
20
- invalidate_uri
21
- invalidate_options
22
- options = @options.merge(options)
23
- response = self.class.get(@uri, options)
24
- if response.success?
25
- from_serializable(response)
26
- else
27
- raise HttpError.new(response.response)
28
- end
29
- end
30
-
31
- def serialize
32
- format = self.class.default_options[:format]
33
- if format.nil?
34
- to_serializable
35
- elsif format == :json
36
- to_serializable.to_json
37
- else
38
- raise FormatNotSupportedError.new
39
- end
40
- end
41
-
42
- def from_serializable(serializable)
43
- @uri = serializable['uri']
44
- end
45
-
46
- def to_serializable
47
- serializable = {}
48
- serializable['uri'] = @uri
49
- serializable
50
- end
51
-
52
- # Returns the plural name used for parsing and building URIs.
53
- def plural_name
54
- raise NotImplementedError.new
55
- end
56
-
57
- # Returns the base URI relative to the server.
58
- def resource_base_uri
59
- "#{CyberCoach::Settings::BASE_URI}/#{plural_name}/"
60
- end
61
-
62
- protected
63
-
64
- # Recalculates the URI from the attributes.
65
- def invalidate_uri
66
-
67
- end
68
-
69
- # Recalculates the request options from the attributes.
70
- def invalidate_options
71
-
72
- end
73
- end
74
- end
@@ -1,4 +0,0 @@
1
- module CyberCoach
2
- class FormatNotSupportedError < RuntimeError
3
- end
4
- end
@@ -1,10 +0,0 @@
1
- module CyberCoach
2
- class HttpError < RuntimeError
3
- attr_accessor :cause
4
-
5
- def initialize(cause)
6
- super
7
- @cause = cause
8
- end
9
- end
10
- end
@@ -1,4 +0,0 @@
1
- module CyberCoach
2
- class NotImplementedError < RuntimeError
3
- end
4
- end
@@ -1,44 +0,0 @@
1
- module CyberCoach
2
- class Partnership < Resource
3
- attr_accessor :proposer,
4
- :proposed,
5
- :confirmed_by_proposer,
6
- :confirmed_by_proposed,
7
- :public_visible
8
-
9
- def from_serializable(serializable)
10
- super(serializable)
11
- @proposer = User.new
12
- unless serializable['user1'].nil?
13
- @proposer.from_serializable(serializable['user1'])
14
- end
15
- @proposed = User.new
16
- unless serializable['user2'].nil?
17
- @proposed.from_serializable(serializable['user2'])
18
- end
19
- @confirmed_by_proposer = serializable['userconfirmed1']
20
- @confirmed_by_proposed = serializable['userconfirmed2']
21
- @public_visible = serializable['publicvisible']
22
- end
23
-
24
- def to_serializable()
25
- serializable = super()
26
- serializable['user1'] = @proposer.to_serializable
27
- serializable['user2'] = @proposed.to_serializable
28
- serializable['publicvisible'] = @public_visible
29
- serializable
30
- end
31
-
32
- def plural_name
33
- 'partnerships'
34
- end
35
-
36
- protected
37
-
38
- def invalidate_uri
39
- unless @proposer.nil? or @proposed.nil?
40
- @uri = "#{resource_base_uri}#{@proposer.username};#{@proposed.username}/"
41
- end
42
- end
43
- end
44
- end
@@ -1,73 +0,0 @@
1
- #require 'cybercoach/abstract_resource'
2
-
3
- module CyberCoach
4
- class Resource < AbstractResource
5
- attr_accessor :id
6
-
7
- def self.read_all
8
- page = ResourcePage.new(self)
9
- page.read()
10
- page
11
- end
12
-
13
- def create(options={})
14
- invalidate_uri
15
- invalidate_options
16
- options = @options.merge(options).merge({
17
- body: serialize
18
- })
19
- if @uri.nil? or @uri.empty?
20
- response = self.class.post(self.class.resource_base_uri, options)
21
- if response.success?
22
- @uri = response.headers['location']
23
- else
24
- raise HttpError.new(response.response)
25
- end
26
- else
27
- response = self.class.put(@uri, options)
28
- if response.success?
29
- from_serializable(response)
30
- else
31
- raise HttpError.new(response.response)
32
- end
33
- end
34
- end
35
-
36
- def update(options={})
37
- invalidate_uri
38
- invalidate_options
39
- options = @options.merge(options).merge({
40
- body: serialize
41
- })
42
- response = self.class.put(@uri, options)
43
- if response.success?
44
- from_serializable(response)
45
- else
46
- raise HttpError.new(response.response)
47
- end
48
- end
49
-
50
- def delete(options={})
51
- invalidate_uri
52
- invalidate_options
53
- options = @options.merge(options)
54
- response = self.class.delete(@uri, options)
55
- if response.success?
56
- from_serializable(response)
57
- else
58
- raise HttpError.new(response.response)
59
- end
60
- end
61
-
62
- def from_serializable(serializable)
63
- super(serializable)
64
- @id = serializable['id']
65
- end
66
-
67
- def to_serializable()
68
- serializable = super()
69
- serializable['id'] = @id
70
- serializable
71
- end
72
- end
73
- end
@@ -1,88 +0,0 @@
1
- require 'cybercoach/abstract_resource'
2
-
3
- module CyberCoach
4
- class ResourcePage < AbstractResource
5
- class NoNextPageError < StandardError
6
- end
7
-
8
- class NoPreviousPageError < StandardError
9
- end
10
-
11
- attr_accessor :start, :end, :size, :available, :type, :items
12
-
13
- def initialize(type)
14
- super()
15
- @type = type
16
- end
17
-
18
- def next(options={})
19
- if @next.nil?
20
- raise NoNextPageError.new
21
- end
22
- invalidate_options
23
- options = @options.merge(options)
24
- response = self.class.get(@next['href'], options)
25
- if response.success?
26
- page = self.class.new(@type)
27
- page.from_serializable(response)
28
- page
29
- else
30
- raise HttpError.new(response.response)
31
- end
32
- end
33
-
34
- def previous(options={})
35
- if @previous.nil?
36
- raise NoPreviousPageError.new
37
- end
38
- invalidate_options
39
- options = @options.merge(options)
40
- response = self.class.get(@previous['href'], options)
41
- if response.success?
42
- page = self.class.new(@type)
43
- page.from_serializable(response)
44
- page
45
- else
46
- raise HttpError.new(response.response)
47
- end
48
- end
49
-
50
- def from_serializable(serializable)
51
- super(serializable)
52
- @start = serializable['start']
53
- @end = serializable['end']
54
- @size = serializable['size']
55
- @available = serializable['available']
56
- if serializable['links'].nil?
57
- @next = nil
58
- @previous = nil
59
- else
60
- @next = serializable['links'].detect { |link| link['description'] == 'next' }
61
- @previous = serializable['links'].detect { |link| link['description'] == 'previous' }
62
- end
63
- resource = @type.new
64
- @items = serializable[resource.plural_name].collect do |item_serializable|
65
- item = @type.new()
66
- item.from_serializable(item_serializable)
67
- item
68
- end
69
- end
70
-
71
- def plural_name
72
- @type.new.plural_name
73
- end
74
-
75
- protected
76
-
77
- def invalidate_uri
78
- query = ''
79
- unless @start.nil?
80
- query = "#{query}start=#{@start}&"
81
- end
82
- unless @size.nil?
83
- query = "#{query}size=#{@size}&"
84
- end
85
- @uri = "#{resource_base_uri}?#{query}"
86
- end
87
- end
88
- end
@@ -1,6 +0,0 @@
1
- module CyberCoach
2
- class Settings
3
- SERVER_URI = 'diufvm31.unifr.ch:8090'
4
- BASE_URI = '/CyberCoachServer/resources'
5
- end
6
- end
@@ -1,30 +0,0 @@
1
- module CyberCoach
2
- class Sport < Resource
3
- attr_accessor :name, :description
4
-
5
- def from_serializable(serializable)
6
- super(serializable)
7
- @name = serializable['name']
8
- @description = serializable['description']
9
- end
10
-
11
- def to_serializable()
12
- serializable = super()
13
- serializable['name'] = @name
14
- serializable['description'] = @description
15
- serializable
16
- end
17
-
18
- def plural_name
19
- 'sports'
20
- end
21
-
22
- protected
23
-
24
- def invalidate_uri
25
- unless @name.nil?
26
- @uri = "#{resource_base_uri}#{@name}/"
27
- end
28
- end
29
- end
30
- end
@@ -1,48 +0,0 @@
1
- require 'cybercoach/resource'
2
- require 'cybercoach/http_error'
3
-
4
- module CyberCoach
5
- class User < CyberCoach::Resource
6
- attr_accessor :username, :email, :password, :public_visible, :real_name
7
-
8
- def from_serializable(serializable)
9
- super(serializable)
10
- @username = serializable['username']
11
- @email = serializable['email']
12
- # the password is never received from the server, so don't set it
13
- @public_visible = serializable['publicvisible']
14
- @real_name = serializable['realname']
15
- end
16
-
17
- def to_serializable()
18
- serializable = super()
19
- serializable['username'] = @username
20
- serializable['email'] = @email
21
- serializable['password'] = @password
22
- serializable['publicvisible'] = @public_visible
23
- serializable['realname'] = @real_name
24
- serializable
25
- end
26
-
27
- def plural_name
28
- 'users'
29
- end
30
-
31
- protected
32
-
33
- def invalidate_uri
34
- unless @username.nil?
35
- @uri = "#{resource_base_uri}#{@username}/"
36
- end
37
- end
38
-
39
- def invalidate_options
40
- @options = @options.merge({
41
- :basic_auth => {
42
- :username => @username,
43
- :password => @password
44
- }
45
- })
46
- end
47
- end
48
- end
@@ -1,3 +0,0 @@
1
- module Cybercoach
2
- VERSION = "0.1.0"
3
- end
data/lib/cybercoach.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'cybercoach/version'
2
- require 'cybercoach/settings'
3
- require 'cybercoach/resource_page'
4
- require 'cybercoach/user'
5
- require 'cybercoach/sport'
6
- require 'cybercoach/partnership'
7
-
8
-
9
- module CyberCoach
10
- end
@@ -1,284 +0,0 @@
1
- require 'rspec'
2
- require 'pry'
3
-
4
- require 'cybercoach'
5
- require 'cybercoach/resource_page'
6
- require 'cybercoach/user'
7
- require 'cybercoach/sport'
8
-
9
- describe 'CyberCoach' do
10
- it 'should have a base URI' do
11
- expect(CyberCoach::Settings::BASE_URI).not_to be_nil
12
- end
13
- it 'should have a server URI' do
14
- expect(CyberCoach::Settings::SERVER_URI).not_to be_nil
15
- end
16
-
17
- describe 'ResourcePage' do
18
- before(:example) do
19
- @page = CyberCoach::User.read_all()
20
- end
21
-
22
- it 'should have meta data', focus:true do
23
- expect(@page.items.size).to eq(5)
24
- expect(@page.start).to eq(0)
25
- expect(@page.end).to eq(5)
26
- expect(@page.available).to be > 5
27
- expect(@page.type).to eq(CyberCoach::User)
28
- end
29
-
30
- it 'should have items of its type' do
31
- type = @page.type
32
- @page.items.each do |item|
33
- expect(item).to be_a_kind_of(type)
34
- end
35
- end
36
-
37
- it 'should read itself' do
38
- @page.start = 1
39
- @page.size = 2
40
- @page.read
41
- expect(@page.items.size).to eq(2)
42
- expect(@page.start).to eq(1)
43
- expect(@page.end).to eq(3)
44
- end
45
-
46
- it 'should be able to navigate between pages' do
47
- expect{@page.previous}.to raise_error(CyberCoach::ResourcePage::NoPreviousPageError)
48
- next_page = @page.next
49
- expect(next_page.items).not_to be_empty
50
- expect(next_page.start).to eq(@page.end)
51
- expect(next_page.end).to eq(next_page.start + 5)
52
- expect(next_page.available).to eq(@page.available)
53
- expect(next_page.type).to eq(@page.type)
54
- expect(next_page.items[0].uri).not_to eq(@page.items[0].uri)
55
- next_previous_page = next_page.previous
56
- expect(next_previous_page.items[0].uri).to eq(@page.items[0].uri)
57
- end
58
- end
59
-
60
- describe 'Sport' do
61
- before(:example) do
62
- @sport = CyberCoach::Sport.new()
63
- end
64
-
65
- it 'should read itself' do
66
- @sport.name = 'Running'
67
- @sport.read
68
- expect(@sport.id).not_to be_nil
69
- expect(@sport.uri).not_to be_nil
70
- expect(@sport.name).not_to be_nil
71
- expect(@sport.description).not_to be_nil
72
- end
73
-
74
- it 'should raise an error if it does not exist' do
75
- @sport.name = 'Pants'
76
- expect{@sport.read}.to raise_error(CyberCoach::HttpError)
77
- end
78
-
79
- it 'should read all' do
80
- sports = CyberCoach::Sport.read_all()
81
- expect(sports.items.size).to eq(4)
82
- expect{sports.next}.to raise_error(CyberCoach::ResourcePage::NoNextPageError)
83
- expect{sports.previous}.to raise_error(CyberCoach::ResourcePage::NoPreviousPageError)
84
- end
85
- end
86
-
87
- describe 'User' do
88
- before(:example) do
89
- @user = CyberCoach::User.new()
90
- end
91
-
92
- it 'should raise an error if it does not exist' do
93
- @user.username = 'gnirloff'
94
- expect{@user.read}.to raise_error(CyberCoach::HttpError)
95
- end
96
-
97
- it 'should read all' do
98
- users = CyberCoach::User.read_all()
99
- expect(users.items.size).to eq(5)
100
- expect(users.next).not_to be_nil
101
- expect{users.previous}.to raise_error(CyberCoach::ResourcePage::NoPreviousPageError)
102
- end
103
-
104
- describe 'crud' do
105
- before(:example) do
106
- @user.username = 'newyorkfalconstest1'
107
- @user.password = 'fancypants'
108
- @user.email = 'newyorkfalconstest1@newyorkfalcons.ch'
109
- @user.public_visible = 1
110
- @user.real_name = 'New York Falcons Test 1'
111
- begin
112
- @user.delete
113
- rescue CyberCoach::HttpError => error
114
- # don't care
115
- end
116
- end
117
-
118
- after(:example) do
119
- begin
120
- @user.delete
121
- rescue CyberCoach::HttpError => error
122
- # don't care
123
- end
124
- end
125
-
126
- it 'should create itself without nilling the password' do
127
- old_uri = @user.uri
128
- old_password = @user.password
129
- @user.create
130
- expect(@user.uri).to eq(old_uri)
131
- expect(@user.password).to eq(old_password)
132
- end
133
-
134
- it 'should read itself without nilling the password' do
135
- old_password = @user.password
136
- @user.create
137
- @user.read
138
- # users do not have an id
139
- expect(@user.id).to be_nil
140
- expect(@user.uri).not_to be_nil
141
- expect(@user.username).not_to be_nil
142
- expect(@user.email).not_to be_nil
143
- expect(@user.password).to eq(old_password)
144
- expect(@user.public_visible).not_to be_nil
145
- expect(@user.real_name).not_to be_nil
146
- end
147
-
148
- it 'should update itself without nilling the password' do
149
- @user.create
150
- old_password = @user.password
151
- old_real_name = @user.real_name
152
- new_real_name = 'habakuck'
153
- @user.real_name = new_real_name
154
- @user.update
155
- expect(@user.password).to eq(old_password)
156
- expect(@user.real_name).not_to eq(old_real_name)
157
- expect(@user.real_name).to eq(new_real_name)
158
- end
159
-
160
- it 'should delete itself' do
161
- @user.create
162
- @user.delete
163
- expect{@user.read}.to raise_error(CyberCoach::HttpError)
164
- end
165
- end
166
- end
167
-
168
- describe 'Partnership' do
169
- before(:context) do
170
- @proposer = CyberCoach::User.new()
171
- @proposer.username = 'newyorkfalconstest1'
172
- @proposer.password = 'fancypants'
173
- @proposer.email = 'newyorkfalconstest1@newyorkfalcons.ch'
174
- @proposer.public_visible = 1
175
- @proposer.real_name = 'New York Falcons Test 1'
176
- @proposed = CyberCoach::User.new()
177
- @proposed.username = 'newyorkfalconstest2'
178
- @proposed.password = 'fancypants'
179
- @proposed.email = 'newyorkfalconstest2@newyorkfalcons.ch'
180
- @proposed.public_visible = 1
181
- @proposed.real_name = 'New York Falcons Test 2'
182
- begin
183
- @proposer.delete
184
- rescue CyberCoach::HttpError => error
185
- # don't care
186
- end
187
- begin
188
- @proposed.delete
189
- rescue CyberCoach::HttpError => error
190
- # don't care
191
- end
192
- @proposer.create
193
- @proposed.create
194
- @options = {
195
- :basic_auth => {
196
- :username => @proposer.username,
197
- :password => @proposer.password
198
- }
199
- }
200
- end
201
-
202
- after(:context) do
203
- begin
204
- @proposer.delete
205
- rescue CyberCoach::HttpError => error
206
- # don't care
207
- end
208
- begin
209
- @proposed.delete
210
- rescue CyberCoach::HttpError => error
211
- # don't care
212
- end
213
- end
214
-
215
- before(:example) do
216
- @partnership = CyberCoach::Partnership.new
217
- @partnership.proposer = @proposer
218
- @partnership.proposed = @proposed
219
- @partnership.public_visible = 1
220
- end
221
-
222
- it 'should raise an error if it does not exist' do
223
- expect{@partnership.read(@options)}.to raise_error(CyberCoach::HttpError)
224
- end
225
-
226
- it 'should read all' do
227
- partnerships = CyberCoach::Partnership.read_all()
228
- expect(partnerships.items).not_to be_empty
229
- expect(partnerships.next).not_to be_nil
230
- expect{partnerships.previous}.to raise_error(CyberCoach::ResourcePage::NoPreviousPageError)
231
- end
232
-
233
- describe 'crud' do
234
- before(:example) do
235
- begin
236
- @partnership.delete(@options)
237
- rescue CyberCoach::HttpError => error
238
- # don't care
239
- end
240
- end
241
-
242
- after(:example) do
243
- begin
244
- @partnership.delete(@options)
245
- rescue CyberCoach::HttpError => error
246
- # don't care
247
- end
248
- end
249
-
250
- it 'should create itself' do
251
- @partnership.create(@options)
252
- expect(@partnership.id).not_to be_nil
253
- end
254
-
255
- it 'should read itself' do
256
- @partnership.create(@options)
257
- @partnership.read(@options)
258
- expect(@partnership.id).not_to be_nil
259
- expect(@partnership.uri).not_to be_nil
260
- expect(@partnership.proposer.username).to eq(@proposer.username)
261
- expect(@partnership.proposed.username).to eq(@proposed.username)
262
- expect(@partnership.confirmed_by_proposer).to be_truthy
263
- expect(@partnership.confirmed_by_proposed).to be_falsy
264
- expect(@partnership.public_visible).not_to be_nil
265
- end
266
-
267
- it 'should update itself' do
268
- @partnership.create(@options)
269
- old_public_visible = @partnership.public_visible
270
- new_public_visible = 2
271
- @partnership.public_visible = new_public_visible
272
- @partnership.update(@options)
273
- expect(@partnership.public_visible).not_to eq(old_public_visible)
274
- expect(@partnership.public_visible).to eq(new_public_visible)
275
- end
276
-
277
- it 'should delete itself' do
278
- @partnership.create(@options)
279
- @partnership.delete(@options)
280
- expect{@partnership.read}.to raise_error(CyberCoach::HttpError)
281
- end
282
- end
283
- end
284
- end
data/spec/spec_helper.rb DELETED
@@ -1,11 +0,0 @@
1
- require 'bundler/setup'
2
- Bundler.setup
3
-
4
- require 'simplecov'
5
- require 'cybercoach'
6
-
7
- SimpleCov.start
8
-
9
- RSpec.configure do |config|
10
- config.filter_run :focus => true
11
- end