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

Generator needs update for Rspec ~> 3.2 #668

Closed
Epigene opened this issue Apr 30, 2015 · 1 comment
Closed

Generator needs update for Rspec ~> 3.2 #668

Epigene opened this issue Apr 30, 2015 · 1 comment

Comments

@Epigene
Copy link

Epigene commented Apr 30, 2015

I have a User model that I want to decorate, so I started by generating the decorator:
rails g decorator User

This created two files:
/app/decorators/user_decorator.rb
/spec/decorators/user_decorator_spec.rb

user_decorator_spec.rb is populated with this code:

require 'spec_helper'

describe UserDecorator do
end

Recent Rspec uses require 'rails_helper'. Since I overlooked this difference, the errors had me going in circles for a couple hours.

Perhaps the generator can be smart about this recent development and modify the require line accordingly based on rspec version?

krainboltgreene pushed a commit to krainboltgreene/draper that referenced this issue May 24, 2015
As of rspec-rails 3.2 they generate two files:

  - spec/spec_helper.rb
  - spec/rails_helper.rb

This allows the user to either do pure ruby unit tests or include the entire rails environment. Draper really only works in a rails application if it has the rails environment. This matches ~> 3.2 and uses the rails_helper instead of spec_helper.
baberthal added a commit to baberthal/draper that referenced this issue Aug 25, 2015
Fix Spec spec generator because RSpec no longer prefers monkey-patching.
baberthal added a commit to baberthal/draper that referenced this issue Aug 27, 2015
Fix Spec spec generator because RSpec no longer prefers
monkey-patching. Refactor PR drapergem#675 to be more concise re RSpec Version
check, and to use RSpec::Core::Version rather than
RSpec::Rails::Version, because the latter does not exist.
baberthal pushed a commit to baberthal/draper that referenced this issue Aug 27, 2015
As of rspec-rails 3.3 they generate two files:

  - spec/spec_helper.rb
  - spec/rails_helper.rb

This allows the user to either do pure ruby unit tests or include the entire
rails environment. Draper really only works in a rails application if it has the
rails environment. This matches ~> 3.2 and uses the rails_helper instead of
spec_helper for the dummy app specs, but the standard spec_helper for
the draper specs.

Fix Spec spec generator because RSpec no longer prefers
monkey-patching. Refactor PR drapergem#675 to be more concise re RSpec Version
check, and to use RSpec::Core::Version rather than
RSpec::Rails::Version, in case the latter does not exist.

Updated all specs to RSpec 3.0 syntax
=====================================

Change specs to use synax `expect(OBJECT).to EXPECTATION` rather that
`OBJECT.should`. Changed all `OBJECT.stub(METHOD)` to `allow(OBJECT).to
receive(:method)`

Change one-liners to use syntax: `it { is_expected.to XXX }` rather than
`it { should }`.

Merge PR drapergem#674 from @mcasper and fix all trivial conflicts (i.e
`allow(OBJ).to receive(:message)` vs `allow(OBJ).to receive_messages`)

Gitignore
=========

Ignore .ruby_version and .ruby_gemset

Spec Helper
===========
ActiveRecord::Migration.maintain_test_schema! is undefined in Rails
4.0, so I made that method conditional upon ENV['RAILS_VERSION']
@ivanovaleksey
Copy link

Seems like this one can be closed.
RSpec generator's template has been updated here.

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

No branches or pull requests

3 participants