cucumber-en_snippet 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6b5d7c5650abf5b320c37a78c8ad459f1741cd7
4
- data.tar.gz: 9db778babaf1541e1a4a2bd7016a1db7e73bdffa
3
+ metadata.gz: 895b0fcde0489036137e07ab852cb0e2a1ae18c1
4
+ data.tar.gz: acfa75b58269eb64686fb7c04cc99b63357ebc3e
5
5
  SHA512:
6
- metadata.gz: 6ec4318d89f24b3d8ac824dfcf181a87c79fe955ca3d8428b18d5dc860b3af9401cc6f1fd617b14e9dad8edc986e0378cb474d0092527749ef0967c5d62b7eae
7
- data.tar.gz: 61de5846c4fa0e44ce066422f82e6918d1273a92b68a01c307fa529566ac46f6c870b1cc46797cf7e9f70dee2b38474efe64fa999ed15109c277842b199a5f9f
6
+ metadata.gz: 15f70247cbc350a06c96e124d26394264c3694b07769e9f93fa3c503ef9b52905add88ff216304ffc47b91b17ef7924edb3be1c290332f1c1ebf614f55283e8e
7
+ data.tar.gz: 83348c2f207ef5f21de155d4bb41d910709af28a87e923b0aae2d086ea7bd1a6f3132251d17b6f4921ebeb989e607db681e42ffac1f841184fb99645b8fb9996
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ script:
3
+ - bundle exec cucumber
4
+ rvm:
5
+ - 2.1.0-rc1
6
+ - 2.0.0
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Cucumber::EnSnippet
2
2
 
3
+ [![Build Status](https://travis-ci.org/mtsmfm/cucumber-en_snippet.png?branch=master)](https://travis-ci.org/mtsmfm/cucumber-en_snippet)
4
+
3
5
  Output cucumber step definition snippets in English regardless of a language header.
4
6
 
5
7
  ## Installation
@@ -24,6 +26,12 @@ Require this library in your ruby files under `features/support`.
24
26
  require 'cucumber/en_snippet'
25
27
  ```
26
28
 
29
+ Then, run cucumber with snippet type option `-I`.
30
+
31
+ ```
32
+ bundle exec cucumber -I en_regexp
33
+ ```
34
+
27
35
  ## Contributing
28
36
 
29
37
  1. Fork it
@@ -21,7 +21,7 @@ Feature: Snippets
21
21
  example with <html> entities
22
22
  \"\"\"
23
23
  """
24
- When I run `cucumber features/undefined_steps.feature -s`
24
+ When I run `cucumber features/undefined_steps.feature -s -I en_regexp`
25
25
  Then the output should contain:
26
26
  """
27
27
  Given(/^a pystring$/) do |string|
@@ -39,7 +39,7 @@ Feature: Snippets
39
39
  | table |
40
40
  |example|
41
41
  """
42
- When I run `cucumber features/undefined_steps.feature -s`
42
+ When I run `cucumber features/undefined_steps.feature -s -I en_regexp`
43
43
  Then the output should contain:
44
44
  """
45
45
  Given(/^a table$/) do |table|
@@ -12,9 +12,9 @@ RSpec::Matchers.define :include do |expected|
12
12
  failure_message_for_should do |actual|
13
13
  <<-EOM.gsub(/^ *\|/, '')
14
14
  |expected:
15
- |#{expected.gsub(/^/,' ')}
15
+ #{expected.gsub(/^/,'| ')}
16
16
  |got:
17
- |#{actual.gsub(/^/,' ')}
17
+ #{actual.gsub(/^/,'| ')}
18
18
  EOM
19
19
  end
20
20
  end
@@ -1,35 +1,34 @@
1
1
  require "cucumber/en_snippet/version"
2
2
 
3
- require "cucumber/rb_support/snippet"
4
-
5
3
  module Cucumber
6
- module EnSnippet
7
- # Your code goes here...
8
- end
9
- end
4
+ class EnBaseSnippet < RbSupport::Snippet::BaseSnippet
5
+ def initialize(code_keyword, pattern, multiline_argument_class)
6
+ keyword = en_keyword(code_keyword)
7
+ keyword = code_keyword if keyword.empty?
10
8
 
11
- module Cucumber
12
- module RbSupport
13
- module Snippet
14
- class BaseSnippet
15
- def initialize_with_en_keyword(code_keyword, pattern, multiline_argument_class)
16
- case
17
- when ::Regexp.new(Gherkin::I18n.keyword_regexp(:given)) =~ code_keyword
18
- en_keyword = 'Given'
19
- when ::Regexp.new(Gherkin::I18n.keyword_regexp(:when)) =~ code_keyword
20
- en_keyword = 'When'
21
- when ::Regexp.new(Gherkin::I18n.keyword_regexp(:then)) =~ code_keyword
22
- en_keyword = 'Then'
23
- else
24
- en_keyword = code_keyword
25
- end
9
+ super(keyword, pattern, multiline_argument_class)
10
+ end
26
11
 
27
- initialize_without_en_keyword(en_keyword, pattern, multiline_argument_class)
28
- end
12
+ private
29
13
 
30
- alias_method :initialize_without_en_keyword, :initialize
31
- alias_method :initialize, :initialize_with_en_keyword
32
- end
14
+ def en_keyword(code_keyword)
15
+ %i(given when then).find {|k|
16
+ ::Regexp.new(::Gherkin::I18n.keyword_regexp(k)) =~ code_keyword
17
+ }.to_s.capitalize
18
+ end
19
+ end
20
+
21
+ class EnRegexp < EnBaseSnippet
22
+ def typed_pattern
23
+ "(/^#{pattern}$/)"
24
+ end
25
+
26
+ def self.description
27
+ 'Snippets with parentheses (English keywords)'
33
28
  end
34
29
  end
35
30
  end
31
+
32
+ Cucumber::RbSupport::RbLanguage::SNIPPET_TYPES.merge!(
33
+ en_regexp: Cucumber::EnRegexp
34
+ )
@@ -1,5 +1,5 @@
1
1
  module Cucumber
2
2
  module EnSnippet
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-en_snippet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fumiaki MATSUSHIMA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-22 00:00:00.000000000 Z
11
+ date: 2013-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -89,6 +89,7 @@ extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
91
  - ".gitignore"
92
+ - ".travis.yml"
92
93
  - Gemfile
93
94
  - LICENSE.txt
94
95
  - README.md