Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to run on 2.99.0 project #66

Closed
sgringwe opened this issue Jun 6, 2014 · 38 comments
Closed

Fails to run on 2.99.0 project #66

sgringwe opened this issue Jun 6, 2014 · 38 comments
Labels

Comments

@sgringwe
Copy link

sgringwe commented Jun 6, 2014

I am getting an issue when running the transpec command. Currently on rspec 2.99.0:

Copying the project for dynamic analysis...
Running dynamic analysis with command "bundle exec rspec"...
2014-06-06T01:24:34Z 24339 TID-ovc2pveew INFO: Sidekiq client with redis options {:size=>1}
2014-06-06T01:24:34Z 24339 TID-ovc2pveew INFO: Sidekiq client with redis options {:url=>"redis://localhost:6379/", :namespace=>"sidekiq"}
/Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/definition_proxy.rb:42:in `add_attribute': wrong number of arguments (5 for 1..2) (ArgumentError)
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/definition_proxy.rb:96:in `method_missing'
    from /private/var/folders/4v/b1x50jjj26s87lvfk6zrdmx80000gn/T/d20140605-24297-w32c8i/handshake/spec/factories/appointments.rb:29:in `block (2 levels) in <top (required)>'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/syntax/default.rb:18:in `instance_eval'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/syntax/default.rb:18:in `factory'
    from /private/var/folders/4v/b1x50jjj26s87lvfk6zrdmx80000gn/T/d20140605-24297-w32c8i/handshake/spec/factories/appointments.rb:22:in `block in <top (required)>'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/syntax/default.rb:49:in `instance_eval'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/syntax/default.rb:49:in `run'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/syntax/default.rb:7:in `define'
    from /private/var/folders/4v/b1x50jjj26s87lvfk6zrdmx80000gn/T/d20140605-24297-w32c8i/handshake/spec/factories/appointments.rb:21:in `<top (required)>'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `load'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `block in load'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `load'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/find_definitions.rb:20:in `block (2 levels) in find_definitions'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/find_definitions.rb:19:in `each'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/find_definitions.rb:19:in `block in find_definitions'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/find_definitions.rb:15:in `each'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/find_definitions.rb:15:in `find_definitions'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/factory_girl_rails-4.4.1/lib/factory_girl_rails/railtie.rb:21:in `block in <class:Railtie>'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:36:in `call'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:44:in `each'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/application/finisher.rb:64:in `block in <module:Finisher>'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/initializable.rb:30:in `run'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/2.1.0/tsort.rb:345:in `each'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/2.1.0/tsort.rb:345:in `call'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/application.rb:288:in `initialize!'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/railtie.rb:194:in `public_send'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/railtie.rb:194:in `method_missing'
    from /private/var/folders/4v/b1x50jjj26s87lvfk6zrdmx80000gn/T/d20140605-24297-w32c8i/handshake/config/environment.rb:97:in `<top (required)>'
    from /private/var/folders/4v/b1x50jjj26s87lvfk6zrdmx80000gn/T/d20140605-24297-w32c8i/handshake/spec/spec_helper.rb:13:in `require'
    from /private/var/folders/4v/b1x50jjj26s87lvfk6zrdmx80000gn/T/d20140605-24297-w32c8i/handshake/spec/spec_helper.rb:13:in `<top (required)>'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.0/lib/rspec/core/configuration.rb:1036:in `require'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.0/lib/rspec/core/configuration.rb:1036:in `block in setup_load_path_and_require'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.0/lib/rspec/core/configuration.rb:1036:in `each'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.0/lib/rspec/core/configuration.rb:1036:in `setup_load_path_and_require'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.0/lib/rspec/core/configuration_options.rb:25:in `configure'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.0/lib/rspec/core/command_line.rb:17:in `run'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.0/lib/rspec/core/runner.rb:89:in `run'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.0/lib/rspec/core/runner.rb:17:in `block in autorun'
Failed running dynamic analysis. Transpec runs your specs in a copied project directory. If your project requires some special setup or commands to run specs, use -c/--rspec-command option.

Any ideas what the issue could be?

@sgringwe
Copy link
Author

sgringwe commented Jun 6, 2014

Forgot to paste the code:

FactoryGirl.define do
  factory :appointment do
    school
    start_date Time.zone.now.beginning_of_week + 9.hours # beginning of week is monday
    end_date Time.zone.now.beginning_of_week + 10.hours
    description 'Resume check'
    appointment_medium

    before(:create) do |appointment, evaluator|
      appointment.student = FactoryGirl.create(:student_user, institution: appointment.school)
      appointment.staff_member = FactoryGirl.create(:school_user, institution: appointment.school)
      building = FactoryGirl.create(:building, school: appointment.school)
      appointment.room = FactoryGirl.create(:room, building: building)
    end
  end
end

The offending code seems to be the after(), before() blocks. If I comment that particular before() block, another one in a different factory has the same failure. Does not happen when running the specs normally.

@sgringwe
Copy link
Author

sgringwe commented Jun 6, 2014

After removing all before() and after() blocks from factory girl, I get the following:

Copying the project for dynamic analysis...
Running dynamic analysis with command "bundle exec rspec"...
2014-06-06T01:33:58Z 25780 TID-ox0kybtfo INFO: Sidekiq client with redis options {:size=>1}
2014-06-06T01:33:58Z 25780 TID-ox0kybtfo INFO: Sidekiq client with redis options {:url=>"redis://localhost:6379/", :namespace=>"sidekiq"}
/private/var/folders/4v/b1x50jjj26s87lvfk6zrdmx80000gn/T/d20140605-25743-1c0yklb/handshake/spec/spec_helper.rb:35:in `<top (required)>': undefined method `transpec_analyze' for main:Object (NoMethodError)
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.0/lib/rspec/core/configuration.rb:1036:in `require'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.0/lib/rspec/core/configuration.rb:1036:in `block in setup_load_path_and_require'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.0/lib/rspec/core/configuration.rb:1036:in `each'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.0/lib/rspec/core/configuration.rb:1036:in `setup_load_path_and_require'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.0/lib/rspec/core/configuration_options.rb:25:in `configure'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.0/lib/rspec/core/command_line.rb:17:in `run'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.0/lib/rspec/core/runner.rb:89:in `run'
    from /Users/sgringwe/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.0/lib/rspec/core/runner.rb:17:in `block in autorun'
Failed running dynamic analysis. Transpec runs your specs in a copied project directory. If your project requires some special setup or commands to run specs, use -c/--rspec-command option.

@yujinakayama
Copy link
Owner

Is your spec suite using environment variable SPEC_OPTS?

@sgringwe
Copy link
Author

sgringwe commented Jun 6, 2014

Not that I know of:

sgringwe at Scotts-MacBook-Pro in ~/code/handshake on view_as_employer
[1] $ echo $SPEC_OPTS                                                                                                                                                                                                                                                         ✘


sgringwe at Scotts-MacBook-Pro in ~/code/handshake on view_as_employer
$

@yujinakayama
Copy link
Owner

Please try grep -r SPEC_OPTS spec.

@sgringwe
Copy link
Author

sgringwe commented Jun 6, 2014

sgringwe at Scotts-MacBook-Pro in ~/code/handshake on view_as_employer
[130] $ grep -r SPEC_OPTS spec                                                                                                                                                                                                                                                ✘

sgringwe at Scotts-MacBook-Pro in ~/code/handshake on view_as_employer
[1] $

@sgringwe
Copy link
Author

sgringwe commented Jun 6, 2014

@yujinakayama is there any information I can give you to help?

@yujinakayama
Copy link
Owner

Hmm, though I still have no idea why it fails, try this:

$ transpec --rspec-command "bundle exec rspec --require ./transpec_analysis_helper.rb"

@sgringwe
Copy link
Author

sgringwe commented Jun 6, 2014

No luck :/. My spec_helper.rb:

# Add code coverage for circle ci
if ENV['CIRCLE_ARTIFACTS']
  require 'simplecov'
  dir = File.join("..", "..", "..", ENV['CIRCLE_ARTIFACTS'], "coverage")
  SimpleCov.coverage_dir(dir)
  SimpleCov.start 'rails'
end

require 'rubygems'

ENV["RAILS_ENV"] ||= 'test'
require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# require 'rspec/support/spec'
require 'capybara/rspec'
require 'capybara/webkit/matchers'
require 'sidekiq/testing'
require 'show_me_the_cookies'
require 'database_cleaner'
require 'tire'

# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.maintain_test_schema!

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

# Start with garbage collection disabled. It will be
# re-enabled in a strict manner below
# GC.disable

RSpec.configure do |config|
  # ## Mock Framework
  #
  # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
  #
  # config.mock_with :mocha
  # config.mock_with :flexmock
  # config.mock_with :rr

  # If you're not using ActiveRecord, or you'd prefer not to run each of your
  # examples within a transaction, remove the following line or assign false
  # instead of true. We want this to be false otherwise EVERYTHING is wrapped
  # in a transaction. We use database cleaner to say transactions for unit tests
  # and truncation (delete at end) for request specs (need to be persisted)
  config.use_transactional_fixtures = false

  # If true, the base class of anonymous controllers will be inferred
  # automatically. This will be the default behavior in future versions of
  # rspec-rails.
  # config.infer_base_class_for_anonymous_controllers = false

  # Add :focus tag to any spec to only run that spec
  config.filter_run :focus => true
  config.run_all_when_everything_filtered = true

  config.before(focus: true) do
    fail "Hey dummy, don't commit focused specs." if ENV['FORBID_FOCUSED_SPECS']
  end

  # config.order = "random"

  config.before(:suite) do
    DatabaseCleaner.strategy = :transaction
    DatabaseCleaner.clean_with(:truncation)
    # FactoryGirl.lint
  end

  config.before(:each) do
    DatabaseCleaner.strategy = :transaction
  end

  # Request specs cannot use a transaction because Capybara runs in a
  # separate thread with a different database connection.
  config.before(type: :request) do
    DatabaseCleaner.strategy = :truncation
  end

  # Reset so other non-request specs don't have to deal with slow truncation.
  config.after(type: :request)  do
    DatabaseCleaner.strategy = :transaction
  end

  config.before(:each, js: true) do
    DatabaseCleaner.strategy = :truncation
  end

  config.after(type: :request, js: true) do
    # This is nice but sometimes there are test-only
    # js errors and I don't have time to debug them right
    # now
    # do_final_checks
  end

  config.before(:each, es: true) do
    # Marks tests that use elasticsearch/make a call to es
    # not doing anything yet but could potentially:
    # 1. reset ALL indexes. slow but simplified?
    # 2. use truncation
    # 3. ???
  end

  config.before(:each) do
    DatabaseCleaner.start
  end

  config.after(:each) do
    DatabaseCleaner.clean
  end

  config.before(:each) { reset_email }

  # use bullet gem in specs to fail on bad database queries (n + 1 queries)
  config.before(:each) do
    Bullet.start_request if Bullet.enable?
  end

  config.after(:each) do
    Bullet.perform_out_of_channel_notifications if Bullet.enable? && Bullet.notification?
    Bullet.end_request if Bullet.enable?
  end

  # Gem which helps us access the cookies
  config.include ShowMeTheCookies

  # The following are used to login before a test is run
  # config.include ControllerMacros, :type => :controller
  config.include SessionHelpers
  config.include JavascriptHelpers
  config.include MailerMacros
  config.include ElasticSearchMacros
  config.include FactoryGirl::Syntax::Methods

  # Requests
  config.include RequestHelpers, type: :request

  # Capybara
  config.include Rails.application.routes.url_helpers
  config.include Capybara::DSL
  config.include Capybara::Webkit::RspecMatchers, :type => :feature

  Capybara.javascript_driver = :webkit

  config.infer_spec_type_from_file_location!
end

# Testing sidekiq processes. Default to fake but tests should set it just in case.
Sidekiq::Testing.fake! # This pushes all enqueued jobs into a jobs array and does not run them
# Sidekiq::Testing.inline! # This runs jobs immediately in the same thread


RSpec::Sidekiq.configure do |config|
  # Clears all job queues before each example
  config.clear_all_enqueued_jobs = true # default => true

  # Whether to use terminal colours when outputting messages
  config.enable_terminal_colours = true # default => true

  # Warn when jobs are not enqueued to Redis but to a job array
  config.warn_when_jobs_not_processed_by_sidekiq = true # default => true
end

# For using elasticsearch in specs. This (hopefully) solves the issue of brittle tests
# from elasaticsearch's refresh interval of 1 second.
# -1 for instant refresh:
# =>  http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules.html
# 30 merge factor for faster index creation:
# =>  http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-merge.html
if Rails.env.test?
  RestClient.put "#{ENV['ELASTICSEARCH_URL']}/_settings ", %<{
    "index" : {
        "refresh_interval" : "-1",
        "merge.policy.merge_factor" : 30
    }
  }>
end

@sgringwe
Copy link
Author

sgringwe commented Jun 6, 2014

What part of the project does transpec copy? The spec folder? Or the whole project?

@yujinakayama
Copy link
Owner

The whole project, or I should say the current working directory.

@yujinakayama
Copy link
Owner

Can you point the line handshake/spec/factories/appointments.rb:29?

@sgringwe
Copy link
Author

sgringwe commented Jun 6, 2014

Line 29 starts on the before:

before(:create) do |appointment, evaluator|
      appointment.student = FactoryGirl.create(:student_user, institution: appointment.school)
      appointment.staff_member = FactoryGirl.create(:school_user, institution: appointment.school)
      building = FactoryGirl.create(:building, school: appointment.school)
      appointment.room = FactoryGirl.create(:room, building: building)
    end

Do you think that the undefined method error may be caused by rbenv installing the gem somewhere the copied directory cannot find?

@sgringwe
Copy link
Author

sgringwe commented Jun 6, 2014

I think this may be helpful:

$ which transpec
/Users/sgringwe/.rbenv/shims/transpec

@yujinakayama
Copy link
Owner

Was the error same as before when you ran transpec --rspec-command "bundle exec rspec --require ./transpec_analysis_helper.rb"?

@yujinakayama
Copy link
Owner

Do you think that the undefined method error may be caused by rbenv installing the gem somewhere the copied directory cannot find?

I don't think so, unless you have run bundle install --path ../somewhere/outside/of/project.

@sgringwe
Copy link
Author

sgringwe commented Jun 6, 2014

Yes, the error was the same when I ran it before. However, I added a line

require 'transpec'

in my spec_helper.rb and it gives me the error:

require': cannot load such file -- transpec (LoadError)

Maybe I could run 'gem install transpec' in my spec_helper as a hacky way to get it working?

@yujinakayama
Copy link
Owner

You don't need to require transpec in your spec.

Please add the following to the top of your spec_helper.rb and run:

p defined?(TranspecAnalysis)
p ENV['SPEC_OPTS']
p Dir.pwd

@sgringwe
Copy link
Author

sgringwe commented Jun 6, 2014

nil
"-r ./transpec_analysis_helper.rb"
"/private/var/folders/4v/b1x50jjj26s87lvfk6zrdmx80000gn/T/d20140605-28999-hce2u8/handshake"

@yujinakayama
Copy link
Owner

Hmm, it's really strange. The module TranspecAnalysis should exist if transpec_analysis_helper.rb is loaded...

@sgringwe
Copy link
Author

sgringwe commented Jun 6, 2014

Maybe I'm missing something, but where is the method actually defined? Can't find anything at https://github.com/yujinakayama/transpec/search?q=transpec_analyze&type=Code

@yujinakayama
Copy link
Owner

@sgringwe
Copy link
Author

sgringwe commented Jun 6, 2014

Alright, well I am going to call it quits on this for now. Will let you know if I get it working though.

@sgringwe
Copy link
Author

sgringwe commented Jun 6, 2014

Doh, looks like there is a static analysis? Doing that :).

@yujinakayama
Copy link
Owner

By default Transpec performs static + dynamic analysis. With -s/--skip-dynamic-analysis option, it performs only static analysis. However as mentioned in the README, it decreases the conversion accuracy notably.

@sgringwe
Copy link
Author

sgringwe commented Jun 6, 2014

@yujinakayama well, I got a pretty decent conversion rate. I'm going to try the upgrade to 3.0.0 and see how it goes. Thanks for all your help.

1047 conversions
  from: obj.should
    to: expect(obj).to
316 conversions
  from: obj.should_not
    to: expect(obj).not_to
123 conversions
  from: describe 'some request' { }
    to: describe 'some request', :type => :request { }
107 conversions
  from: describe 'some model' { }
    to: describe 'some model', :type => :model { }
2 conversions
  from: > expected
    to: be > expected
2 conversions
  from: describe 'some routing' { }
    to: describe 'some routing', :type => :routing { }
1 conversion
  from: =~ [1, 2]
    to: match_array([1, 2])
1 conversion
  from: describe 'some mailer' { }
    to: describe 'some mailer', :type => :mailer { }
1 conversion
  from: obj.stub(:message)
    to: allow(obj).to receive(:message)
1 conversion
  from: pending
    to: skip

@yujinakayama
Copy link
Owner

Glad to hear that. Anyway it's much easier than manual rewriting. :)

@sgringwe
Copy link
Author

sgringwe commented Jun 6, 2014

Absolutely! Looks like 3.0 upgrade was successful. Thanks1

@inukshuk
Copy link

@sgringwe do you have an .rspec file in your root directory by any chance? I just ran into the same problem – transpec_analysis_helper.rb was generated just fine, but it was not loaded because a --require in my .rspec file took precedence over ENV['SPEC_OPTS']

@yujinakayama do you think it would make sense to adapt to this condition? And thanks for transpec – it's awesome!

@yujinakayama
Copy link
Owner

@inukshuk Good point! It's quite likely.

Even if it's not the cause of @sgringwe's case, I'll handle this case.

And you're welcome. :)

@yujinakayama
Copy link
Owner

Released 2.2.2 with fix for the @inukshuk's case.

@yujinakayama
Copy link
Owner

@inukshuk @sgringwe It's much appreciated if you would check if the issue is really fixed.

@inukshuk
Copy link

@yujinakayama I'll soon run out of projects to test : ) But I just checked 2.2.2 and it works as advertised with my .rspec files. Thanks!

@yujinakayama
Copy link
Owner

@inukshuk You need to start some projects with RSpec 2. :P Thanks for the great report!

@RobinDaugherty
Copy link

Perhaps a regression? I'm having the same issue with transpec 2.3.2.

Was on factory_girl 4.3.0, upgraded to 4.4.0. I tried running transpec --rspec-command "bundle exec rspec --require ./transpec_analysis_helper.rb". I tried removing my .rspec file to run transpec. Still no love.

/Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.4.0/lib/factory_girl/definition_proxy.rb:42:in add_attribute': wrong number of arguments (5 for 1..2) (ArgumentError)
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.4.0/lib/factory_girl/definition_proxy.rb:96:in method_missing' from /private/var/folders/jp/2sf9j3zd3vbd78xfn65zw7zr0000gn/T/d20140708-14106-1492sd/aperture/spec/factories.rb:133:in block (3 levels) in <top (required)>'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.4.0/lib/factory_girl/trait.rb:12:in instance_eval' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.4.0/lib/factory_girl/trait.rb:12:in initialize'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.4.0/lib/factory_girl/definition_proxy.rb:161:in new' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.4.0/lib/factory_girl/definition_proxy.rb:161:in trait'
from /private/var/folders/jp/2sf9j3zd3vbd78xfn65zw7zr0000gn/T/d20140708-14106-1492sd/aperture/spec/factories.rb:132:in block (2 levels) in <top (required)>' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.4.0/lib/factory_girl/syntax/default.rb:18:in instance_eval'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.4.0/lib/factory_girl/syntax/default.rb:18:in factory' from /private/var/folders/jp/2sf9j3zd3vbd78xfn65zw7zr0000gn/T/d20140708-14106-1492sd/aperture/spec/factories.rb:123:in block in <top (required)>'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.4.0/lib/factory_girl/syntax/default.rb:49:in instance_eval' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.4.0/lib/factory_girl/syntax/default.rb:49:in run'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.4.0/lib/factory_girl/syntax/default.rb:7:in define' from /private/var/folders/jp/2sf9j3zd3vbd78xfn65zw7zr0000gn/T/d20140708-14106-1492sd/aperture/spec/factories.rb:69:in <top (required)>'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:245:in load' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:245:in block in load'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:236:in load_dependency' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:245:in load'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.4.0/lib/factory_girl/find_definitions.rb:16:in block in find_definitions' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.4.0/lib/factory_girl/find_definitions.rb:15:in each'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.4.0/lib/factory_girl/find_definitions.rb:15:in find_definitions' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl_rails-4.4.1/lib/factory_girl_rails/railtie.rb:21:in block in class:Railtie'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/lazy_load_hooks.rb:34:in call' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/lazy_load_hooks.rb:34:in execute_hook'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/lazy_load_hooks.rb:26:in block in on_load' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/lazy_load_hooks.rb:25:in each'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/lazy_load_hooks.rb:25:in on_load' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-3.2.18/lib/rails/railtie/configuration.rb:59:in after_initialize'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl_rails-4.4.1/lib/factory_girl_rails/railtie.rb:20:in <class:Railtie>' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl_rails-4.4.1/lib/factory_girl_rails/railtie.rb:6:in module:FactoryGirl'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl_rails-4.4.1/lib/factory_girl_rails/railtie.rb:5:in <top (required)>' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in require'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in block in require' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:236:in load_dependency'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in require' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl_rails-4.4.1/lib/factory_girl_rails.rb:1:in <top (required)>'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in require' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in block in require'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:236:in load_dependency' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in require'
from /private/var/folders/jp/2sf9j3zd3vbd78xfn65zw7zr0000gn/T/d20140708-14106-1492sd/aperture/spec/spec_helper.rb:8:in <top (required)>' from /private/var/folders/jp/2sf9j3zd3vbd78xfn65zw7zr0000gn/T/d20140708-14106-1492sd/aperture/spec/admin/clients_spec.rb:1:in require'
from /private/var/folders/jp/2sf9j3zd3vbd78xfn65zw7zr0000gn/T/d20140708-14106-1492sd/aperture/spec/admin/clients_spec.rb:1:in <top (required)>' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in load'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in block in load_spec_files' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in each'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in load_spec_files' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/command_line.rb:18:in run'
from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/runner.rb:103:in run' from /Users/robind/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/runner.rb:17:in block in autorun'`

@sgringwe
Copy link
Author

sgringwe commented Jul 8, 2014

@yujinakayama i indeed had '--require spec_helper' in my .rspec file. That must have been it.

@yujinakayama
Copy link
Owner

@RobinDaugherty I was just investigating the issue :). It seems that @sgringwe's issue and @inukshuk's one were different. It's caused by undefining Object methods by factory_girl. I'm almost finishing fix for this.

@yujinakayama
Copy link
Owner

Relesed version 2.3.3 with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants