cucumber_csteps 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/.ruby-version +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +104 -0
- data/Rakefile +7 -0
- data/bin/csteps-include-path +7 -0
- data/cucumber_csteps.gemspec +31 -0
- data/include/csteps.h +8 -0
- data/lib/cucumber_csteps.rb +5 -0
- data/lib/cucumber_csteps/c_snippets.rb +37 -0
- data/lib/cucumber_csteps/define_steps.rb +107 -0
- data/lib/cucumber_csteps/parser.rb +65 -0
- data/lib/cucumber_csteps/step_wrapper.rb +32 -0
- data/lib/cucumber_csteps/version.rb +3 -0
- data/spec/cucumber_csteps_spec.rb +72 -0
- data/spec/spec_helper.rb +5 -0
- metadata +180 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d34c16b322df1afd5a69ea61f6885a7a96e0de08
|
4
|
+
data.tar.gz: 5a232799fbede46d4814260f6192d2076e113870
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6e44711f44c3eb176ff94ee592c46c9f274ffcdd23f258bb6208e05b972b2567d0ae15d19f0f17bccdae5f6df9e88f942658bbddccd73004022b956106c4252c
|
7
|
+
data.tar.gz: 9a08e3438e8decc757495f0f0d907a9f223fb5916394e12c8721a1b7cf226f54461c919b3c935d29d1efdefc1918d4bcdebf729c838b3141cc8bbbfbd278c5f4
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Niclas Nilsson
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# cucumber_csteps
|
2
|
+
|
3
|
+
Write [Cucumber](https://github.com/cucumber/cucumber) step definitions in C (or C++)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'cucumber_csteps'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install cucumber_csteps
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Write your step definitions in this form
|
24
|
+
|
25
|
+
```c
|
26
|
+
#include <csteps.h>
|
27
|
+
|
28
|
+
// You need a uniq STEP_PREFIX per file
|
29
|
+
#define STEP_PREFIX atm_steps
|
30
|
+
|
31
|
+
GIVEN("^the account balance is (\d+)$") (int balance) {
|
32
|
+
// setup account
|
33
|
+
}
|
34
|
+
|
35
|
+
WHEN("^the account holder requests (\d+)$") (int amount) {
|
36
|
+
// make withdraval
|
37
|
+
}
|
38
|
+
|
39
|
+
THEN("^the account balance should be (\d+)$") (int balance) {
|
40
|
+
// assert correct behaviuor
|
41
|
+
}
|
42
|
+
```
|
43
|
+
|
44
|
+
Place your step definition files in features/step_definitions
|
45
|
+
|
46
|
+
Compile the code. The include path of <csteps.h> can be found by running
|
47
|
+
|
48
|
+
$ csteps-include-path
|
49
|
+
|
50
|
+
In order to cope with different dev environments, it is most feasible to run this command in your build, e.g. in a Makefile:
|
51
|
+
|
52
|
+
CSTEPS_INCLUDE_PATH = $(shell csteps-include-path)
|
53
|
+
|
54
|
+
Link your production code and step_definitions into a shared library.
|
55
|
+
|
56
|
+
Put this in features/support/env.rb (replace LIBNAME with the name of your library)
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
require 'cucumber_csteps'
|
60
|
+
CucumberCsteps.load_steps('LIBNAME', 'libLIBNAME.so', ["features/**/*.c"])
|
61
|
+
```
|
62
|
+
|
63
|
+
Run cucumber as you would normally:
|
64
|
+
|
65
|
+
$ cucumber
|
66
|
+
|
67
|
+
## Example
|
68
|
+
|
69
|
+
For a full working example, checkout [https://github.com/fooheads/cucumber_csteps-atm](https://github.com/fooheads/cucumber_csteps-atm)
|
70
|
+
|
71
|
+
## Contributing
|
72
|
+
|
73
|
+
1. Fork it ( https://github.com/[my-github-username]/cucumber_csteps/fork )
|
74
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
75
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
76
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
77
|
+
5. Create a new Pull Request
|
78
|
+
|
79
|
+
## License
|
80
|
+
|
81
|
+
(The MIT License)
|
82
|
+
|
83
|
+
Copyright (c) 2015 Fooheads AB <hello@fooheads.com>
|
84
|
+
|
85
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
86
|
+
a copy of this software and associated documentation files (the
|
87
|
+
'Software'), to deal in the Software without restriction, including
|
88
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
89
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
90
|
+
permit persons to whom the Software is furnished to do so, subject to
|
91
|
+
the following conditions:
|
92
|
+
|
93
|
+
The above copyright notice and this permission notice shall be
|
94
|
+
included in all copies or substantial portions of the Software.
|
95
|
+
|
96
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
97
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
98
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
99
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
100
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
101
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
102
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
103
|
+
|
104
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cucumber_csteps/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cucumber_csteps"
|
8
|
+
spec.version = CucumberCsteps::VERSION
|
9
|
+
spec.authors = ["Jon-Erling Dahl", "Niclas Nilsson"]
|
10
|
+
spec.email = ["jon-erling@fooheads.com", "niclas@fooheads.com"]
|
11
|
+
spec.summary = %q{Cucumber steps in C/C++}
|
12
|
+
spec.description = %q{Write your Cucumber steps in C/C++}
|
13
|
+
spec.homepage = "https://github.com/fooheads/cucumber_csteps"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
spec.add_development_dependency "dp", "~> 1.0"
|
25
|
+
|
26
|
+
spec.add_dependency "parslet", "~> 1.6"
|
27
|
+
spec.add_dependency "activesupport", "~> 4.2"
|
28
|
+
spec.add_dependency "cucumber", "~> 1.3"
|
29
|
+
spec.add_dependency "ffi", "~> 1.9"
|
30
|
+
end
|
31
|
+
|
data/include/csteps.h
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'cucumber/rb_support/snippet.rb'
|
2
|
+
|
3
|
+
# Hack to output C step definitions
|
4
|
+
module Cucumber
|
5
|
+
module RbSupport
|
6
|
+
module Snippet
|
7
|
+
class Regexp < BaseSnippet
|
8
|
+
def initialize(code_keyword, pattern, multiline_argument)
|
9
|
+
super(code_keyword.upcase, pattern, multiline_argument)
|
10
|
+
end
|
11
|
+
|
12
|
+
def do_block
|
13
|
+
do_block = ""
|
14
|
+
do_block << "(#{arguments}) {\n"
|
15
|
+
#multiline_argument.append_comment_to(do_block)
|
16
|
+
do_block << " //pending(); // Write code here that turns the phrase above into concrete actions\n"
|
17
|
+
do_block << "}"
|
18
|
+
do_block
|
19
|
+
end
|
20
|
+
|
21
|
+
def arguments
|
22
|
+
block_args = (0...number_of_arguments).map { |n| "some_t arg#{n+1}" }
|
23
|
+
block_args.empty? ? "" : "#{block_args.join(", ")}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def typed_pattern
|
27
|
+
@code_keyword = @code_keyword.upcase
|
28
|
+
"(\"^#{pattern}$\")"
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.description
|
32
|
+
"Snippets with parentheses"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
require_relative 'step_wrapper'
|
3
|
+
|
4
|
+
module CucumberCsteps
|
5
|
+
|
6
|
+
TYPE_MAP = {
|
7
|
+
'char*' => {ffi_type: ':string', cast_op: 'to_s'},
|
8
|
+
'const char*' => {ffi_type: ':string', cast_op: 'to_s'},
|
9
|
+
'int' => {ffi_type: ':int', cast_op: 'to_i'},
|
10
|
+
'float' => {ffi_type: ':float', cast_op: 'to_f'},
|
11
|
+
'double' => {ffi_type: ':double', cast_op: 'to_f'},
|
12
|
+
}
|
13
|
+
|
14
|
+
def self.load_steps(lib_name, lib_file, glob_patterns)
|
15
|
+
Dir.glob(glob_patterns).each do |file|
|
16
|
+
CucumberCsteps.define_steps(file, lib_name, lib_file).each do |regex, block|
|
17
|
+
Cucumber::RbSupport::RbDsl.register_rb_step_definition(regex, block)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.define_steps(filename, library_name, library_file)
|
23
|
+
module_name = library_name.camelize
|
24
|
+
module_code = %Q{
|
25
|
+
module #{module_name}
|
26
|
+
extend FFI::Library
|
27
|
+
ffi_lib ['#{library_name}', '#{library_file}']
|
28
|
+
|
29
|
+
begin
|
30
|
+
attach_function('before_scenario', [], :void)
|
31
|
+
before_hook = proc { #{module_name}.before_scenario() }
|
32
|
+
Cucumber::RbSupport::RbDsl.register_rb_hook('before', [], before_hook)
|
33
|
+
rescue FFI::NotFoundError
|
34
|
+
end
|
35
|
+
|
36
|
+
begin
|
37
|
+
attach_function('after_scenario', [], :void)
|
38
|
+
after_hook = proc { #{module_name}.after_scenario() }
|
39
|
+
Cucumber::RbSupport::RbDsl.register_rb_hook('after', [], proc { after_hook() })
|
40
|
+
rescue FFI::NotFoundError
|
41
|
+
end
|
42
|
+
end
|
43
|
+
}
|
44
|
+
|
45
|
+
eval(module_code)
|
46
|
+
|
47
|
+
step_prefix = find_step_prefix(filename)
|
48
|
+
step_definitions = find_step_definitions(filename)
|
49
|
+
step_definitions.map do |step_definition, line_number|
|
50
|
+
step = parse_cstep(step_definition)
|
51
|
+
fun_name = "#{step_prefix}#{line_number}".to_sym
|
52
|
+
args = step.c_args.map { |arg| TYPE_MAP[arg.type][:ffi_type] }.join(",")
|
53
|
+
|
54
|
+
attach_code = %Q{
|
55
|
+
module #{module_name}
|
56
|
+
#{fun_name} = attach_function('#{fun_name}', [#{args}], :void)
|
57
|
+
end
|
58
|
+
}
|
59
|
+
|
60
|
+
eval(attach_code)
|
61
|
+
|
62
|
+
lambda_args = step.c_args.map do |arg|
|
63
|
+
arg.identifier
|
64
|
+
end.join(",")
|
65
|
+
|
66
|
+
fun_args = step.c_args.map do |arg|
|
67
|
+
cast_op = TYPE_MAP[arg.type][:cast_op]
|
68
|
+
"#{arg.identifier}.#{cast_op}"
|
69
|
+
end.join(",")
|
70
|
+
|
71
|
+
code_block = %Q{lambda { |#{lambda_args}|
|
72
|
+
CucumberCsteps.try_and_catch_abort do
|
73
|
+
#{module_name}.#{fun_name}(#{fun_args})
|
74
|
+
end
|
75
|
+
}}
|
76
|
+
|
77
|
+
[step.regex, eval(code_block) ]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def self.find_step_prefix(filename)
|
84
|
+
step_prefix_regex = /#define\s+STEP_PREFIX\s+(\w+)/
|
85
|
+
code = File.read(filename)
|
86
|
+
|
87
|
+
prefixes = code.lines.select { |l| l =~ step_prefix_regex }
|
88
|
+
raise "Step file '#{filename}' contains #{prefixes.size} STEP_PREFIX definitions." if prefixes.size != 1
|
89
|
+
|
90
|
+
prefixes.first.match(step_prefix_regex)[1]
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.find_step_definitions(filename)
|
94
|
+
step_regex = /^\s*(GIVEN|WHEN|THEN)\s*(.*)/
|
95
|
+
code = File.read(filename)
|
96
|
+
|
97
|
+
matching_lines = []
|
98
|
+
code.lines.each_with_index do |line, line_number|
|
99
|
+
if line.match(step_regex)
|
100
|
+
matching_lines << [line, line_number + 1]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
matching_lines
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'parslet'
|
2
|
+
require 'active_support/core_ext/string'
|
3
|
+
|
4
|
+
module CucumberCsteps
|
5
|
+
|
6
|
+
def self.parse_cstep(s)
|
7
|
+
tree = CStepParser.new.parse(s)
|
8
|
+
CStepTransform.new.apply(tree)
|
9
|
+
end
|
10
|
+
|
11
|
+
class CStep < Struct.new(:keyword, :regex, :c_args)
|
12
|
+
end
|
13
|
+
|
14
|
+
class CArg < Struct.new(:type, :identifier)
|
15
|
+
end
|
16
|
+
|
17
|
+
class CStepParser < Parslet::Parser
|
18
|
+
# Single character rules
|
19
|
+
rule(:lparen) { str('(') >> space? }
|
20
|
+
rule(:rparen) { str(')') >> space? }
|
21
|
+
rule(:comma) { str(',') >> space? }
|
22
|
+
rule(:quote) { str('"') >> space? }
|
23
|
+
|
24
|
+
rule(:space) { match('\s').repeat(1) }
|
25
|
+
rule(:space?) { space.maybe }
|
26
|
+
|
27
|
+
rule(:keyword) { (str('GIVEN') | str('WHEN') | str('THEN')).as(:keyword) >> space? }
|
28
|
+
# rule(:anything) { inner_paren_group | match('[^()]').repeat(1) }
|
29
|
+
# rule(:inner_paren_group) { lparen >> anything.repeat(1) >> rparen }
|
30
|
+
# rule(:paren_group) { lparen >> anything.repeat(1).as(:regex) >> rparen }
|
31
|
+
|
32
|
+
rule(:c_identifier) { match('[^(),]').repeat(1) }
|
33
|
+
rule(:primitive_type) { (str('char*') | str('int') | str('long') | str('float')).as(:c_type) >> space? }
|
34
|
+
rule(:c_type) { primitive_type }
|
35
|
+
rule(:c_arg) { c_type >> c_identifier.as(:c_identifier) }
|
36
|
+
rule(:c_args) { lparen >> (c_arg.as(:c_arg) >> (comma >> c_arg.as(:c_arg)).repeat).maybe.as(:c_args) >> rparen }
|
37
|
+
rule(:garbage) { match('[^(),]').repeat }
|
38
|
+
|
39
|
+
rule(:anything) { str('\"') | match('[^"]') }
|
40
|
+
|
41
|
+
rule(:step_matcher) { lparen >> quote >> anything.repeat(1).as(:regex) >> quote >> rparen }
|
42
|
+
rule(:step) { space? >> keyword >> step_matcher >> c_args >> garbage }
|
43
|
+
|
44
|
+
root(:step)
|
45
|
+
end
|
46
|
+
|
47
|
+
class CStepTransform < Parslet::Transform
|
48
|
+
rule(
|
49
|
+
keyword: simple(:keyword),
|
50
|
+
regex: simple(:regex),
|
51
|
+
c_args: subtree(:args)) {
|
52
|
+
arguments = args.nil? ? [] : [args].flatten
|
53
|
+
|
54
|
+
CStep.new(
|
55
|
+
keyword.to_s.downcase.camelize ,
|
56
|
+
Regexp.new(regex.to_s),
|
57
|
+
arguments.map do |arg|
|
58
|
+
arg = arg[:c_arg]
|
59
|
+
CArg.new(arg[:c_type].to_s, arg[:c_identifier].to_s)
|
60
|
+
end
|
61
|
+
)
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
|
3
|
+
module CucumberCsteps
|
4
|
+
|
5
|
+
module StdLib
|
6
|
+
extend FFI::Library
|
7
|
+
ffi_lib 'c'
|
8
|
+
|
9
|
+
callback :signal_handler, [:int], :void
|
10
|
+
attach_function :signal, [ :int, :signal_handler], :void
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.try_and_catch_abort(&block)
|
14
|
+
step_failed = false
|
15
|
+
|
16
|
+
on_sigabrt = Proc.new do |signum|
|
17
|
+
step_failed = true
|
18
|
+
throw :error
|
19
|
+
end
|
20
|
+
|
21
|
+
StdLib.signal(6, on_sigabrt)
|
22
|
+
catch(:error) do
|
23
|
+
yield
|
24
|
+
end
|
25
|
+
|
26
|
+
if step_failed
|
27
|
+
fail()
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'cucumber_csteps'
|
3
|
+
|
4
|
+
include CucumberCsteps
|
5
|
+
|
6
|
+
describe "cucumber csteps parser" do
|
7
|
+
it "should parse simple steps with no arguments" do
|
8
|
+
line = 'GIVEN("the room is warm")()'
|
9
|
+
|
10
|
+
step = CucumberCsteps.parse_cstep(line)
|
11
|
+
step.keyword.should == "Given"
|
12
|
+
step.regex.should == /the room is warm/
|
13
|
+
step.c_args.should == [ ]
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should parse simple steps with no arguments and trailing garbage" do
|
17
|
+
line = 'GIVEN("the room is warm")() {'
|
18
|
+
|
19
|
+
step = CucumberCsteps.parse_cstep(line)
|
20
|
+
step.keyword.should == "Given"
|
21
|
+
step.regex.should == /the room is warm/
|
22
|
+
step.c_args.should == [ ]
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
it "should parse simple steps with one arguments" do
|
27
|
+
line = 'GIVEN("the room is at (\d+) degrees")(int degrees)'
|
28
|
+
|
29
|
+
step = CucumberCsteps.parse_cstep(line)
|
30
|
+
step.keyword.should == "Given"
|
31
|
+
step.regex.should == /the room is at (\d+) degrees/
|
32
|
+
step.c_args.should == [ CArg.new('int', 'degrees') ]
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should parse simple steps with more than one argument" do
|
36
|
+
line = 'GIVEN("the room is at (\d+) degrees and (\d+) persons are in the room")(int degrees, int num_persons)'
|
37
|
+
|
38
|
+
step = CucumberCsteps.parse_cstep(line)
|
39
|
+
step.keyword.should == "Given"
|
40
|
+
step.regex.should == /the room is at (\d+) degrees and (\d+) persons are in the room/
|
41
|
+
step.c_args.should == [ CArg.new('int', 'degrees'), CArg.new('int', 'num_persons') ]
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should work for string arguments" do
|
45
|
+
# Given the room is warm
|
46
|
+
line = 'GIVEN("the (\w+) is (\w+)")(char* room, char* temp)'
|
47
|
+
|
48
|
+
step = CucumberCsteps.parse_cstep(line)
|
49
|
+
step.keyword.should == "Given"
|
50
|
+
step.regex.should == /the (\w+) is (\w+)/
|
51
|
+
step.c_args.should == [ CArg.new('char*', 'room'), CArg.new('char*', 'temp') ]
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should cope with escaped quotes" do
|
55
|
+
# Given the "room" is "warm"
|
56
|
+
line = 'GIVEN("the \"(\w+)\" is \"(\w+)\"")(char* room, char* temp)'
|
57
|
+
|
58
|
+
step = CucumberCsteps.parse_cstep(line)
|
59
|
+
step.keyword.should == "Given"
|
60
|
+
step.regex.should == /the \"(\w+)\" is \"(\w+)\"/
|
61
|
+
step.c_args.should == [ CArg.new('char*', 'room'), CArg.new('char*', 'temp') ]
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should cope with commas" do
|
65
|
+
line = 'GIVEN("a list with 1, 2, 3")()'
|
66
|
+
|
67
|
+
step = CucumberCsteps.parse_cstep(line)
|
68
|
+
step.keyword.should == "Given"
|
69
|
+
step.regex.should == /a list with 1, 2, 3/
|
70
|
+
step.c_args.should == []
|
71
|
+
end
|
72
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cucumber_csteps
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jon-Erling Dahl
|
8
|
+
- Niclas Nilsson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-03-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.7'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.7'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '10.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '10.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: dp
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '1.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: parslet
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.6'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.6'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: activesupport
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '4.2'
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '4.2'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: cucumber
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '1.3'
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '1.3'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: ffi
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '1.9'
|
119
|
+
type: :runtime
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '1.9'
|
126
|
+
description: Write your Cucumber steps in C/C++
|
127
|
+
email:
|
128
|
+
- jon-erling@fooheads.com
|
129
|
+
- niclas@fooheads.com
|
130
|
+
executables:
|
131
|
+
- csteps-include-path
|
132
|
+
extensions: []
|
133
|
+
extra_rdoc_files: []
|
134
|
+
files:
|
135
|
+
- ".gitignore"
|
136
|
+
- ".rspec"
|
137
|
+
- ".ruby-version"
|
138
|
+
- ".travis.yml"
|
139
|
+
- Gemfile
|
140
|
+
- LICENSE.txt
|
141
|
+
- README.md
|
142
|
+
- Rakefile
|
143
|
+
- bin/csteps-include-path
|
144
|
+
- cucumber_csteps.gemspec
|
145
|
+
- include/csteps.h
|
146
|
+
- lib/cucumber_csteps.rb
|
147
|
+
- lib/cucumber_csteps/c_snippets.rb
|
148
|
+
- lib/cucumber_csteps/define_steps.rb
|
149
|
+
- lib/cucumber_csteps/parser.rb
|
150
|
+
- lib/cucumber_csteps/step_wrapper.rb
|
151
|
+
- lib/cucumber_csteps/version.rb
|
152
|
+
- spec/cucumber_csteps_spec.rb
|
153
|
+
- spec/spec_helper.rb
|
154
|
+
homepage: https://github.com/fooheads/cucumber_csteps
|
155
|
+
licenses:
|
156
|
+
- MIT
|
157
|
+
metadata: {}
|
158
|
+
post_install_message:
|
159
|
+
rdoc_options: []
|
160
|
+
require_paths:
|
161
|
+
- lib
|
162
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - ">="
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
requirements: []
|
173
|
+
rubyforge_project:
|
174
|
+
rubygems_version: 2.2.2
|
175
|
+
signing_key:
|
176
|
+
specification_version: 4
|
177
|
+
summary: Cucumber steps in C/C++
|
178
|
+
test_files:
|
179
|
+
- spec/cucumber_csteps_spec.rb
|
180
|
+
- spec/spec_helper.rb
|