Say you have a post model, and you gave it the label foobar.
Now you try to use that label to refer to the model you've created/found.
Consider the following example:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given a post: "foobar" exists with title: "My awesome post" | |
And I go to the home page | |
Then the post: "foobar" should exist with title: "just a post" |
This example, rather than failing by saying the model did not match the fields passed into it, violently fails by giving the error:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The model: 'the post: "foobar"' is not known in this scenario. |
Not very pretty, right?
In fact, I personally mistook this for having something wrong with my labels.
Turns out, the label is totally fine, but the error thrown, well... threw me off...
It took me way too much time to go through any bit of capybara documentation I could lay my hands on, and I still not understand why I got the error.
Finally, turns out Pickle raises this error, not because this label is not valid, but rather because the model "myteacher" doesn't match the attributes I'm requesting.
For example: the following test, which uses the same label is actually passing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given a teacher: "myteacher" exists with first_name: "Joe" | |
And I go to the home page | |
Then the teacher: "myteacher" should exist with first_name: "Joe" |
Hopefully this saves you some good quality time between your head and your favorite wall.
I emailed the developer of Pickle and I'm hoping he'll be kind enough to change the error a bit in future versions so that it is clearer what's happening.