-
Notifications
You must be signed in to change notification settings - Fork 526
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
Rspec3 Updates: Spec Syntax, Generators, and Monkey-Patching (continued) #853
Draft
codebycliff
wants to merge
34
commits into
master
Choose a base branch
from
feature/rspec3-updates
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
036be08
Update the rest of the specs to rspec3 syntax
mcasper 46f97aa
rspec-rails ~> 3.2 uses rails_helper fixes #668
59bdeb1
RSpec is now into the whole type based tagging
66c5b39
Merge PR #668 #675 from drapergem/master
baberthal 2ae00ef
Update .gitignore.
baberthal ed5c3c6
Refactored spec setup and helpers
baberthal 354b7e9
Moved back to separated spec & spec/dummy/spec
baberthal adfa1a4
Updated spec/draper to RSpec 3.0 syntax
baberthal eb1a9d1
update to RSpec 3.0 syntax
baberthal eebd252
Update to RSpec 3.0 syntax
baberthal bd806b5
Update spec_helper to disable monkey_patching, other RSpec 3.0 updates
baberthal 1ce287d
Update RSpec decorator spec generator to use RSpec::Core::Version, be…
baberthal 67e4ebb
update dummy fast_spec to RSpec 3.0 syntax
baberthal e90d553
ignore rspec_results files
baberthal aa5d239
Add pry to development group gemfile, update Guardfile fore new guard…
baberthal c4c7fdf
update integration spec for RSpec 3.0 syntax
baberthal 85ff30e
Update .travis.yml for more ruby versions
baberthal a4b87c2
Ignore binstubs
baberthal 4a6d3ec
update to RSpec 3.3
baberthal 80db110
should -> is_expected.to
baberthal e9d44fd
Modify spec/rails_helper.
baberthal 84a2365
RSpec decorator_spec generator. Fixes #668
baberthal 7db14de
Update .gitignore.
baberthal 89ca930
Update to RSpec 3.3
baberthal f4bb26b
Updated all specs to RSpec 3.0 syntax
baberthal 406f962
Gemfile and Guardfile Edits
baberthal 7063cd6
Travis.yml
baberthal b709770
Merge branch 'master' of https://github.com/baberthal/draper
baberthal 4109534
Don't verify partial doubles because it breaks some specs
baberthal 66bc7ad
Merge branch 'mcasper/update_to_rspec_3_syntax'
baberthal d358537
rspec-rails ~> 3.3. Fixes #668. Update Spec Synax
978fad0
moved all the specs to the right place
baberthal deaef72
Fixed Issue with RSpec Version Check
baberthal cb9af6c
Merge remote-tracking branch 'origin/master' into feature/rspec3-updates
codebycliff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
require 'rails_helper' | ||
<% require 'rspec/version' %> | ||
<% if RSpec::Version::STRING.match(/\A3\.[^10]/) %> | ||
require 'rails_helper' | ||
<% else %> | ||
require 'spec_helper' | ||
<% end %> | ||
|
||
RSpec.describe <%= class_name %>Decorator do | ||
RSpec.describe <%= class_name %>Decorator, type: :decorator do | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
require 'spec_helper' | ||
require 'shared_examples/decoratable' | ||
require_relative '../spec_helper' | ||
require_relative '../shared_examples/decoratable' | ||
|
||
if defined?(Mongoid) | ||
describe MongoidPost do | ||
RSpec.describe MongoidPost do | ||
it_behaves_like "a decoratable model" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
ENV['RAILS_ENV'] ||= 'test' | ||
require File.expand_path('../../config/environment', __FILE__) | ||
# Prevent database truncation if the environment is production | ||
abort('Rails is running in production mode!') if Rails.env.production? | ||
require 'spec_helper' | ||
require 'rspec/rails' | ||
# Add additional requires below this line. Rails is not loaded until this point! | ||
|
||
# Requires supporting ruby files with custom matchers and macros, etc, in | ||
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are | ||
# run as spec files by default. This means that files in spec/support that end | ||
# in _spec.rb will both be required and run as specs, causing the specs to be | ||
# run twice. It is recommended that you do not name files matching this glob to | ||
# end with _spec.rb. You can configure this pattern with the --pattern | ||
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. | ||
# | ||
# The following line is provided for convenience purposes. It has the downside | ||
# of increasing the boot-up time by auto-requiring all files in the support | ||
# directory. Alternatively, in the individual `*_spec.rb` files, manually | ||
# require only the support files necessary. | ||
# | ||
# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } | ||
|
||
# Checks for pending migrations before tests are run. | ||
# If you are not using ActiveRecord, you can remove this line. | ||
unless ENV['RAILS_VERSION'] == '4.0' | ||
ActiveRecord::Migration.maintain_test_schema! | ||
end | ||
|
||
RSpec.configure do |config| | ||
config.fixture_path = "#{::Rails.root}/spec/fixtures" | ||
config.use_transactional_fixtures = true | ||
config.infer_spec_type_from_file_location! | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,60 @@ | ||
ENV['RAILS_ENV'] ||= 'test' | ||
require File.expand_path('../../config/environment', __FILE__) | ||
require 'rspec/rails' | ||
|
||
RSpec.configure do |config| | ||
config.expect_with(:rspec) {|c| c.syntax = :expect} | ||
config.expect_with :rspec do |expectations| | ||
expectations.include_chain_clauses_in_custom_matcher_descriptions = true | ||
end | ||
|
||
config.mock_with :rspec do |mocks| | ||
mocks.verify_partial_doubles = true | ||
end | ||
|
||
config.disable_monkey_patching! | ||
|
||
# The settings below are suggested to provide a good initial experience | ||
# with RSpec, but feel free to customize to your heart's content. | ||
=begin | ||
# These two settings work together to allow you to limit a spec run | ||
# to individual examples or groups you care about by tagging them with | ||
# `:focus` metadata. When nothing is tagged with `:focus`, all examples | ||
# get run. | ||
config.filter_run :focus | ||
config.run_all_when_everything_filtered = true | ||
|
||
# Allows RSpec to persist some state between runs in order to support | ||
# the `--only-failures` and `--next-failure` CLI options. We recommend | ||
# you configure your source control system to ignore this file. | ||
config.example_status_persistence_file_path = "spec/examples.txt" | ||
|
||
# Limits the available syntax to the non-monkey patched syntax that is | ||
# recommended. For more details, see: | ||
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax | ||
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ | ||
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching | ||
|
||
# Many RSpec users commonly either run the entire suite or an individual | ||
# file, and it's useful to allow more verbose output when running an | ||
# individual spec file. | ||
if config.files_to_run.one? | ||
# Use the documentation formatter for detailed output, | ||
# unless a formatter has already been configured | ||
# (e.g. via a command-line flag). | ||
config.default_formatter = 'doc' | ||
end | ||
|
||
# Print the 10 slowest examples and example groups at the | ||
# end of the spec run, to help surface which specs are running | ||
# particularly slow. | ||
config.profile_examples = 10 | ||
|
||
# Run specs in random order to surface order dependencies. If you find an | ||
# order dependency and want to debug it, you can fix the order by providing | ||
# the seed, which is printed after each run. | ||
# --seed 1234 | ||
config.order = :random | ||
|
||
# Seed global randomization in this process using the `--seed` CLI option. | ||
# Setting this allows you to use `--seed` to deterministically reproduce | ||
# test failures related to randomization by passing the same `--seed` value | ||
# as the one that triggered the failure. | ||
Kernel.srand config.seed | ||
=end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What rspec versions are you trying to test for here with 3 not followed by a 1 or a 0? Are you trying to do rspec version greater than 3.2? That should prob be doc'd in comment, but also, that regexp will fail if rspec gets to 3.10, which it's not far from.
You may be able to use this instead?
Which is self-evident enough not to require a comment doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the code you have provided is a lot less brittle. This work was originally done by someone else, I just fixed the conflicts and re-opened the pull request. I can only assume they were trying to achieve what you stated above. I haven't had a lot of time lately to work on this. If you are interested in cleaning this up and getting it pushed through, you are more than welcome to take it over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think the highest priority is actually improving the template for the decorator specs that Draper generates -- this file we're commenting on now.
The rest of the PR seems to be about changing Draper's own specs -- but if Draper's specs currently pass, that doesn't seem to be as much of a priority, as it doesn't really effect the developer users of Draper, like the Draper generator for specs in your own app does.
So if I can find the time, I might open another PR just focusing on that? It sounds like you are a Draper committer/maintainer, so I have some sense that if I can find time to do that, it'll have some chance of being reviewed/merged and my work won't be in vain? :) Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that makes perfect sense. I'd love to see that get improved. And yes, I will be able to review and merge. Sometimes I'm slower to review that I'd personally like, so if that becomes the case, just bug me. Thanks for the help!