RestxSpecLoader { public RestxSpec load(String resource) throws IOException { return load(resource, Resources.asCharSource( MoreResources.getResource(resource, true), Charsets.UTF_8)); } @Inject  RestxSpecLoader(Factory factory);  RestxSpecLoader(Set<NamedComponent<GivenLoader>> givenLoaders,
                           Set<NamedComponent<WhenHeaderLoader>> whenHeaderLoaders); RestxSpec load(String resource); RestxSpec load(String path, CharSource charSource);  }
@Test public void should_load_spec() throws Exception { RestxSpec spec = new RestxSpecLoader(Factory.getInstance()).load("cases/test/test.spec.yaml"); assertThat(spec.getTitle()).isEqualTo("should say hello"); assertThat(spec.getGiven()).hasSize(2); assertThat(spec.getGiven().get(0)).isInstanceOf(GivenTime.class); assertThat(((GivenTime) spec.getGiven().get(0)).getTime().getMillis()) .isEqualTo(DateTime.parse("2013-03-31T14:33:18.272+02:00").getMillis()); assertThat(spec.getGiven().get(1)).isInstanceOf(GivenUUIDGenerator.class); assertThat(((GivenUUIDGenerator) spec.getGiven().get(1)).getPlaybackUUIDs()).containsExactly("123456"); assertThat(spec.getWhens()).extracting("method", "path").containsExactly(Tuple.tuple("GET", "message/xavier")); assertThat(spec.getWhens()).extracting("then").extracting("expectedCode", "expected") .containsExactly(Tuple.tuple(200, "{\"message\":\"hello xavier, it's 14:33:18\"}")); }