rspec_candy 0.2.10 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -3
- data/README.md +7 -0
- data/lib/rspec_candy/helpers/rails/it_should_run_callbacks.rb +5 -4
- data/lib/rspec_candy/version.rb +1 -1
- data/spec/rspec1/Gemfile.lock +74 -0
- data/spec/rspec2/Gemfile.lock +137 -0
- data/spec/shared/app_root/app/models/state_machine_model.rb +23 -0
- data/spec/shared/rspec_candy/helpers/rails/it_should_run_callbacks_spec.rb +16 -0
- metadata +7 -5
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -145,6 +145,13 @@ If you only care about the matchers or helpers you can also more specifically re
|
|
145
145
|
it_should_run_callbacks :notify_this, :notify_that
|
146
146
|
end
|
147
147
|
|
148
|
+
|
149
|
+
If you have used a custom state machine name, you can use specify it like this:
|
150
|
+
|
151
|
+
describe Model, '#my_event on :my_machine from :my_state1 to :my_state" do
|
152
|
+
it_should_run_callbacks :notify_this, :notify_that
|
153
|
+
end
|
154
|
+
|
148
155
|
**it_should_run_callbacks_in_order**
|
149
156
|
|
150
157
|
Like `it_should_run_callbacks`, but also checks the correct order.
|
@@ -88,11 +88,12 @@ module RSpecCandy
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def run_state_machine_callbacks_from_prose(prose)
|
91
|
-
if parts = prose.match(/^(#\w+) from ([\:\w]+) to ([\:\w]+)$/)
|
91
|
+
if parts = prose.match(/^(#\w+) (?:on ([\:\w]+) )?from ([\:\w]+) to ([\:\w]+)$/)
|
92
92
|
name = parts[1].sub(/^#/, '').to_sym
|
93
|
-
|
94
|
-
|
95
|
-
|
93
|
+
machine_name = parts[2] ? parts[2].sub(/^:/, '').to_sym : :state
|
94
|
+
from = parts[3].sub(/^:/, '').to_sym
|
95
|
+
to = parts[4].sub(/^:/, '').to_sym
|
96
|
+
transition = StateMachine::Transition.new(subject, subject.class.state_machine(machine_name), name, from, to)
|
96
97
|
transition.run_callbacks
|
97
98
|
end
|
98
99
|
end
|
data/lib/rspec_candy/version.rb
CHANGED
@@ -0,0 +1,74 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../..
|
3
|
+
specs:
|
4
|
+
rspec_candy (0.3.0)
|
5
|
+
rspec
|
6
|
+
sneaky-save
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (2.3.18)
|
12
|
+
actionpack (= 2.3.18)
|
13
|
+
actionpack (2.3.18)
|
14
|
+
activesupport (= 2.3.18)
|
15
|
+
rack (~> 1.1.0)
|
16
|
+
activerecord (2.3.18)
|
17
|
+
activesupport (= 2.3.18)
|
18
|
+
activeresource (2.3.18)
|
19
|
+
activesupport (= 2.3.18)
|
20
|
+
activesupport (2.3.18)
|
21
|
+
columnize (0.3.6)
|
22
|
+
debugger (1.6.1)
|
23
|
+
columnize (>= 0.3.1)
|
24
|
+
debugger-linecache (~> 1.2.0)
|
25
|
+
debugger-ruby_core_source (~> 1.2.3)
|
26
|
+
debugger-linecache (1.2.0)
|
27
|
+
debugger-ruby_core_source (1.2.3)
|
28
|
+
has_defaults (0.4.1)
|
29
|
+
activerecord
|
30
|
+
hoe (2.8.0)
|
31
|
+
rake (>= 0.8.7)
|
32
|
+
linecache (0.46)
|
33
|
+
rbx-require-relative (> 0.0.4)
|
34
|
+
rack (1.1.6)
|
35
|
+
rails (2.3.18)
|
36
|
+
actionmailer (= 2.3.18)
|
37
|
+
actionpack (= 2.3.18)
|
38
|
+
activerecord (= 2.3.18)
|
39
|
+
activeresource (= 2.3.18)
|
40
|
+
activesupport (= 2.3.18)
|
41
|
+
rake (>= 0.8.3)
|
42
|
+
rake (10.1.0)
|
43
|
+
rbx-require-relative (0.0.9)
|
44
|
+
rspec (1.3.2)
|
45
|
+
rspec-rails (1.3.4)
|
46
|
+
rack (>= 1.0.0)
|
47
|
+
rspec (~> 1.3.1)
|
48
|
+
ruby-debug (0.10.4)
|
49
|
+
columnize (>= 0.1)
|
50
|
+
ruby-debug-base (~> 0.10.4.0)
|
51
|
+
ruby-debug-base (0.10.4)
|
52
|
+
linecache (>= 0.3)
|
53
|
+
sneaky-save (0.0.2)
|
54
|
+
activerecord (>= 2.3.2)
|
55
|
+
sqlite3 (1.3.8)
|
56
|
+
state_machine (1.2.0)
|
57
|
+
test-unit (1.2.3)
|
58
|
+
hoe (>= 1.5.1)
|
59
|
+
|
60
|
+
PLATFORMS
|
61
|
+
ruby
|
62
|
+
|
63
|
+
DEPENDENCIES
|
64
|
+
debugger
|
65
|
+
has_defaults
|
66
|
+
hoe (= 2.8.0)
|
67
|
+
rails (~> 2)
|
68
|
+
rspec (~> 1)
|
69
|
+
rspec-rails (~> 1)
|
70
|
+
rspec_candy!
|
71
|
+
ruby-debug
|
72
|
+
sqlite3
|
73
|
+
state_machine
|
74
|
+
test-unit (~> 1.2)
|
@@ -0,0 +1,137 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../..
|
3
|
+
specs:
|
4
|
+
rspec_candy (0.3.0)
|
5
|
+
rspec
|
6
|
+
sneaky-save
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (3.2.14)
|
12
|
+
actionpack (= 3.2.14)
|
13
|
+
mail (~> 2.5.4)
|
14
|
+
actionpack (3.2.14)
|
15
|
+
activemodel (= 3.2.14)
|
16
|
+
activesupport (= 3.2.14)
|
17
|
+
builder (~> 3.0.0)
|
18
|
+
erubis (~> 2.7.0)
|
19
|
+
journey (~> 1.0.4)
|
20
|
+
rack (~> 1.4.5)
|
21
|
+
rack-cache (~> 1.2)
|
22
|
+
rack-test (~> 0.6.1)
|
23
|
+
sprockets (~> 2.2.1)
|
24
|
+
activemodel (3.2.14)
|
25
|
+
activesupport (= 3.2.14)
|
26
|
+
builder (~> 3.0.0)
|
27
|
+
activerecord (3.2.14)
|
28
|
+
activemodel (= 3.2.14)
|
29
|
+
activesupport (= 3.2.14)
|
30
|
+
arel (~> 3.0.2)
|
31
|
+
tzinfo (~> 0.3.29)
|
32
|
+
activeresource (3.2.14)
|
33
|
+
activemodel (= 3.2.14)
|
34
|
+
activesupport (= 3.2.14)
|
35
|
+
activesupport (3.2.14)
|
36
|
+
i18n (~> 0.6, >= 0.6.4)
|
37
|
+
multi_json (~> 1.0)
|
38
|
+
arel (3.0.2)
|
39
|
+
builder (3.0.4)
|
40
|
+
columnize (0.3.6)
|
41
|
+
debugger (1.6.1)
|
42
|
+
columnize (>= 0.3.1)
|
43
|
+
debugger-linecache (~> 1.2.0)
|
44
|
+
debugger-ruby_core_source (~> 1.2.3)
|
45
|
+
debugger-linecache (1.2.0)
|
46
|
+
debugger-ruby_core_source (1.2.3)
|
47
|
+
diff-lcs (1.2.4)
|
48
|
+
erubis (2.7.0)
|
49
|
+
has_defaults (0.4.1)
|
50
|
+
activerecord
|
51
|
+
hike (1.2.3)
|
52
|
+
i18n (0.6.5)
|
53
|
+
journey (1.0.4)
|
54
|
+
json (1.8.0)
|
55
|
+
linecache (0.46)
|
56
|
+
rbx-require-relative (> 0.0.4)
|
57
|
+
mail (2.5.4)
|
58
|
+
mime-types (~> 1.16)
|
59
|
+
treetop (~> 1.4.8)
|
60
|
+
mime-types (1.24)
|
61
|
+
multi_json (1.7.9)
|
62
|
+
polyglot (0.3.3)
|
63
|
+
rack (1.4.5)
|
64
|
+
rack-cache (1.2)
|
65
|
+
rack (>= 0.4)
|
66
|
+
rack-ssl (1.3.3)
|
67
|
+
rack
|
68
|
+
rack-test (0.6.2)
|
69
|
+
rack (>= 1.0)
|
70
|
+
rails (3.2.14)
|
71
|
+
actionmailer (= 3.2.14)
|
72
|
+
actionpack (= 3.2.14)
|
73
|
+
activerecord (= 3.2.14)
|
74
|
+
activeresource (= 3.2.14)
|
75
|
+
activesupport (= 3.2.14)
|
76
|
+
bundler (~> 1.0)
|
77
|
+
railties (= 3.2.14)
|
78
|
+
railties (3.2.14)
|
79
|
+
actionpack (= 3.2.14)
|
80
|
+
activesupport (= 3.2.14)
|
81
|
+
rack-ssl (~> 1.3.2)
|
82
|
+
rake (>= 0.8.7)
|
83
|
+
rdoc (~> 3.4)
|
84
|
+
thor (>= 0.14.6, < 2.0)
|
85
|
+
rake (10.1.0)
|
86
|
+
rbx-require-relative (0.0.9)
|
87
|
+
rdoc (3.12.2)
|
88
|
+
json (~> 1.4)
|
89
|
+
rspec (2.14.1)
|
90
|
+
rspec-core (~> 2.14.0)
|
91
|
+
rspec-expectations (~> 2.14.0)
|
92
|
+
rspec-mocks (~> 2.14.0)
|
93
|
+
rspec-core (2.14.5)
|
94
|
+
rspec-expectations (2.14.2)
|
95
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
96
|
+
rspec-mocks (2.14.3)
|
97
|
+
rspec-rails (2.14.0)
|
98
|
+
actionpack (>= 3.0)
|
99
|
+
activesupport (>= 3.0)
|
100
|
+
railties (>= 3.0)
|
101
|
+
rspec-core (~> 2.14.0)
|
102
|
+
rspec-expectations (~> 2.14.0)
|
103
|
+
rspec-mocks (~> 2.14.0)
|
104
|
+
ruby-debug (0.10.4)
|
105
|
+
columnize (>= 0.1)
|
106
|
+
ruby-debug-base (~> 0.10.4.0)
|
107
|
+
ruby-debug-base (0.10.4)
|
108
|
+
linecache (>= 0.3)
|
109
|
+
sneaky-save (0.0.4)
|
110
|
+
activerecord (>= 3.2.0)
|
111
|
+
sprockets (2.2.2)
|
112
|
+
hike (~> 1.2)
|
113
|
+
multi_json (~> 1.0)
|
114
|
+
rack (~> 1.0)
|
115
|
+
tilt (~> 1.1, != 1.3.0)
|
116
|
+
sqlite3 (1.3.8)
|
117
|
+
state_machine (1.2.0)
|
118
|
+
thor (0.18.1)
|
119
|
+
tilt (1.4.1)
|
120
|
+
treetop (1.4.15)
|
121
|
+
polyglot
|
122
|
+
polyglot (>= 0.3.1)
|
123
|
+
tzinfo (0.3.37)
|
124
|
+
|
125
|
+
PLATFORMS
|
126
|
+
ruby
|
127
|
+
|
128
|
+
DEPENDENCIES
|
129
|
+
debugger
|
130
|
+
has_defaults
|
131
|
+
rails (~> 3)
|
132
|
+
rspec (~> 2)
|
133
|
+
rspec-rails (~> 2)
|
134
|
+
rspec_candy!
|
135
|
+
ruby-debug
|
136
|
+
sqlite3
|
137
|
+
state_machine
|
@@ -22,9 +22,32 @@ class StateMachineModel < ActiveRecord::Base
|
|
22
22
|
|
23
23
|
end
|
24
24
|
|
25
|
+
state_machine :custom_state, :initial => :state1 do
|
26
|
+
|
27
|
+
state :state1
|
28
|
+
|
29
|
+
state :state2
|
30
|
+
|
31
|
+
state :state3
|
32
|
+
|
33
|
+
event :event do
|
34
|
+
transition :state1 => :state2
|
35
|
+
end
|
36
|
+
|
37
|
+
event :another_event do
|
38
|
+
transition :state1 => :state3
|
39
|
+
end
|
40
|
+
|
41
|
+
after_transition :state1 => :state2, :do => :custom_state_event_callback
|
42
|
+
|
43
|
+
end
|
44
|
+
|
25
45
|
def event_callback
|
26
46
|
end
|
27
47
|
|
48
|
+
def custom_state_event_callback
|
49
|
+
end
|
50
|
+
|
28
51
|
end
|
29
52
|
|
30
53
|
end
|
@@ -95,6 +95,22 @@ describe RSpecCandy::Helpers::Rails::ItShouldRunCallbacks do
|
|
95
95
|
describe_block
|
96
96
|
end
|
97
97
|
|
98
|
+
it 'should also run state machine callbacks for a state machine with a custom name and pass if they are called if StateMachine is present' do
|
99
|
+
<<-describe_block.should pass_as_describe_block
|
100
|
+
describe StateMachineModel, '#event on :custom_state from :state1 to :state2' do
|
101
|
+
it_should_run_callbacks :custom_state_event_callback
|
102
|
+
end
|
103
|
+
describe_block
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should also run state machine callbacks for a state machine with a custom name and fail if they are not called if StateMachine is present' do
|
107
|
+
<<-describe_block.should fail_as_describe_block
|
108
|
+
describe StateMachineModel, '#event on :custom_state from :state1 to :state3' do
|
109
|
+
it_should_run_callbacks :custom_state_event_callback
|
110
|
+
end
|
111
|
+
describe_block
|
112
|
+
end
|
113
|
+
|
98
114
|
end
|
99
115
|
|
100
116
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_candy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Henning Koch
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2013-
|
19
|
+
date: 2013-08-30 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- lib/rspec_candy/version.rb
|
85
85
|
- rspec_candy.gemspec
|
86
86
|
- spec/rspec1/Gemfile
|
87
|
+
- spec/rspec1/Gemfile.lock
|
87
88
|
- spec/rspec1/Rakefile
|
88
89
|
- spec/rspec1/app_root/config/boot.rb
|
89
90
|
- spec/rspec1/app_root/config/database.yml
|
@@ -98,6 +99,7 @@ files:
|
|
98
99
|
- spec/rspec1/spec/switcher_spec.rb
|
99
100
|
- spec/rspec2/.rspec
|
100
101
|
- spec/rspec2/Gemfile
|
102
|
+
- spec/rspec2/Gemfile.lock
|
101
103
|
- spec/rspec2/Rakefile
|
102
104
|
- spec/rspec2/app_root/.gitignore
|
103
105
|
- spec/rspec2/app_root/config/application.rb
|