1 package com
.intellij
.execution
.testframework
.sm
;
3 import com
.intellij
.execution
.Location
;
4 import com
.intellij
.execution
.testframework
.sm
.runner
.SMTestProxy
;
5 import com
.intellij
.testFramework
.LightProjectDescriptor
;
8 * @author Roman Chernyatchik
10 public class FileUrlLocationTest
extends SMLightFixtureTestCase
{
12 protected LightProjectDescriptor
getProjectDescriptor() {
16 public void testSpecNavigation() throws Throwable
{
17 createAndAddFile("my_example_spec.rb",
19 "require \"spec\"\n" +
21 "describe \"Blabla\" do\n" +
23 " # Called before each example.\n" +
24 " before(:each) do\n" +
28 " # Called after each example.\n" +
29 " after(:each) do\n" +
33 " it \"should fail\" do\n" +
36 " true.should == false\n" +
39 " it \"should pass\" do\n" +
42 " true.should == true\n" +
46 final String path
= myFixture
.getFile().getVirtualFile().getPath();
47 doTest(17, "describe", path
, 4);
48 doTest(189, "it", path
, 16);
49 doTest(261, "it", path
, 22);
52 private void doTest(final int expectedOffset
, final String expectedStartsWith
,
53 final String filePath
, final int lineNum
) {
54 final SMTestProxy testProxy
=
55 new SMTestProxy("myTest", false, "file://" + filePath
+ ":" + lineNum
);
57 final Location location
= testProxy
.getLocation(getProject());
58 assertNotNull(location
);
59 assertNotNull(location
.getPsiElement());
61 //System.out.println(location.getPsiElement().getText());
62 //System.out.println(location.getPsiElement().getTextOffset());
63 assertEquals(expectedOffset
, location
.getPsiElement().getTextOffset());
64 final String element
= location
.getPsiElement().getText();
65 assertTrue(element
, element
.startsWith(expectedStartsWith
));