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 #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 #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']
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 }`.
Since structs respond to `.first`, Draper thinks they're collections and
always tries to wrap them in CollectionDecorators, which is surprising!
This is similar to the issue and fix in [#259].
Calling `#decorate` on an unsaved collection association forced a
db lookup, clearing any items that have been added (e.g. using
`#build`).
Closes#518.
To use different decorators in different contexts (e.g. HTML rendering
vs. API representation), the ability to specify a decorator namespace is
added. For example:
> Product.new.decorate
=> #<ProductDecorator:0x0000010b6e47e8>
> Product.new.decorate(:namespace => HTML)
=> #<HTML::ProductDecorator:0x0000010b6e47e9>