-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed the behavior as require_migration expected to be called from the spec, but this method could be called from the helper or elsewhere. Therefore, we detect the first caller location with the spec instead of assuming it's the first one.
- Loading branch information
Showing
2 changed files
with
7 additions
and
5 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
def require_migration | ||
spec_name = caller_locations.first.path | ||
migration_name = spec_name.sub("spec/migrations", "db/migrate").sub("_spec.rb", ".rb") | ||
require migration_path | ||
end | ||
|
||
require migration_name | ||
def migration_path | ||
spec_name = caller_locations.detect {|loc| loc.path.end_with?("_spec.rb")}.path | ||
spec_name.sub("spec/migrations", "db/migrate").sub("_spec.rb", ".rb") | ||
end |