fixation 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ebf779f055287d6af43f1dc2fc1625a06186d9cb
4
- data.tar.gz: 8b77c04e6bfa3682a5662cc9833e5b34224b7c3e
3
+ metadata.gz: d7f04907bb50bacd416534ed78dbe5205e639cb9
4
+ data.tar.gz: eac0e4498d2170e42572ceab300a7a4fe5aff477
5
5
  SHA512:
6
- metadata.gz: 664900554e247b44d0029f426128df2909e5dd10cfcdbe254e088c92f88584480acb63976fec453f8e9bf70d1c3177feb8c6ac75d43290fe5377d0f93b281338
7
- data.tar.gz: bc34ed6961ca5966c561b8d7faf70cc57fd93900acfd52acfdc301b002014f5bf7e90bdea8a32bf4a1612ab4fedb81f86c6d9613068928ad38a0124e96ba6bc9
6
+ metadata.gz: a621c179c474fb230b93577b77cb4d5a681b85e9fe133d0e95df7d6b9be929e9a03c2f71d4bfc079abdaf7eb14a410ac5d92612f02ecc416f0f42d63997ddceb
7
+ data.tar.gz: '07581f2633f211d575e9490d391064aba08e7be4ff5650d4a3cb3f8a94a3152ea6cf8242e4278d589f4fc2a5f13dd31c68d36d0ba4025d80adc3e07db0d1c265'
data/README.md CHANGED
@@ -98,6 +98,12 @@ end
98
98
 
99
99
  (You should avoid accessing your actual model classes here, since that will cause them to be auto-loaded.)
100
100
 
101
+ ## Reversing mappings
102
+
103
+ When debugging difficult test scenarios, it can be useful to confirm which record you are looking at. As well as the usual forward mappings from fixture name to record, Fixation supports mapping back from record or record ID to the fixture name.
104
+
105
+ For example, if `customers(:jeff)` returns a record with ID `12345678`, then `customer_fixture_name_for_id(12345678)` will return `:jeff`, as will `customer_fixture_name_for_id(Customer.find(12345678))`.
106
+
101
107
  ## Contributing
102
108
 
103
109
  Bug reports and pull requests are welcome on GitHub at https://github.com/willbryant/fixation.
@@ -126,6 +126,15 @@ module Fixation
126
126
  instances.size == 1 ? instances.first : instances
127
127
  end
128
128
  private fixture_name
129
+
130
+ name_method = :"#{fixture_name.singularize}_fixture_name_for_id"
131
+ define_method(name_method) do |fixture_id|
132
+ fixture_id = fixture_id.to_param
133
+ fixtures.detect do |name, id|
134
+ break name.to_sym if id.to_param == fixture_id
135
+ end or raise ArgumentError, "No fixture with ID #{fixture_id.inspect} in table #{fixture_name}"
136
+ end
137
+ private name_method
129
138
  end
130
139
  end
131
140
  end
@@ -1,3 +1,3 @@
1
1
  module Fixation
2
- VERSION = "2.1.0"
2
+ VERSION = "2.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixation
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Bryant
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-09 00:00:00.000000000 Z
11
+ date: 2017-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler