¿ªÔÆÌåÓýHi Brian,I certainly don't know ... I'll think aloud and in terms I understand and see what happens. I know less than nothing about Elixir.
I'm pretending that I just sat down to pair with you, all full of total ignorance but great curiosity. I guess that updatable! returns an updated animal (or hurls). I guess animal -> is magically the return result of the Read. I guess that functions return the last thing computed and that put_updatable_fields() will return the animal it updates.? I want a test, probably, for put_updatable_fields, and it needs to check all the fields. Since that takes and returns an animal, it can be tested with a canned empty animal and a canned full one and an irritating compare equal of some kind. But in mocks, I think it'd be much the same, since we have to check each field to see if it has been changed.? I guess if I were mocking, then I'd just do the mock thing you show that says that updatable! does in fact call the put. Since I wouldn't likely be mocking (Detroit school, y'know), what would I do? I'd write a test that would fail if some should-be-updatable field wasn't updatable. (Which I really think means displayable or something.) I'm guessing that a non-updatable animal is still a valid animal. (That might be a bug.) It appears that updatable is a pure cosmetic thing to get the form to work, and that the animal has no reason to know whether it is updatable. I'm wondering why they aren't always made updatable out of the box. (Complete Constructor Method). If they were, would that change our thinking on how to do this? I think it might: we don't worry any more. Anyway, now we're writing four functions which, I guess? could conceivably read animals wrongly, not calling updatable! and we want to be sure that they do? Tell the truth, since this is a display issue (?), I think I'd just look. If I worry that someone will try to make these four functions more efficient by removing the updatable bit, though, I need tests. So either A) I'd have only one way to get an animal and it would be updatable, end of story I think, or B1) write tests for each of those four functions. Do whatever is_updatable checking one does, one or many fields, etc.? B2) observe duplication and remove it. (def check_is_updatable(animal))? I'm just about certain that I've missed some key thing here. What is it? Ron Jeffries Everything that needs to be said has already been said. But since no one was listening, everything must be said again. -- Andre Gide |