Coder Social home page Coder Social logo

Comments (19)

mmastoras avatar mmastoras commented on June 15, 2024 1

also worked for me w/ following:

Gemfile

group :development do
  gem "factory_girl_rails"
end

config/application.rb

config.generators do |g|
  g.test_framework :rspec, :fixture => true, :views => false
  g.fixture_replacement :factory_girl, :dir => "spec/factories"
end

from factory_bot_rails.

joshuaclayton avatar joshuaclayton commented on June 15, 2024

What version of rails are you using?

from factory_bot_rails.

AntonTrapp avatar AntonTrapp commented on June 15, 2024

3.2.0

from factory_bot_rails.

joshuaclayton avatar joshuaclayton commented on June 15, 2024

Weird - I just tried with a 3.2.2 app and it works fine. What version of factory_girl_rails are you using? I tried with 3.0.0 and it worked without a hitch.

from factory_bot_rails.

AntonTrapp avatar AntonTrapp commented on June 15, 2024

Yes, weird - but on the other side: one of the gems is always itching ;)

factory_girl (3.0.0)
factory_girl_rails (3.0.0)

Maybe a side effect with another gem? rspec? rails3-generators? shoulda? Anything known?

*** LOCAL GEMS ***

actionmailer (3.2.0)
actionpack (3.2.0)
activemodel (3.2.0)
activerecord (3.2.0)
activeresource (3.2.0)
activesupport (3.2.0)
addressable (2.2.7)
arel (3.0.2)
autotest (4.4.6)
awesome_print (1.0.2)
bcrypt-ruby (3.0.1)
builder (3.0.0)
bundler (1.1.3)
cancan (1.6.7)
capybara (1.1.2)
childprocess (0.3.1)
chronic (0.6.7)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.2.0)
commonjs (0.2.5)
country_select (0.0.2)
cucumber (1.1.9)
cucumber-rails (1.3.0)
database_cleaner (0.7.2)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.3.0)
factory_girl (3.0.0)
factory_girl_rails (3.0.0)
ffi (1.0.11)
gherkin (2.9.3)
haml (3.1.4)
haml-rails (0.3.4)
hike (1.2.1)
hirb (0.6.2)
hirb-unicode (0.0.5)
hpricot (0.8.6)
i18n (0.6.0)
journey (1.0.3)
jquery-rails (2.0.1)
json (1.6.6)
launchy (2.1.0)
less (2.0.12)
less-rails (2.1.8)
libv8 (3.3.10.4 x86_64-darwin-11)
mail (2.4.4)
mime-types (1.18)
multi_json (1.2.0)
mysql2 (0.3.11)
nokogiri (1.5.2)
orm_adapter (0.0.7)
paper_trail (2.6.3)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.0)
rails3-generators (0.17.4)
railties (3.2.0)
rake (0.9.2.2)
rdoc (3.12)
rspec (2.9.0)
rspec-core (2.9.0)
rspec-expectations (2.9.0)
rspec-mocks (2.9.0)
rspec-rails (2.9.0)
ruby_parser (2.3.1)
rubyzip (0.9.6.1)
sass (3.1.15)
sass-rails (3.2.5)
selenium-webdriver (2.20.0)
sexp_processor (3.1.0)
shoulda (3.0.1)
shoulda-context (1.0.0)
shoulda-matchers (1.0.0)
simple_form (2.0.1)
simplecov (0.6.1)
simplecov-html (0.5.3)
sprockets (2.1.2)
term-ansicolor (1.0.7)
therubyracer (0.9.10)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
twitter-bootstrap-rails (2.0.4)
tzinfo (0.3.32)
uglifier (1.2.4)
unicode-display_width (0.1.1)
warden (1.1.1)
whenever (0.7.3)
xpath (0.1.4)
ZenTest (4.7.0)

from factory_bot_rails.

joshuaclayton avatar joshuaclayton commented on June 15, 2024

Can you paste your Gemfile.lock and your config/application.rb? My guess is that it may be another generator, but I'm not positive. I've tried a couple of different Rails versions, with and without the fixture_replacement defined in the config (it gets used by default). If it generates the factories for you, I'd just remove it.

from factory_bot_rails.

AntonTrapp avatar AntonTrapp commented on June 15, 2024

Sure! Glad if I can help, really love this girl ;)

Gemfile.lock: https://gist.github.com/2252137
application.rb: https://gist.github.com/2252149

from factory_bot_rails.

joshuaclayton avatar joshuaclayton commented on June 15, 2024

I've got nothing... sorry. Here's a repo that I made with what looks to be the core pieces of fixtures and the rails app: https://github.com/joshuaclayton/fgr_fixture_replacement_example Walk through the commits and you can see what I did (I even outlined the commands I ran). If you can find a way to reproduce in a similar fashion, that'd be great. The only thing I notice a difference in is the patch version of Rails, so try bumping up to 3.2.2. If that doesn't work, finding a way to reproduce will be the only way you can help me I think. Once you find a way to repro, reopen this issue if you could. Thanks!

from factory_bot_rails.

AntonTrapp avatar AntonTrapp commented on June 15, 2024

Thanks, I figure it out this weekend and will be back again (with a reproduction of the error or the solution to the problem)...

from factory_bot_rails.

neocoin avatar neocoin commented on June 15, 2024

I have almost same problem.
This problem is made by FactoryGirls version 3.0.0.

/lib/generators/factory_girl/model/model_generator.rb

module FactoryGirl
  module Generators
    class ModelGenerator < Base
      argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
      class_option :dir, :type => :string, :default => "test/factories", :desc => "The directory where the factories should go"

      def create_fixture_file
        version = nil
        begin
          require 'factory_girl/version'
          version = FactoryGirl::VERSION.to_i
        rescue LoadError
          require 'factory_girl'
          version = Factory::VERSION.to_i
        rescue Object => e
          raise "Please install Factory_girl or add it to your Gemfile"
        end

        template "fixtures.#{version}.rb", File.join(options[:dir], "#{table_name}.rb")
      end
    end
  end
end

with factory_girl 3.0.0 , generator should find fixture for version 3

template "fixtures.#{version}.rb", File.join(options[:dir], "#{table_name}.rb")

Now, fixture templates for factory_girl are just 'fixtures.1.rb, fixtures.2.rb' in template directory.
So you could solve this problem just to copy fixtures.2.rb to fixtures.3.rb in generators/factory_girl/model/templates

I could find exact solution. (ye.. I need solution right now.) See below comments

from factory_bot_rails.

neocoin avatar neocoin commented on June 15, 2024

@AntonTrapp

hm. This situation is slightly complex.

factory_girl_rails have fixture generator for factory_girl. This feature moved from rails3-generator 5 month ago.

But rails3-generator 0.17.4 gem have factory_girl generator yet.
And, even if factory_girl fixture generators are removed from current rails3-generator master source,
master branch have useless 'generators/factory_girl.rb' file yet.

So if you point with 'gem rails3-generator, :git => https://github.com/indirect/rails3-generators.git', you could not solve this problem. ;;

I made temporal solution for me in 'https://github.com/neocoin/rails3-generators.git' 3 minute ago.
I just remove factory_girl generator.... (Also I requested pull to master)

So you could use temporal solution below until this patch will apply master version. Or fork me and use user repository.

group :development do
  gem 'factory_girl_rails'
  gem "rails3-generators", :git => "https://github.com/neocoin/rails3-generators.git"
end

good luck.

from factory_bot_rails.

joshuaclayton avatar joshuaclayton commented on June 15, 2024

Yeah, it looks like rails3-generators is the culprit. My recommendation is removing the gem until the rails3-generators gem removes the factory_girl generator and bumps the gem version. Good luck!

from factory_bot_rails.

JeanMertz avatar JeanMertz commented on June 15, 2024

I am having the same issue. I uninstalled the rails3-generators gem but I am still having the same issue.

application.rb

    config.generators do |g|
      g.test_framework :rspec, fixture: true
      g.fixture_replacement :factory_girl, dir: 'spec/factories'
      g.form_builder :simple_form
      g.template_engine :haml
    end

Here is my command:


Usage:
  rails generate oauth_provider [NAME] [options]

Options:
      [--skip-namespace]        # Skip namespace (affects only isolated applications)
      [--old-style-hash]        # Force using old style hash (:foo => 'bar') on Ruby >= 1.9
  -o, [--orm=NAME]              # Orm to be invoked
                                # Default: active_record
  -t, [--test-framework=NAME]   # Test framework to be invoked
                                # Default: rspec
  -e, [--template-engine=NAME]  # Template engine to be invoked
                                # Default: haml

Rspec options:
  [--fixture]                   # Indicates when to generate fixture
                                # Default: true
  [--fixture-replacement=NAME]  # Fixture replacement to be invoked
                                # Default: factory_girl

And here is the output:

      invoke  rspec
      create    spec/controllers/oauth_clients_controller_spec.rb
      create    spec/models/client_application_spec.rb
      create    spec/models/oauth_token_spec.rb
      create    spec/models/oauth2_token_spec.rb
      create    spec/models/oauth2_verifier_spec.rb
      create    spec/models/oauth_nonce_spec.rb
       error    factory_girl [not found]

from factory_bot_rails.

AntonTrapp avatar AntonTrapp commented on June 15, 2024

@joshuaclayton - sorry for the delay, I can confirm that removing and uninstalling the rails3-generators solves the issue for me too.
Thank you very much!

from factory_bot_rails.

dustineichler avatar dustineichler commented on June 15, 2024

@mmastoras grazie, that worked.

from factory_bot_rails.

jspooner avatar jspooner commented on June 15, 2024

Thank you @mmastoras that worked for our app.

from factory_bot_rails.

AntonTrapp avatar AntonTrapp commented on June 15, 2024

@mmastoras Thank you, worked for me too!

from factory_bot_rails.

pavankat avatar pavankat commented on June 15, 2024

@mmastoras When I tried your solution I got this:

/Users/pkat/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require': dlopen(/Users/pkat/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /Users/pkat/.bundler/tmp/25324/gems/nokogiri-1.6.0/ports/i686-apple-darwin11/libxml2/2.8.0/lib/libxml2.2.dylib (LoadError)

from factory_bot_rails.

joshuaclayton avatar joshuaclayton commented on June 15, 2024

@pavankat it looks Nokogiri was compiled against a (now-?)nonexistent version of libxml.

from factory_bot_rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.