Skip to content

Commit 01b95f5

Browse files
committed
fix test
1 parent c1d2437 commit 01b95f5

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

lib/restful_error.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
require "restful_error/railtie" if defined? ActionController
55
require "restful_error/status"
66

7-
I18n.load_path += Dir["#{File.expand_path("../config/locales")}/*.yml"]
7+
I18n.load_path += Dir["#{File.expand_path("../config/locales")}/*.yml"] if defined? I18n
88

99
module RestfulError
1010
class BaseError < StandardError; end
@@ -35,7 +35,7 @@ def const_missing(const_name)
3535

3636
def build_error_class_for(code)
3737
status = Status.new(code)
38-
message = I18n.t status.symbol, default: status.reason_phrase, scope: :restful_error
38+
message = defined?(I18n) ? I18n.t(status.symbol, default: status.reason_phrase, scope: :restful_error) : status.reason_phrase
3939
klass = Class.new(BaseError) do
4040
define_method(:http_status) { status.code }
4141
define_method(:restful) { status }

lib/restful_error/inflector.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ def underscore(word_)
88
return word_.underscore if word_.respond_to?(:underscore)
99

1010
word = word_.dup
11-
word = word.gsub!("::", "/")
12-
word = word.gsub!(/(?<=[A-Z])(?=[A-Z][a-z])|(?<=[a-z\d])(?=[A-Z])/, "_")
11+
word.gsub!("::", "/")
12+
word.gsub!(/(?<=[A-Z])(?=[A-Z][a-z])|(?<=[a-z\d])(?=[A-Z])/, "_")
1313
word.tr!("-", "_")
1414
word.downcase!
1515
end

spec/rack_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require 'action_controller'
12
require 'spec_helper'
23

34
describe 'RestfulError' do
@@ -11,7 +12,7 @@ def app
1112
env "action_dispatch.exception", RestfulError[404].new
1213
end
1314
it do
14-
get '/hoge'
15+
get '/404'
1516
expect(last_response.status).to eq 404
1617
end
1718
end

spec/restful_error_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
require "spec_helper"
44

55
describe RestfulError do
6-
it "has a version number" do
7-
expect(RestfulError::VERSION).not_to be_nil
8-
end
9-
106
describe "RestfullError[404]" do
117
subject { described_class[404].new }
128

0 commit comments

Comments
 (0)