rspec-active_record 0.4.0 → 0.5.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7554766e4cdb7debbfac3df8d43b4b2f211fa47fa848e518e3d0e2c5aec0df42
4
- data.tar.gz: 81925b6f2cd75bfde8d747ae62d4b1365af0ec580063c520418f3fc61a556e0b
3
+ metadata.gz: a7a6ee8d2f8e4e3230227c54f7b6ac9484820e2d7316b7a286529f7b96fcf168
4
+ data.tar.gz: 7544437ce608ee8190a98631c3a9ac81839e9a137f598826383e90950e8d7ea8
5
5
  SHA512:
6
- metadata.gz: 4f927093f62c81b0403d035f6a49bd89620d5a4c9ecedb00f0a408adbee02f00a39b1f01df83875e4c26c5f22da50ac8930606df92a0af490fca9006864ed524
7
- data.tar.gz: 19962a9c8758128a346982c5927fbfb6bcd2f42e1f1b3d9ff058aaf58e659b40dc1b57962b185304730013ae12884b10bab9dc0d2258096c3cbd94f531486c14
6
+ metadata.gz: e6e48ae2fef14172a456daa012eea9eeb94f53ddabb54db89e5b469f6d51c68b55386374b58836358d311d1fb77353bbffc4768927123de75968882bf2ce2b4f
7
+ data.tar.gz: acdf577a588b6da64e5233ab0c875cbbc38d8896218f24ef2f298928c5697b4b5fb6271671910a32f1358c82e263600a30270b36a729afcf37e11c833bfcf613
data/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
1
  ## [Unreleased]
2
+ ## [0.5.0] - 2026-10-26
3
+
4
+ - Implement `change_record.attributes`, which allows shortening `change_record.from`.
2
5
 
3
6
  ## [0.4.0] - 2026-10-02
4
7
 
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in rspec-active_record.gemspec
6
6
  gemspec
7
7
 
8
+ gem "bump"
8
9
  gem "database_cleaner-active_record"
9
10
  gem "rake"
10
11
  gem "rspec"
data/README.md CHANGED
@@ -66,6 +66,14 @@ expect { user.update!(name: "RSpec User") }.to change_record(user).from(name: "I
66
66
  expect { user.name = "RSpec User" }.to not_change_record(user).from(name: "Initial Name")
67
67
  ```
68
68
 
69
+ Use `attributes` to take the initial values from the record, equivalent to
70
+ `from(name: user.name, id: user.id)`:
71
+ ```ruby
72
+ expect { user.update!(name: "RSpec User", email: "user@example.com") }
73
+ .to change_record(user).attributes(:name, :email)
74
+ expect { user.name = "RSpec User" }.to not_change_record(user).attributes(:name, :id)
75
+ ```
76
+
69
77
  ### destroy_record
70
78
 
71
79
  Check that code destroys a record:
@@ -18,6 +18,11 @@ module RSpec
18
18
  self
19
19
  end
20
20
 
21
+ # Use the record's current values as the initial attributes
22
+ def attributes(*names)
23
+ from(names.index_with { |name| @record.public_send(name) })
24
+ end
25
+
21
26
  def matches?(block)
22
27
  @from_diff = diff_unless_match(@record, @from)
23
28
  @to_pre_match = !not_match_attributes?(@record, @to)
@@ -60,7 +65,7 @@ module RSpec
60
65
  elsif @to_diff
61
66
  "expected to change #{format_record} to #{format_hash(@to)} but did not#{@to_diff}"
62
67
  else
63
- "please specify from or to for change_record"
68
+ "please specify attributes, from or to for change_record"
64
69
  end
65
70
  end
66
71
 
@@ -68,7 +73,7 @@ module RSpec
68
73
  if @to
69
74
  "negative matcher for change_record with to is not supported"
70
75
  elsif @from.blank?
71
- "negative matcher for change_record without from is not supported"
76
+ "negative matcher for change_record without attributes or from is not supported"
72
77
  elsif @from_diff
73
78
  "expected #{format_record} to match #{format_hash(@from)} initially but it did not#{@from_diff}"
74
79
  elsif !@from_post_match
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module ActiveRecord
5
- VERSION = "0.4.0"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrius Chamentauskas