Skip to content

add whitespace checks and fix end of line whitespace #1438

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

Merged
merged 1 commit into from
Aug 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions features/Transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ already ran. For example:
it "does something" do
expect(@widget).to do_something
end

it "does something else" do
expect(@widget).to do_something_else
end
Expand All @@ -47,7 +47,7 @@ already ran. For example:
The `@widget` is recreated in each of the two examples above, so each example
has a different object, _and_ the underlying data is rolled back so the data
backing the `@widget` in each example is new.

### Data created in `before(:all)` are _not_ rolled back

`before(:all)` hooks are invoked before the transaction is opened. You can use
Expand Down
7 changes: 3 additions & 4 deletions features/controller_specs/Cookies.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ the following guidelines:
* Access cookies through the `request` and `response` objects in the spec.
* Use `request.cookies` before the action to set up state.
* Use `response.cookies` after the action to specify outcomes.
* Use the `cookies` object in the controller action.
* Use the `cookies` object in the controller action.
* Use String keys.

<pre>
Expand Down Expand Up @@ -42,7 +42,7 @@ sticking with string keys for consistency.

The `cookies` method combines the `request` and `response` cookies. This can
lead to confusion when setting cookies in the example in order to set up state
for the controller action.
for the controller action.

# does not work in rails 3.0.0 > 3.1.0
cookies['foo'] = 'bar' # this is not visible in the controller
Expand All @@ -51,7 +51,6 @@ for the controller action.
### Future versions of Rails

There is code in the master branch in rails that makes cookie access more
consistent so you can use the same `cookies` object before and after the action,
consistent so you can use the same `cookies` object before and after the action,
and you can use String or Symbol keys. We'll update these docs accordingly when
that is released.

2 changes: 1 addition & 1 deletion features/matchers/new_record_matcher.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature: be_a_new matcher
You can also chain `with` on `be_a_new` with a hash of attributes to specify
the subject has equal attributes.

Scenario: example spec with four be_a_new possibilities
Scenario: example spec with four be_a_new possibilities
Given a file named "spec/models/widget_spec.rb" with:
"""ruby
require "rails_helper"
Expand Down
26 changes: 26 additions & 0 deletions spec/rspec/rails_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'rspec/support/spec/library_wide_checks'

RSpec.describe "RSpec::Rails" do
include RSpec::Support::WhitespaceChecks

# Pasted from rspec-support lib/rspec/support/spec/library_wide_checks.rb:134
# Easier to do that here than to extract it out
RSpec::Matchers.define :be_well_formed do
match do |actual|
actual.empty?
end

failure_message do |actual|
actual.join("\n")
end
end

it "has no malformed whitespace", :slow do
error_messages = []
`git ls-files -z`.split("\x0").each do |filename|
error_messages << check_for_tab_characters(filename)
error_messages << check_for_extra_spaces(filename)
end
expect(error_messages.compact).to be_well_formed
end
end