gurke 1.0.1 → 2.0.0.dev.1.b17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ba96b511b63ade3b7846428a3af7a09c643b3551
4
- data.tar.gz: 21cf019e6773067c52d53327865ecbb135a60e36
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NDc3MWMyNWIzYzQ0MGRmMWFkMmIyMmFmMjYwMTgzN2I3NmQ0YTdmYQ==
5
+ data.tar.gz: !binary |-
6
+ ODQ4YWI3ZTUyZDhmYjk2YzQ2NWQwOWY1ZmM1YzFkNDQ5YWRhZTJjYQ==
5
7
  SHA512:
6
- metadata.gz: 9d798023595db4dcf3b64bd1d6b93ff1644acea4b87493304100abf3c81ae0ab148648a157ef44923f4b968976421b8be3d8f19f9d8851b39687d1fcd1ba2463
7
- data.tar.gz: 3d438d0bd1bcf5a065f7afb3c2755350038a64eb9417204c2b00bd25e38221ff615038846857a14f41f04e47d5ef92d94052c4564ae76b4ca97cc1791ef0f2e8
8
+ metadata.gz: !binary |-
9
+ OTcwMGYwOTM2NTEzNGQ0MWU0YmFiN2I3OWMxNjAxZTc4N2Q0OGEwYTdkOGY4
10
+ NDJkNmI0MjY0ZTYzYzcyMTVhNDZkYWY0MWE2MzVmYTc1ZjE1ZTMxYzZkMjQ2
11
+ OGU4ZTRmODkyZTQ2MWMzY2VjOTM0MWE5MTdhNWQwODdiYjEwZmQ=
12
+ data.tar.gz: !binary |-
13
+ MmUyOWRiZDQ3ZWYyMDU5ZGY0M2Y3ODk2MmIyYThjNGI2MGYzNTEyMTJiNzJl
14
+ ZTAzOGZlNzIwMGJmNGQzZDBlY2E5ZDBlZDk1ZDlhOWVlZDFhMzJiYjJjODJh
15
+ ZGNjMmU1OWFjOTdjMTkwNmFjNTE5ZDQ4NDI1MGViZTliNTA4ZjA=
data/README.md CHANGED
@@ -1,74 +1,121 @@
1
1
  # Gurke
2
2
 
3
- **Gurke** is a highly opinionated cucumber toolkit overtaking cucumbers formatter to add webm flv video recording with headless (xvfb), multiple output formatters, global available current step and scenario and additional hooks.
3
+ **Gurke** is an experimental, alternative cucumber runner. It ~~steals~~ borrows ideas and concepts from [turnip](https://github.com/jnicklas/turnip), [rspec](http://rspec.info) and tries to avoid [cucumber](https://github.com/cucumber/cucumber/).
4
4
 
5
- Unfinished, not recommended, highly dangerous!
5
+ That includes * Step definitions in modules * Before, After and Around hooks * Formatters * Partial step inclusion (via modules) * etc. Also new ideas like keyword depended step definitions are planned.
6
+
7
+ But still **Gurke** is unfinished, not recommended and highly dangerous!
6
8
 
7
9
  ## Installation
8
10
 
9
- Add this line to your application's Gemfile:
11
+ Or install it yourself as:
12
+
13
+ $ gem install gurke
10
14
 
11
- gem 'gurke'
15
+ Or add it to your `Gemfile` and install it using bundler.
12
16
 
13
- And then execute:
17
+ ## Usage
14
18
 
15
- $ bundle
19
+ 1. Put features in `features/`.
16
20
 
17
- Or install it yourself as:
21
+ 2. Put support and configuration files as ruby into `features/support/**`.
18
22
 
19
- $ gem install gurke
23
+ e.g.
20
24
 
21
- ## Usage
25
+ ```ruby
26
+ # features/support/gurke.rb
27
+ require 'gurke/rspec'
28
+ require 'tmpdir'
22
29
 
30
+ Gurke.configure do |c|
31
+ c.around(:scenario) do |scenario|
32
+ Dir.mktmpdir('gurke') do |dir|
33
+ @__root = Pathname.new(dir)
34
+ scenario.call
35
+ end
36
+ end
37
+ end
23
38
  ```
24
- require 'gurke'
25
39
 
26
- require 'cucumber/formatter/pretty'
27
- require 'cucumber/formatter/junit'
28
- require 'gurke/formatters/headless'
40
+ 3. Put your step definitions into `features/support/**`.
29
41
 
30
- class MyExternalTool < ::Gurke::Formatters::Base
31
- def quiet?
32
- options[:quiet]
33
- end
42
+ ```ruby
43
+ # features/support/steps/file_steps.rb
44
+ module FileSteps
45
+ step(/a file "(.*?)" with the following content exists/) do |path, step|
46
+ file = @__root.join(path)
34
47
 
35
- def before_features(features)
36
- puts 'BUUUH!' unless quiet?
48
+ FileUtils.mkdir_p(File.dirname(file))
49
+ File.write(file, step.doc_string)
37
50
  end
38
51
  end
39
52
 
40
- Gurke::Formatter.config do
41
- use Cucumber::Formatter::Pretty
42
- use Cucumber::Formatter::JUnit
43
- use MyExternalTool, quiet: true
44
- use Gurke::Formatters::Headless, dir: 'report/html', recording: true, record_all: true
45
- end
53
+ Gurke.configure{|c| c.include FileSteps }
46
54
  ```
47
55
 
48
- ```
49
- Gurke.current.step
50
- Gurke.current.scenario
56
+ You can also use an existing method as a step:
51
57
 
52
- Gurke.before :features do |*args|
53
- # ...
54
- end
58
+ ```ruby
59
+ module MySteps
60
+ def do_something(arg)
61
+ # ...
62
+ end
55
63
 
56
- Gurke.before :feature_element do |*args|
57
- # ...
64
+ step(/I do something: "(.*?)"/, :do_something)
65
+
66
+ # Easy call it from another step
67
+ step(/I do something else/) { do_something('abc') }
58
68
  end
69
+ ```
70
+
71
+ ### Keyword specific step definitions
72
+
73
+ You can also define steps for only a specific keyword. This also allows you to use the same step pattern for different keywords, e.g.
59
74
 
60
- Gurke.after :step_result do |*args|
61
- # ...
75
+ ```ruby
76
+ module PathSteps
77
+ Given(/^I am on the start page$/) { visit '/' }
78
+ Then(/^I am on the start page$/) { assert current_path == '/' }
62
79
  end
80
+ ```
63
81
 
64
- #...
82
+ Therefore you can write your scenarios in a documentary style of facts:
65
83
 
66
84
  ```
85
+ Scenario: Use the back button
86
+ Given I am on the start page
87
+ When I click on "Go to another page"
88
+ And I click the back button
89
+ Then I am on the start page
90
+ ```
91
+
92
+ `And` and `But` steps will inherit the keyword type from the step before, e.g. the `And` step above will be of the `when` type.
93
+
94
+ ### Use the command line runner
95
+
96
+ Run all scenarios by just calling `bundle exec gurke`. By default scenarios and features tagged with `@wip` will be ignored.
97
+
98
+ Specify one or more `--tags` or `-t` arguments to filter for specific tags, negate tag filters with `~`.
99
+
100
+ Examples:
101
+
102
+ * `--tags a,b` - only run scenarios with tags `@a` AND `@b`
103
+ * `-t a -t b` - only run scenarios with tags `@a` OR `@b`
104
+ * `-t a,~b` - only run scenarios with `@a` but not `@b`
67
105
 
68
106
  ## TODO
69
107
 
70
- * Headless Dir & HTML Template
108
+ * Random run order (rspec)
109
+ * Using strings with placeholders as step pattern (turnip)
110
+ * Custom placeholders (turnip)
111
+ * Define scenario specific after hook in a step (e.g. to close opened resource)
112
+ * More reporters (NyanCat / JUnit / TeamCity / Adapter to run multiple reporters)
113
+ * SimpleCov support (and use it in own tests)
114
+
115
+ ## History
116
+
117
+ Now: * Can finally (start to) test itself.
71
118
 
72
119
  ## Contributing
73
120
 
74
- Don't even think about it.
121
+ Send me code.
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gurke'
3
+ require 'gurke/cli'
4
+
5
+ Gurke::CLI.new.run(ARGV)
@@ -0,0 +1,47 @@
1
+ Feature: Use gurke
2
+ As a developer
3
+ In order to run my feature definitions
4
+ I want to use the gurke command line program
5
+
6
+ Background:
7
+ Given I am in a project using gurke
8
+
9
+ Scenario: Run a passing feature file
10
+ Given a file "features/test.feature" with the following content exists
11
+ """
12
+ Feature: F
13
+ Scenario: Scenario A
14
+ Given everything is ok
15
+ """
16
+ And a file "features/support/steps/test_steps.rb" with the following content exists
17
+ """
18
+ module TestSteps
19
+ step("everything is ok") { }
20
+ end
21
+ Gurke.configure{|c| c.include TestSteps }
22
+ """
23
+ When I execute "bundle exec gurke"
24
+ Then the program exit code should be null
25
+ And the program output should include "Feature: F"
26
+ And the program output should include "Scenario: Scenario A"
27
+ And the program output should include "Given everything is ok"
28
+ And the program output should include "1 scenarios: 0 failing, 0 pending"
29
+
30
+ Scenario: Run a failing feature file
31
+ Given a file "features/test.feature" with the following content exists
32
+ """
33
+ Feature: F
34
+ Scenario: Scenario A
35
+ Given nothing is ok
36
+
37
+ """
38
+ And a file "features/support/steps/test_steps.rb" with the following content exists
39
+ """
40
+ module TestSteps
41
+ step("nothing is ok") { raise RuntimeError }
42
+ end
43
+ Gurke.configure{|c| c.include TestSteps }
44
+ """
45
+ When I execute "bundle exec gurke"
46
+ And the program output should include "1 scenarios: 1 failing, 0 pending"
47
+ Then the program exit code should be non-null
@@ -0,0 +1,12 @@
1
+ require 'gurke/rspec'
2
+ require 'tmpdir'
3
+
4
+ Gurke.configure do |c|
5
+ c.around(:scenario) do |scenario|
6
+
7
+ Dir.mktmpdir('gurke') do |dir|
8
+ @__root = Pathname.new(dir)
9
+ scenario.call
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,36 @@
1
+ Feature: Backtrace filtering
2
+ As a developer
3
+ In order to faster find the backtrace lines
4
+ I want to see modified backtraces with only non-library calls
5
+
6
+ Background:
7
+ Given I am in a project using gurke
8
+ And a file "features/test.feature" with the following content exists
9
+ """
10
+ Feature: F
11
+ Scenario: Scenario A
12
+ Given there is an error
13
+
14
+ """
15
+ And a file "features/support/steps/test_steps.rb" with the following content exists
16
+ """
17
+ module TestSteps
18
+ step("there is an error") { raise RuntimeError }
19
+ end
20
+ Gurke.configure{|c| c.include TestSteps }
21
+ """
22
+
23
+ Scenario: See backtrace without line from libraries
24
+ When I execute "bundle exec gurke"
25
+ Then the program output should include "features/support/steps/test_steps.rb:2"
26
+ Then the program output should not include "gurke/lib/gurke/runner.rb"
27
+
28
+ Scenario: See backtrace when run with --backtrace
29
+ When I execute "bundle exec gurke --backtrace"
30
+ Then the program output should include "features/support/steps/test_steps.rb:2"
31
+ Then the program output should include "gurke/lib/gurke/runner.rb"
32
+
33
+ Scenario: See backtrace when run with -b
34
+ When I execute "bundle exec gurke -b"
35
+ Then the program output should include "features/support/steps/test_steps.rb:2"
36
+ Then the program output should include "gurke/lib/gurke/runner.rb"
@@ -0,0 +1,70 @@
1
+ Feature: Backtrace filtering
2
+ In order to not always run every fukcin long scenario
3
+ As a tester
4
+ I want to filter features and scenarios by tags to only run a subset
5
+
6
+ Background:
7
+ Given I am in a project using gurke
8
+ And a file "features/support/steps/test_steps.rb" with the following content exists
9
+ """
10
+ module TestSteps
11
+ step("everything's ok") { true && true }
12
+ end
13
+ Gurke.configure{|c| c.include TestSteps }
14
+ """
15
+ And a file "features/feature_flag_a.feature" with the following content exists
16
+ """
17
+ @a @c @d
18
+ Feature: Feature Flagged little-A
19
+ Scenario: Best Scenario evvvarrr
20
+ Then everything's ok
21
+ """
22
+ And a file "features/feature_flag_b.feature" with the following content exists
23
+ """
24
+ @b @c @d
25
+ Feature: Feature Flagged little-B
26
+ Scenario: Best Scenario evvvarr, the second
27
+ Then everything's ok
28
+ """
29
+ And a file "features/feature_flag_wip.feature" with the following content exists
30
+ """
31
+ @wip
32
+ Feature: Feature Flagged little-WIP
33
+ Scenario: Best Scenario evvarr, the second
34
+ Then everything's ok
35
+ """
36
+
37
+ Scenario: Do not run @wip by default
38
+ When I execute "bundle exec gurke"
39
+ Then the program output should include "Feature Flagged little-A"
40
+ And the program output should include "Feature Flagged little-B"
41
+ And the program output should not include "Feature Flagged little-WIP"
42
+ And the program output should include "2 scenarios"
43
+
44
+ Scenario: Filter with positive tag match
45
+ When I execute "bundle exec gurke --tags a"
46
+ Then the program output should include "Feature Flagged little-A"
47
+ And the program output should not include "Feature Flagged little-B"
48
+ And the program output should not include "Feature Flagged little-WIP"
49
+ And the program output should include "1 scenarios"
50
+
51
+ Scenario: Filter with negative tag match
52
+ When I execute "bundle exec gurke -t ~b"
53
+ Then the program output should include "Feature Flagged little-A"
54
+ And the program output should not include "Feature Flagged little-B"
55
+ And the program output should include "Feature Flagged little-WIP"
56
+ And the program output should include "2 scenarios"
57
+
58
+ Scenario: Filter with multiple tag match and'ed
59
+ When I execute "bundle exec gurke --tags c,d"
60
+ Then the program output should include "Feature Flagged little-A"
61
+ And the program output should include "Feature Flagged little-B"
62
+ And the program output should not include "Feature Flagged little-WIP"
63
+ And the program output should include "2 scenarios"
64
+
65
+ Scenario: Filter with multiple tag match or'ed
66
+ When I execute "bundle exec gurke --tags b --tags wip"
67
+ Then the program output should not include "Feature Flagged little-A"
68
+ And the program output should include "Feature Flagged little-B"
69
+ And the program output should include "Feature Flagged little-WIP"
70
+ And the program output should include "2 scenarios"
@@ -0,0 +1,41 @@
1
+ Feature: Step keyword specific definitions
2
+ In order to allow documentary style scenarios
3
+ As a user
4
+ I want to define same steps with different step keywords
5
+
6
+ Background:
7
+ Given I am in a project using gurke
8
+
9
+ Scenario: Use same step definition with different keyword
10
+ Given a file "features/test.feature" with the following content exists
11
+ """
12
+ Feature: F
13
+ Scenario: Scenario A
14
+ Given I am "John"
15
+ When I am "John"
16
+ Then I am "John"
17
+
18
+ """
19
+ And a file "features/support/steps/test_steps.rb" with the following content exists
20
+ """
21
+ require 'test/unit/assertions'
22
+
23
+ module Steps
24
+ include MiniTest::Assertions
25
+
26
+ Given(/^I am "(.+)"$/) do |name|
27
+ @me = name
28
+ end
29
+
30
+ When(/^I am "(.+)"$/) do |name|
31
+ @copy = @me
32
+ end
33
+
34
+ Then(/^I am "(.+)"$/) do |name|
35
+ assert name == @copy, "Expected #{name.inspect} but #{@me.inspect} given."
36
+ end
37
+ end
38
+ Gurke.world.send :include, Steps
39
+ """
40
+ When I execute all scenarios
41
+ Then all scenarios have passed
@@ -0,0 +1,50 @@
1
+ require 'open3'
2
+
3
+ #
4
+ module CLISteps
5
+ def _execute(exec)
6
+ Dir.chdir(@__root) do
7
+ Bundler.with_clean_env do
8
+ Open3.popen2e(exec) do |_, stdout_err, wait_thr|
9
+ exit_status = wait_thr.value
10
+ stdout_err = stdout_err.read
11
+
12
+ @last_process = [exit_status.to_i, stdout_err]
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ step(/I execute "(.*?)"/, :_execute)
19
+
20
+ step('I execute all scenarios') do
21
+ _execute 'bundle exec gurke'
22
+ end
23
+
24
+ step(/the program exit code should be null/) do
25
+ expect(@last_process[0]).to eq 0
26
+ end
27
+
28
+ step(/the program exit code should be non-null/) do
29
+ expect(@last_process[0]).to_not eq 0
30
+ end
31
+
32
+ def _cli_include_content(content)
33
+ expect(@last_process[1]).to include content
34
+ end
35
+
36
+ step(/the program output should include "(.*?)"/, :_cli_include_content)
37
+
38
+ def _cli_not_include_content(content)
39
+ expect(@last_process[1]).to_not include content
40
+ end
41
+
42
+ step(/the program output should not include "(.*?)"/,
43
+ :_cli_not_include_content)
44
+
45
+ step(/all scenarios have passed/) do
46
+ _cli_include_content 'scenarios: 0 failing, 0 pending'
47
+ end
48
+ end
49
+
50
+ Gurke.configure{|c| c.include CLISteps }