Skip to content

Commit

Permalink
step matches command
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Meyer committed Jun 20, 2015
1 parent cf1789b commit 7a2325b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
13 changes: 12 additions & 1 deletion command_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,19 @@ func (parser *wire_command_parser) parse(command []byte) wire_command {
case "end_scenario":
return &wire_command_end_scenario{}
case "step_matches":
return &wire_command_step_matches{}
return parse_step_matches(raw_command[1])
}

return nil
}

func parse_step_matches(raw_arguments json.RawMessage) wire_command {
type name_to_match struct {
Pattern string `json:"name_to_match"`
}

var arguments name_to_match
json.Unmarshal(raw_arguments, &arguments)

return &wire_command_step_matches{arguments.Pattern}
}
11 changes: 11 additions & 0 deletions command_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,14 @@ func Test_parsing_step_matches_returns_a_corresponding_command_object(t *testing
expected := &wire_command_step_matches{}
assert.IsType(t, expected, command)
}

func Test_step_name_to_match_is_stored_step_matches_command(t *testing.T) {
testee := wire_command_parser{}

pattern := "given pattern"
command_string := []byte(`["step_matches",{"name_to_match":"` + pattern + `"}]`)

command := testee.parse(command_string).(*wire_command_step_matches)

assert.Equal(t, pattern, command.name_to_match)
}
1 change: 1 addition & 0 deletions wire_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func (command *wire_command_end_scenario) execute(steps steps) wire_response {
}

type wire_command_step_matches struct {
name_to_match string
}

func (command *wire_command_step_matches) execute(steps steps) wire_response {
Expand Down

0 comments on commit 7a2325b

Please sign in to comment.