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 +4 -4
- data/README.md +6 -0
- data/lib/fixation/fixtures.rb +9 -0
- data/lib/fixation/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7f04907bb50bacd416534ed78dbe5205e639cb9
|
4
|
+
data.tar.gz: eac0e4498d2170e42572ceab300a7a4fe5aff477
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
data/lib/fixation/fixtures.rb
CHANGED
@@ -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
|
data/lib/fixation/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|