You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This supports both the old version (single value) and new version (hash-based).
I've added back the tests from the old version to check that the code stills works
when we provide a single value.
I've also adapted the README a bit to explain both versions.
compare_error_message_and_class =-> (control, candidate) do
124
-
control.class== candidate.class&&
124
+
control.class== candidate.class&&
125
125
control.message == candidate.message
126
126
end
127
127
128
128
compare_argument_errors =-> (control, candidate) do
129
129
control.class==ArgumentError&&
130
130
candidate.class==ArgumentError&&
131
131
control.message.start_with?("Input has invalid characters") &&
132
-
candidate.message.start_with?("Invalid characters in input")
132
+
candidate.message.start_with?("Invalid characters in input")
133
133
end
134
134
135
135
e.compare_errors do |control, candidate|
@@ -550,7 +550,25 @@ end
550
550
551
551
#### Providing fake timing data
552
552
553
-
If you're writing tests that depend on specific timing values, you can provide canned durations using the `fabricate_durations_for_testing_purposes` method, and Scientist will report these in `Scientist::Observation#duration` and `Scientist::Observation#cpu_time` instead of the actual execution times.
553
+
If you're writing tests that depend on specific timing values, you can provide canned durations using the `fabricate_durations_for_testing_purposes` method. This can be done using either the old version (single value) or the new version (hash-based) to include both duration and cpu_time.
554
+
555
+
##### Old version (Single Value)
556
+
557
+
In the old version, you can provide a single value for the duration:
`fabricate_durations_for_testing_purposes` takes a Hash of duration values, keyed by behavior names. (By default, Scientist uses `"control"` and `"candidate"`, but if you override these as shown in [Trying more than one thing](#trying-more-than-one-thing) or [No control, just candidates](#no-control-just-candidates), use matching names here.) If a name is not provided, the actual execution time will be reported instead.
568
+
569
+
##### New version (Hash-based)
570
+
571
+
Scientist will report these in `Scientist::Observation#duration` and `Scientist::Observation#cpu_time` instead of the actual execution times.
0 commit comments