smrunner: dependency on ruby module removed
[fedora-idea.git] / smRunner / testSrc / com / intellij / execution / testframework / sm / FileUrlLocationTest.java
blob151028c2ab4993996955ef6a19fb510f535cb2cd
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;
7 /**
8 * @author Roman Chernyatchik
9 */
10 public class FileUrlLocationTest extends SMLightFixtureTestCase {
11 @Override
12 protected LightProjectDescriptor getProjectDescriptor() {
13 return ourDescriptor;
16 public void testSpecNavigation() throws Throwable {
17 createAndAddFile("my_example_spec.rb",
18 "\n" +
19 "require \"spec\"\n" +
20 "\n" +
21 "describe \"Blabla\" do\n" +
22 "\n" +
23 " # Called before each example.\n" +
24 " before(:each) do\n" +
25 " # Do nothing\n" +
26 " end\n" +
27 "\n" +
28 " # Called after each example.\n" +
29 " after(:each) do\n" +
30 " # Do nothing\n" +
31 " end\n" +
32 "\n" +
33 " it \"should fail\" do\n" +
34 "\n" +
35 " #should pass\n" +
36 " true.should == false\n" +
37 " end\n" +
38 "\n" +
39 " it \"should pass\" do\n" +
40 "\n" +
41 " #should pass\n" +
42 " true.should == true\n" +
43 " end\n" +
44 "end");
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));