shoulda_create 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.
@@ -50,9 +50,9 @@ module ShouldaCreate
50
50
  def should_change(description, options = {}, &block)
51
51
  by, from, to = get_options!([options], :by, :from, :to)
52
52
  stmt = "change #{description}"
53
- stmt << " from #{from.inspect}" if from
53
+ stmt << " from #{from.inspect}" if from && !from.is_a?(Proc)
54
54
  stmt << " to #{to.inspect}" if to && !to.is_a?(Proc)
55
- stmt << " by #{by.inspect}" if by
55
+ stmt << " by #{by.inspect}" if by && !by.is_a?(Proc)
56
56
 
57
57
  if block_given?
58
58
  code = block
@@ -67,7 +67,9 @@ module ShouldaCreate
67
67
  should stmt, :before => before do
68
68
  old_value = self.instance_variable_get( before_var_name )
69
69
  new_value = code.bind(self).call
70
+ from = from.bind(self).call if from.is_a?(Proc)
70
71
  to = to.bind(self).call if to.is_a?(Proc)
72
+ by = by.bind(self).call if by.is_a?(Proc)
71
73
  assert_operator from, :===, old_value, "#{description} did not originally match #{from.inspect}" if from
72
74
  assert_not_equal old_value, new_value, "#{description} did not change" unless by == 0
73
75
  assert_operator to, :===, new_value, "#{description} was not changed to match #{to.inspect}" if to
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoulda_create
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-28 00:00:00.000000000 Z
12
+ date: 2015-09-09 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: I like using should_create and friends to make assertions about records
15
15
  coming and going in the database. Shoulda did, but doesn't any more. With this,