Updated API example to now use FeatureContext func name rather than featureContext, also updated the screenshots
Этот коммит содержится в:
		
							родитель
							
								
									6b2d813498
								
							
						
					
					
						коммит
						ab47cd9af0
					
				
					 3 изменённых файлов: 6 добавлений и 5 удалений
				
			
		| 
						 | 
					@ -11,7 +11,7 @@ error responses.
 | 
				
			||||||
``` gherkin
 | 
					``` gherkin
 | 
				
			||||||
# file: version.feature
 | 
					# file: version.feature
 | 
				
			||||||
Feature: get version
 | 
					Feature: get version
 | 
				
			||||||
  In order to know API version
 | 
					  In order to know godog version
 | 
				
			||||||
  As an API user
 | 
					  As an API user
 | 
				
			||||||
  I need to be able to request version
 | 
					  I need to be able to request version
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,7 +31,7 @@ Feature: get version
 | 
				
			||||||
    And the response should match json:
 | 
					    And the response should match json:
 | 
				
			||||||
      """
 | 
					      """
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        "version": "v0.2.0"
 | 
					        "version": "v0.5.3"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      """
 | 
					      """
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
| 
						 | 
					@ -75,7 +75,7 @@ func (a *apiFeature) theResponseShouldMatchJSON(body *gherkin.DocString) error {
 | 
				
			||||||
	return godog.ErrPending
 | 
						return godog.ErrPending
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func featureContext(s *godog.Suite) {
 | 
					func FeatureContext(s *godog.Suite) {
 | 
				
			||||||
	api := &apiFeature{}
 | 
						api := &apiFeature{}
 | 
				
			||||||
	s.Step(`^I send "([^"]*)" request to "([^"]*)"$`, api.iSendrequestTo)
 | 
						s.Step(`^I send "([^"]*)" request to "([^"]*)"$`, api.iSendrequestTo)
 | 
				
			||||||
	s.Step(`^the response code should be (\d+)$`, api.theResponseCodeShouldBe)
 | 
						s.Step(`^the response code should be (\d+)$`, api.theResponseCodeShouldBe)
 | 
				
			||||||
| 
						 | 
					@ -99,7 +99,7 @@ import (
 | 
				
			||||||
	"net/http/httptest"
 | 
						"net/http/httptest"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/DATA-DOG/godog"
 | 
						"github.com/DATA-DOG/godog"
 | 
				
			||||||
	"gopkg.in/cucumber/gherkin-go.v3"
 | 
						"github.com/DATA-DOG/godog/gherkin"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type apiFeature struct {
 | 
					type apiFeature struct {
 | 
				
			||||||
| 
						 | 
					@ -158,7 +158,7 @@ func (a *apiFeature) theResponseShouldMatchJSON(body *gherkin.DocString) (err er
 | 
				
			||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func featureContext(s *godog.Suite) {
 | 
					func FeatureContext(s *godog.Suite) {
 | 
				
			||||||
	api := &apiFeature{}
 | 
						api := &apiFeature{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	s.BeforeScenario(api.resetResponse)
 | 
						s.BeforeScenario(api.resetResponse)
 | 
				
			||||||
| 
						 | 
					@ -184,6 +184,7 @@ Finally, lets implement the **api** server:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
``` go
 | 
					``` go
 | 
				
			||||||
// file: api.go
 | 
					// file: api.go
 | 
				
			||||||
 | 
					// Example - demonstrates REST API server implementation tests.
 | 
				
			||||||
package main
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										
											Двоичные данные
										
									
								
								examples/api/screenshots/passed.png
									
										
									
									
									
								
							
							
						
						
									
										
											Двоичные данные
										
									
								
								examples/api/screenshots/passed.png
									
										
									
									
									
								
							
										
											Двоичный файл не отображается.
										
									
								
							| 
		 До Ширина: | Высота: | Размер: 124 КиБ После Ширина: | Высота: | Размер: 75 КиБ  | 
							
								
								
									
										
											Двоичные данные
										
									
								
								examples/api/screenshots/undefined.png
									
										
									
									
									
								
							
							
						
						
									
										
											Двоичные данные
										
									
								
								examples/api/screenshots/undefined.png
									
										
									
									
									
								
							
										
											Двоичный файл не отображается.
										
									
								
							| 
		 До Ширина: | Высота: | Размер: 148 КиБ После Ширина: | Высота: | Размер: 99 КиБ  | 
		Загрузка…
	
	Создание таблицы
		
		Сослаться в новой задаче