shoulda_create 0.0.3 → 0.0.4
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/README.rdoc +3 -0
- data/lib/shoulda_create/shoulda_create.rb +2 -1
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -26,6 +26,9 @@ Some ideological dispute, I guess. I complained to one of the thoughtbot guys,
|
|
26
26
|
|
27
27
|
# ... or it can be a table name: (remember to pluralize)
|
28
28
|
should_create 'audits'
|
29
|
+
|
30
|
+
# the to can be a proc: (when using factories and ids are not known at context setup time)
|
31
|
+
should_change('the user group', :to => lambda{ @group.id }){ @user.reload.group_id }
|
29
32
|
end
|
30
33
|
|
31
34
|
== License
|
@@ -47,7 +47,7 @@ module ShouldaCreate
|
|
47
47
|
by, from, to = get_options!([options], :by, :from, :to)
|
48
48
|
stmt = "change #{description}"
|
49
49
|
stmt << " from #{from.inspect}" if from
|
50
|
-
stmt << " to #{to.inspect}" if to
|
50
|
+
stmt << " to #{to.inspect}" if to && !to.is_a?(Proc)
|
51
51
|
stmt << " by #{by.inspect}" if by
|
52
52
|
|
53
53
|
if block_given?
|
@@ -63,6 +63,7 @@ module ShouldaCreate
|
|
63
63
|
should stmt, :before => before do
|
64
64
|
old_value = self.instance_variable_get( before_var_name )
|
65
65
|
new_value = code.bind(self).call
|
66
|
+
to = to.bind(self).call if to.is_a?(Proc)
|
66
67
|
assert_operator from, :===, old_value, "#{description} did not originally match #{from.inspect}" if from
|
67
68
|
assert_not_equal old_value, new_value, "#{description} did not change" unless by == 0
|
68
69
|
assert_operator to, :===, new_value, "#{description} was not changed to match #{to.inspect}" if to
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoulda_create
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bill Kirtley
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-11-
|
18
|
+
date: 2012-11-16 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: I like using should_create and friends to make assertions about records coming and going in the database. Shoulda did, but doesn't any more. With this, it can again.
|