digital_opera 0.0.7 → 0.0.8
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.
- data/MIT-LICENSE +1 -1
- data/Rakefile +7 -0
- data/lib/digital_opera/presenter/base.rb +4 -0
- data/lib/digital_opera/version.rb +1 -1
- data/spec/banker_spec.rb +35 -0
- data/spec/base_extensions/object_spec.rb +67 -0
- data/spec/presenter/base_spec.rb +35 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/support/base_presenter.rb +13 -0
- data/spec/support/user.rb +19 -0
- data/spec/token_spec.rb +11 -0
- metadata +37 -6
data/MIT-LICENSE
CHANGED
data/Rakefile
CHANGED
@@ -8,3 +8,10 @@ end
|
|
8
8
|
|
9
9
|
Bundler::GemHelper.install_tasks
|
10
10
|
|
11
|
+
require 'rspec/core/rake_task'
|
12
|
+
|
13
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
14
|
+
|
15
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
16
|
+
RSpec::Core::RakeTask.new
|
17
|
+
task :default => :spec
|
data/spec/banker_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'support/user'
|
3
|
+
|
4
|
+
describe DigitalOpera::Banker do
|
5
|
+
subject { User.new }
|
6
|
+
|
7
|
+
it{ should be_respond_to :money_in_account }
|
8
|
+
it{ should be_respond_to :money_in_account= }
|
9
|
+
it{ should be_respond_to :money_in_account_in_cents }
|
10
|
+
it{ should be_respond_to :money_in_account_in_cents= }
|
11
|
+
|
12
|
+
context 'from string' do
|
13
|
+
it 'should convert to cents' do
|
14
|
+
subject.money_in_account = '15.31'
|
15
|
+
subject.money_in_account_in_cents.should eq 1531
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should convert to cents' do
|
19
|
+
subject.money_in_account_in_cents = '1531'
|
20
|
+
subject.money_in_account.should eq '15.31'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'from int' do
|
25
|
+
it 'should convert to cents' do
|
26
|
+
subject.money_in_account = 15.31
|
27
|
+
subject.money_in_account_in_cents.should eq 1531
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should convert to cents' do
|
31
|
+
subject.money_in_account_in_cents = 1531
|
32
|
+
subject.money_in_account.should eq '15.31'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Object do
|
4
|
+
|
5
|
+
describe '#be_nil_or_zero?' do
|
6
|
+
|
7
|
+
context 'numbers' do
|
8
|
+
it 'should be false' do
|
9
|
+
(1.1).should_not be_nil_or_zero
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should be false' do
|
13
|
+
1.should_not be_nil_or_zero
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should be true' do
|
17
|
+
0.should be_nil_or_zero
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'string' do
|
22
|
+
it 'should be false' do
|
23
|
+
'boo'.should_not be_nil_or_zero
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should be false' do
|
27
|
+
''.should_not be_nil_or_zero
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'array' do
|
32
|
+
it 'should be false' do
|
33
|
+
[].should_not be_nil_or_zero
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should be false' do
|
37
|
+
[1,2,3].should_not be_nil_or_zero
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should be false' do
|
41
|
+
['12',2,3].should_not be_nil_or_zero
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should be false' do
|
45
|
+
[''].should_not be_nil_or_zero
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'hash' do
|
50
|
+
it 'should be false' do
|
51
|
+
{}.should_not be_nil_or_zero
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should be false' do
|
55
|
+
{foo: 'bar'}.should_not be_nil_or_zero
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'nil' do
|
60
|
+
it 'should be true' do
|
61
|
+
nil.should be_nil_or_zero
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'support/user'
|
3
|
+
require 'support/base_presenter'
|
4
|
+
require 'action_controller'
|
5
|
+
|
6
|
+
describe DigitalOpera::Presenter::Base do
|
7
|
+
let(:user) { User.new }
|
8
|
+
|
9
|
+
describe 'base class' do
|
10
|
+
subject{ DigitalOpera::Presenter::Base.new user }
|
11
|
+
|
12
|
+
its(:source) { should eq user }
|
13
|
+
its(:_h) { should be_respond_to :view_renderer }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'delegating to base class' do
|
17
|
+
subject{ BasePresenter.new user }
|
18
|
+
|
19
|
+
its(:family_name) { should eq 'Dido' }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'overridden methods' do
|
23
|
+
subject{ BasePresenter.new user }
|
24
|
+
|
25
|
+
its(:first_name){ should eq 'Jane' }
|
26
|
+
its(:last_name){ should eq 'Doe family' }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'new methods' do
|
30
|
+
subject{ BasePresenter.new user }
|
31
|
+
|
32
|
+
its(:role) { should eq 'administrator' }
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spork'
|
3
|
+
require 'active_support'
|
4
|
+
require 'digital_opera'
|
5
|
+
|
6
|
+
Spork.prefork do
|
7
|
+
ENV["RAILS_ENV"] ||= 'test'
|
8
|
+
require 'rspec'
|
9
|
+
require 'rspec/autorun'
|
10
|
+
require 'mocha/api'
|
11
|
+
|
12
|
+
# Configure RSpec ---------------------------------------
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.mock_with :mocha
|
15
|
+
|
16
|
+
# Run specs in random order to surface order dependencies. If you find an
|
17
|
+
# order dependency and want to debug it, you can fix the order by providing
|
18
|
+
# the seed, which is printed after each run.
|
19
|
+
# --seed 1234
|
20
|
+
config.order = "random"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
Spork.each_run do
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class User
|
2
|
+
# simulate fields
|
3
|
+
attr_accessor :money_in_account, :money_in_account_in_cents
|
4
|
+
|
5
|
+
include DigitalOpera::Banker
|
6
|
+
currency_fields :money_in_account
|
7
|
+
|
8
|
+
def first_name
|
9
|
+
'John'
|
10
|
+
end
|
11
|
+
|
12
|
+
def last_name
|
13
|
+
'Doe'
|
14
|
+
end
|
15
|
+
|
16
|
+
def family_name
|
17
|
+
'Dido'
|
18
|
+
end
|
19
|
+
end
|
data/spec/token_spec.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DigitalOpera::Token do
|
4
|
+
subject { DigitalOpera::Token.generate }
|
5
|
+
its(:length){ should eq 40 }
|
6
|
+
it{ should match /[0-9a-zA-Z]+/ }
|
7
|
+
|
8
|
+
it 'should change length' do
|
9
|
+
DigitalOpera::Token.generate(256).length.should eq 256
|
10
|
+
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: digital_opera
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-11-
|
13
|
+
date: 2013-11-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -28,6 +28,22 @@ dependencies:
|
|
28
28
|
- - ! '>='
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: 3.1.0
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: rake
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
31
47
|
- !ruby/object:Gem::Dependency
|
32
48
|
name: rspec
|
33
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,8 +139,16 @@ files:
|
|
123
139
|
- lib/digital_opera.rb
|
124
140
|
- MIT-LICENSE
|
125
141
|
- Rakefile
|
142
|
+
- spec/banker_spec.rb
|
143
|
+
- spec/base_extensions/object_spec.rb
|
144
|
+
- spec/presenter/base_spec.rb
|
145
|
+
- spec/spec_helper.rb
|
146
|
+
- spec/support/base_presenter.rb
|
147
|
+
- spec/support/user.rb
|
148
|
+
- spec/token_spec.rb
|
126
149
|
homepage: http://www.digitalopera.com/
|
127
|
-
licenses:
|
150
|
+
licenses:
|
151
|
+
- MIT
|
128
152
|
post_install_message:
|
129
153
|
rdoc_options: []
|
130
154
|
require_paths:
|
@@ -137,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
161
|
version: '0'
|
138
162
|
segments:
|
139
163
|
- 0
|
140
|
-
hash:
|
164
|
+
hash: 1294121815354848515
|
141
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
166
|
none: false
|
143
167
|
requirements:
|
@@ -146,11 +170,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
170
|
version: '0'
|
147
171
|
segments:
|
148
172
|
- 0
|
149
|
-
hash:
|
173
|
+
hash: 1294121815354848515
|
150
174
|
requirements: []
|
151
175
|
rubyforge_project:
|
152
176
|
rubygems_version: 1.8.23
|
153
177
|
signing_key:
|
154
178
|
specification_version: 3
|
155
179
|
summary: Tools and utilities for helping out in developing Ruby applications
|
156
|
-
test_files:
|
180
|
+
test_files:
|
181
|
+
- spec/banker_spec.rb
|
182
|
+
- spec/base_extensions/object_spec.rb
|
183
|
+
- spec/presenter/base_spec.rb
|
184
|
+
- spec/spec_helper.rb
|
185
|
+
- spec/support/base_presenter.rb
|
186
|
+
- spec/support/user.rb
|
187
|
+
- spec/token_spec.rb
|