Skip to content
Open
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
1 change: 1 addition & 0 deletions lib/i18n/tasks/scanners/ruby_scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def setup_ast_matchers
AstMatchers::MessageReceiversMatcher.new(
receivers: [
AST::Node.new(:const, [nil, :I18n]),
AST::Node.new(:const, [AST::Node.new(:cbase), :I18n]),
nil
],
message: message,
Expand Down
39 changes: 39 additions & 0 deletions spec/ruby_scanner_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# frozen_string_literal: true

require "spec_helper"
require "tempfile"

RSpec.describe "I18n::Tasks::Scanners::RubyScanner" do
describe "#scan_file" do
subject do
I18n::Tasks::Scanners::RubyScanner.new.send(:scan_file, tempfile.path)
end

let(:tempfile) do
tempfile = Tempfile.new
tempfile.write(source)
tempfile.flush
tempfile
end

context "when source contains I18n.t calls" do
let(:source) do
<<~RUBY
I18n.t("foo")
RUBY
end

it { is_expected.to be_present }
end

context "when source contains ::I18n.t calls" do
let(:source) do
<<~RUBY
::I18n.t("foo")
RUBY
end

it { is_expected.to be_present }
end
end
end
Loading