Skip to content

Commit

Permalink
Travis build change: Fix build, use latest JRuby
Browse files Browse the repository at this point in the history
  - Lint only 1 time, on modern Ruby
  • Loading branch information
olleolleolle authored and thomasklemm committed May 11, 2017
1 parent 0e3a11c commit f60d059
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 26 deletions.
13 changes: 11 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
inherit_from: .rubocop_todo.yml
AllCops:
DisplayCopNames: true
TargetRubyVersion: 1.9
Exclude:
- "gemfiles/**/*"
- "vendor/**/*"
- "lib/generators/**/*"

Metrics/BlockLength:
Exclude:
- "**/*_spec.rb"

Metrics/MethodLength:
Max: 40

Metrics/ModuleLength:
Max: 200
Exclude:
- "**/*_spec.rb"

Metrics/LineLength:
Max: 120
Expand Down Expand Up @@ -50,7 +59,7 @@ Documentation:
Enabled: false # TODO: Enable again once we have more docs

Style/CaseIndentation:
IndentWhenRelativeTo: case
EnforcedStyle: case
SupportedStyles:
- case
- end
Expand All @@ -74,7 +83,7 @@ Style/TrivialAccessors:
ExactNameMatch: true

Lint/EndAlignment:
AlignWith: variable
EnforcedStyleAlignWith: variable

Lint/DefEndAlignment:
Enabled: false
Expand Down
13 changes: 13 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-12-06 09:57:39 +0100 using RuboCop version 0.41.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Cop supports --auto-correct.
Lint/UnneededDisable:
Exclude:
- 'lib/pundit/rspec.rb'
28 changes: 18 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
language: ruby
sudo: false
rvm:
- 2.0.0
- 2.1
- 2.2
- 2.3.0
- jruby-19mode
- rbx-2
env:
- RSPEC_VERSION="<2.99"
- RSPEC_VERSION="~>3.0
before_install:
- gem update --system
- gem install bundler

matrix:
include:
- rvm: 2.4.0
script: bundle exec rake rubocop # ONLY lint once, first
- rvm: 2.1
- rvm: 2.2
- rvm: 2.3.3
- rvm: 2.4.0
- rvm: jruby-1.7.26
env:
- JRUBY_OPTS="--debug"
- rvm: jruby-9.1.8.0
env:
- JRUBY_OPTS="--debug"
14 changes: 13 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
source "https://rubygems.org"

gem "rspec", ENV["RSPEC_VERSION"] unless ENV["RSPEC_VERSION"].to_s.empty?
ruby RUBY_VERSION

gemspec

group :development, :test do
gem "actionpack"
gem "activemodel"
gem "bundler"
gem "pry"
gem "rake"
gem "rspec"
gem "rubocop"
gem "yard"
end
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ YARD::Rake::YardocTask.new do |t|
end

task default: :spec
task default: :rubocop unless RUBY_ENGINE == "rbx"
1 change: 1 addition & 0 deletions lib/pundit/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module RSpec
module Matchers
extend ::RSpec::Matchers::DSL

# rubocop:disable Metrics/BlockLength
matcher :permit do |user, record|
match_proc = lambda do |policy|
@violating_permissions = permissions.find_all do |permission|
Expand Down
8 changes: 0 additions & 8 deletions pundit.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,4 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"]

gem.add_dependency "activesupport", ">= 3.0.0"
gem.add_development_dependency "activemodel", ">= 3.0.0"
gem.add_development_dependency "actionpack", ">= 3.0.0"
gem.add_development_dependency "bundler", "~> 1.3"
gem.add_development_dependency "rspec", ">=2.0.0"
gem.add_development_dependency "pry"
gem.add_development_dependency "rake"
gem.add_development_dependency "yard"
gem.add_development_dependency "rubocop"
end
15 changes: 11 additions & 4 deletions spec/pundit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@
admin: true
})

expect(Controller.new(user, params).permitted_attributes(post)).to eq("title" => "Hello", "votes" => 5)
expect(Controller.new(double, params).permitted_attributes(post)).to eq("votes" => 5)
expect(Controller.new(user, params).permitted_attributes(post).to_h).to eq("title" => "Hello", "votes" => 5)
expect(Controller.new(double, params).permitted_attributes(post).to_h).to eq("votes" => 5)
end

it "checks policy for permitted attributes for record of a ActiveModel type" do
Expand All @@ -444,6 +444,13 @@

expect(Controller.new(user, params).permitted_attributes(customer_post)).to eq("title" => "Hello", "votes" => 5)
expect(Controller.new(double, params).permitted_attributes(customer_post)).to eq("votes" => 5)
expect(Controller.new(user, params).permitted_attributes(customer_post).to_h).to eq(
"title" => "Hello",
"votes" => 5
)
expect(Controller.new(double, params).permitted_attributes(customer_post).to_h).to eq(
"votes" => 5
)
end
end

Expand All @@ -456,7 +463,7 @@
admin: true
})

expect(Controller.new(user, params).permitted_attributes(post)).to eq("body" => "blah")
expect(Controller.new(user, params).permitted_attributes(post).to_h).to eq("body" => "blah")
end

it "can be explicitly set" do
Expand All @@ -467,7 +474,7 @@
admin: true
})

expect(Controller.new(user, params).permitted_attributes(post, :revise)).to eq("body" => "blah")
expect(Controller.new(user, params).permitted_attributes(post, :revise).to_h).to eq("body" => "blah")
end
end

Expand Down

0 comments on commit f60d059

Please sign in to comment.