Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: thoughtbot/factory_girl
...
head fork: thoughtbot/factory_girl
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 5 files changed
  • 0 commit comments
  • 2 contributors
View
2  lib/factory_girl.rb
@@ -21,7 +21,7 @@ def Factory (name, attrs = {})
end
class Factory
- VERSION = "1.3.1"
+ VERSION = "1.3.2"
end
if defined?(Rails) && Rails::VERSION::MAJOR == 2
View
2  lib/factory_girl/aliases.rb
@@ -4,7 +4,7 @@ class << self
attr_accessor :aliases #:nodoc:
end
self.aliases = [
- [/(.*)_id/, '\1'],
+ [/(.+)_id/, '\1'],
[/(.*)/, '\1_id']
]
View
9 lib/factory_girl/factory.rb
@@ -303,11 +303,12 @@ def self.default_strategy (name, overrides = {})
def self.find_definitions #:nodoc:
definition_file_paths.each do |path|
- require("#{path}.rb") if File.exists?("#{path}.rb")
+ full_path = File.expand_path(path)
+ require("#{full_path}.rb") if File.exists?("#{full_path}.rb")
- if File.directory? path
- Dir[File.join(path, '*.rb')].each do |file|
- require file
+ if File.directory?(full_path)
+ Dir[File.join(full_path, '*.rb')].each do |file|
+ require(file)
end
end
end
View
4 spec/factory_girl/aliases_spec.rb
@@ -14,6 +14,10 @@
Factory.aliases_for(:test).should include(:test_id)
end
+ it "should NOT include an attribute as an alias when it starts with underscore" do
+ Factory.aliases_for(:_id).should_not include(:id)
+ end
+
describe "after adding an alias" do
before do
View
5 spec/factory_girl/factory_spec.rb
@@ -586,7 +586,7 @@ def self.in_directory_with_files(*files)
files.each do |file|
FileUtils.mkdir_p File.dirname(file)
FileUtils.touch file
- stub(Factory).require(file)
+ stub(Factory).require
end
end
@@ -598,7 +598,8 @@ def self.in_directory_with_files(*files)
def require_definitions_from(file)
simple_matcher do |given, matcher|
- has_received = have_received.method_missing(:require, file)
+ full_path = File.expand_path(file)
+ has_received = have_received.method_missing(:require, full_path)
result = has_received.matches?(given)
matcher.description = "require definitions from #{file}"
matcher.failure_message = has_received.failure_message

No commit comments for this range

Something went wrong with that request. Please try again.