Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit c13817f

Browse files
committed
Merge pull request #520 from rspec/add-spec-for-source-token-one-liner
Add spec for ruby one line method definition change in closed_by
1 parent 0310777 commit c13817f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

spec/rspec/support/source/token_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ class RSpec::Support::Source
2626
# [[1, 6], :on_ident, "foo"]
2727
# ]
2828

29+
describe "#closed_by" do
30+
context "with a normal ruby multi line method" do
31+
let(:source) { "def foo\n :bar\nend" }
32+
33+
specify 'the first token is closed by the last' do
34+
expect(tokens.first).to be_closed_by(tokens.last)
35+
end
36+
end
37+
38+
context "with a ruby one line method definition" do
39+
let(:source) { 'def self.foo = "bar"' }
40+
41+
specify 'the first token is closed by the =' do
42+
expect(tokens.first).to be_closed_by(tokens[6])
43+
end
44+
end
45+
end
46+
2947
describe '#location' do
3048
it 'returns a Location object with line and column numbers' do
3149
expect(target_token.location).to have_attributes(:line => 1, :column => 0)

0 commit comments

Comments
 (0)