role_playing 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/lib/role_playing.rb +2 -1
- data/lib/role_playing/version.rb +1 -1
- data/role_playing.gemspec +1 -1
- data/spec/role_playing/role_playing_spec.rb +21 -21
- data/spec/spec_helper.rb +0 -6
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc74978c9985f1142bd3444a4d139e704140e54d
|
4
|
+
data.tar.gz: f885fb34c5abb5a854cc7b5c8ce06a02901b77bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ab1fef9d6becafeba82880bac4cc200dfb76e8365dedc5d7546b7dea8a710301f43bf4210c82843013719f6211dd221e8053c073226d420f376a8b9de387a10
|
7
|
+
data.tar.gz: 53cf26da5412beb79b391c0ac2fb4ab3aed8e830354a5f5689b394c429549c8a48ba9622a8a60971a3d9a6b55f12a6e5ba59da491721805a58e4fbfefe126a9b
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/lib/role_playing.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
require "active_support"
|
1
2
|
require "active_support/core_ext"
|
2
3
|
require "role_playing/version"
|
3
4
|
require "role_playing/core_ext"
|
4
5
|
require "role_playing/context"
|
5
6
|
require "role_playing/role"
|
6
|
-
require 'role_playing/railtie' if defined?(Rails)
|
7
|
+
require 'role_playing/railtie' if defined?(Rails)
|
data/lib/role_playing/version.rb
CHANGED
data/role_playing.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.add_development_dependency("rspec", ">=
|
20
|
+
gem.add_development_dependency("rspec", ">= 3.0")
|
21
21
|
gem.add_development_dependency("bundler")
|
22
22
|
|
23
23
|
gem.add_dependency("activesupport", ">= 3.0.0")
|
@@ -59,30 +59,30 @@ describe RolePlaying do
|
|
59
59
|
subject { MyRole.new(bare_object) }
|
60
60
|
|
61
61
|
it "should be of same class as wrapped object" do
|
62
|
-
subject.class.
|
62
|
+
expect(subject.class).to eq bare_object.class
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should be equal to wrapped object" do
|
66
|
-
subject.
|
66
|
+
expect(subject).to eq bare_object
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should respond_to additional methods" do
|
70
|
-
subject.
|
70
|
+
expect(subject).to respond_to(:two_fields)
|
71
71
|
end
|
72
72
|
|
73
73
|
it "#two_fields should concatenate data objects two fields" do
|
74
|
-
subject.two_fields.
|
74
|
+
expect(subject.two_fields).to eq "#{bare_object.field_1} #{bare_object.field_2}"
|
75
75
|
end
|
76
76
|
|
77
77
|
it "#role_player should not respond_to additional methods" do
|
78
|
-
subject.role_player.
|
78
|
+
expect(subject.role_player).to_not respond_to(:two_fields)
|
79
79
|
end
|
80
80
|
|
81
81
|
it "#in_role takes a block and returns the result" do
|
82
82
|
two_fields = MyRole.played_by(bare_object) do |role|
|
83
83
|
role.two_fields
|
84
84
|
end
|
85
|
-
two_fields.
|
85
|
+
expect(two_fields).to eq "#{bare_object.field_1} #{bare_object.field_2}"
|
86
86
|
end
|
87
87
|
|
88
88
|
end
|
@@ -109,9 +109,9 @@ describe RolePlaying do
|
|
109
109
|
|
110
110
|
it "an array of roles can be applied using Array#played_by" do
|
111
111
|
role = [role_class_1, role_class_2].played_by(player_class.new)
|
112
|
-
role.
|
113
|
-
role.
|
114
|
-
role.
|
112
|
+
expect(role).to respond_to(:role_1)
|
113
|
+
expect(role).to respond_to(:role_2)
|
114
|
+
expect(role).to respond_to(:base)
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
@@ -122,13 +122,13 @@ describe RolePlaying do
|
|
122
122
|
let(:bare_account) {Account.new(original_amount)}
|
123
123
|
subject { MoneyTransferring::SourceAccount.new(bare_account) }
|
124
124
|
it "adds a withdraw method to data object" do
|
125
|
-
bare_account.
|
126
|
-
subject.
|
125
|
+
expect(bare_account).to_not respond_to(:withdraw)
|
126
|
+
expect(subject).to respond_to(:withdraw)
|
127
127
|
end
|
128
128
|
it "withdraws a specified amount" do
|
129
129
|
subject.withdraw(10)
|
130
|
-
subject.amount.
|
131
|
-
bare_account.amount.
|
130
|
+
expect(subject.amount).to eq original_amount-10
|
131
|
+
expect(bare_account.amount).to eq original_amount-10
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
@@ -137,13 +137,13 @@ describe RolePlaying do
|
|
137
137
|
let(:bare_account) {Account.new(original_amount)}
|
138
138
|
subject { MoneyTransferring::DestinationAccount.new(bare_account) }
|
139
139
|
it "adds a deposit method to data object" do
|
140
|
-
bare_account.
|
141
|
-
subject.
|
140
|
+
expect(bare_account).to_not respond_to(:deposit)
|
141
|
+
expect(subject).to respond_to(:deposit)
|
142
142
|
end
|
143
143
|
it "deposits a specified amount" do
|
144
144
|
subject.deposit(10)
|
145
|
-
subject.amount.
|
146
|
-
bare_account.amount.
|
145
|
+
expect(subject.amount).to eq original_amount+10
|
146
|
+
expect(bare_account.amount).to eq original_amount+10
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
@@ -155,11 +155,11 @@ describe RolePlaying do
|
|
155
155
|
subject { MoneyTransferring.new(source_account, destination_account) }
|
156
156
|
|
157
157
|
it "transfers a specified amount from a SourceAccount to a DestinationAccount" do
|
158
|
-
source_account.amount.
|
159
|
-
destination_account.amount.
|
158
|
+
expect(source_account.amount).to eq original_source_account_amount
|
159
|
+
expect(destination_account.amount).to eq original_destination_account_amount
|
160
160
|
subject.call(transfer_amount)
|
161
|
-
source_account.amount.
|
162
|
-
destination_account.amount.
|
161
|
+
expect(source_account.amount).to eq original_source_account_amount-transfer_amount
|
162
|
+
expect(destination_account.amount).to eq original_destination_account_amount+transfer_amount
|
163
163
|
end
|
164
164
|
|
165
165
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: role_playing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Axel Eriksson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '3.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,6 +60,7 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- .gitignore
|
63
|
+
- .rspec
|
63
64
|
- .travis.yml
|
64
65
|
- Gemfile
|
65
66
|
- LICENSE.txt
|
@@ -94,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
95
|
version: '0'
|
95
96
|
requirements: []
|
96
97
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.0.
|
98
|
+
rubygems_version: 2.0.14
|
98
99
|
signing_key:
|
99
100
|
specification_version: 4
|
100
101
|
summary: A ruby DCI implementation
|