turnip 1.2.2 → 1.2.3
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 +4 -4
- data/.rspec +1 -1
- data/.travis.yml +4 -0
- data/README.md +12 -0
- data/examples/errors.feature +3 -0
- data/gemfiles/Gemfile-rspec-2.14.x +6 -0
- data/gemfiles/Gemfile-rspec-2.99.x +6 -0
- data/gemfiles/Gemfile-rspec-3.0.x +6 -0
- data/lib/turnip.rb +0 -2
- data/lib/turnip/builder.rb +1 -1
- data/lib/turnip/capybara.rb +2 -2
- data/lib/turnip/dsl.rb +4 -2
- data/lib/turnip/execute.rb +8 -3
- data/lib/turnip/rspec.rb +10 -4
- data/lib/turnip/version.rb +1 -1
- data/spec/builder_spec.rb +8 -0
- data/spec/define_and_execute_spec.rb +2 -2
- data/spec/dsl_spec.rb +6 -0
- data/spec/integration_spec.rb +8 -2
- data/spec/spec_helper.rb +8 -0
- data/turnip.gemspec +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55812553e9b4c345d85bd1d9d0561c1480306486
|
4
|
+
data.tar.gz: 3ffd467efff8bdc43ed27623b46370dd53c665e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d28c1998683657ea2c3b110e53edcb75adff78a47fc2210dcfae622c6cb60fcf54292b5d95ae6a5ce8c345cf2f5502d952a5e474a9c4957033f0a3d83ab653c
|
7
|
+
data.tar.gz: 8bed3537732a35c45796fc63f6a6725d397045f23bfb5b6b12af73c9650a4447c55404d5ebce6bb7c6f9a9ceaed716886c60af60988c1044138b20f8bbf4e671
|
data/.rspec
CHANGED
@@ -1 +1 @@
|
|
1
|
-
-r turnip
|
1
|
+
-r turnip/rspec
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -360,6 +360,18 @@ step "there are the following monsters:" do |table|
|
|
360
360
|
end
|
361
361
|
```
|
362
362
|
|
363
|
+
## Unimplemented steps
|
364
|
+
Turnip mark a scenario as pending when steps in the scenario is not implemented.
|
365
|
+
If you sets `raise_error_for_unimplemented_steps` as `true`, turnip will mark a scenario as fail.
|
366
|
+
|
367
|
+
It defaults to `false`, you can change it by following configuration:
|
368
|
+
|
369
|
+
```ruby
|
370
|
+
RSpec.configure do |config|
|
371
|
+
config.raise_error_for_unimplemented_steps = true
|
372
|
+
end
|
373
|
+
```
|
374
|
+
|
363
375
|
## Substitution in Scenario Outlines
|
364
376
|
|
365
377
|
You would be able to use substitution that can be used to DocString and Table arguments in Scenario Outline like [Cucumber](http://cukes.info/step-definitions.html#substitution_in_scenario_outlines):
|
data/examples/errors.feature
CHANGED
data/lib/turnip.rb
CHANGED
data/lib/turnip/builder.rb
CHANGED
data/lib/turnip/capybara.rb
CHANGED
@@ -2,8 +2,8 @@ require 'capybara/rspec'
|
|
2
2
|
|
3
3
|
RSpec.configure do |config|
|
4
4
|
config.before do
|
5
|
-
current_example =
|
6
|
-
current_example ||=
|
5
|
+
current_example = RSpec.current_example if RSpec.respond_to?(:current_example)
|
6
|
+
current_example ||= example
|
7
7
|
|
8
8
|
if self.class.include?(Capybara::DSL) and current_example.metadata[:turnip]
|
9
9
|
Capybara.current_driver = Capybara.javascript_driver if current_example.metadata.has_key?(:javascript)
|
data/lib/turnip/dsl.rb
CHANGED
data/lib/turnip/execute.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
module Turnip
|
2
2
|
module Execute
|
3
|
-
def step(
|
4
|
-
|
3
|
+
def step(step_or_description, *extra_args)
|
4
|
+
if step_or_description.respond_to?(:extra_args)
|
5
|
+
description = step_or_description.description
|
6
|
+
extra_args.concat(step_or_description.extra_args)
|
7
|
+
else
|
8
|
+
description = step_or_description
|
9
|
+
end
|
5
10
|
|
6
11
|
matches = methods.map do |method|
|
7
12
|
next unless method.to_s.start_with?("match: ")
|
8
|
-
send(method.to_s, description
|
13
|
+
send(method.to_s, description)
|
9
14
|
end.compact
|
10
15
|
|
11
16
|
if matches.length == 0
|
data/lib/turnip/rspec.rb
CHANGED
@@ -48,13 +48,18 @@ module Turnip
|
|
48
48
|
example.metadata[:line_number] = step.line
|
49
49
|
example.metadata[:location] = "#{example.metadata[:file_path]}:#{step.line}"
|
50
50
|
|
51
|
+
if ::RSpec.configuration.raise_error_for_unimplemented_steps
|
52
|
+
e.backtrace.unshift "#{feature_file}:#{step.line}:in `#{step.description}'"
|
53
|
+
raise
|
54
|
+
end
|
55
|
+
|
51
56
|
if ::RSpec::Version::STRING >= '2.99.0'
|
52
57
|
skip("No such step: '#{e}'")
|
53
58
|
else
|
54
59
|
pending("No such step: '#{e}'")
|
55
60
|
end
|
56
|
-
rescue StandardError => e
|
57
|
-
e.backtrace.
|
61
|
+
rescue StandardError, ::RSpec::Expectations::ExpectationNotMetError => e
|
62
|
+
e.backtrace.unshift "#{feature_file}:#{step.line}:in `#{step.description}'"
|
58
63
|
raise e
|
59
64
|
end
|
60
65
|
end
|
@@ -75,7 +80,7 @@ module Turnip
|
|
75
80
|
before do
|
76
81
|
example = Turnip::RSpec.fetch_current_example(self)
|
77
82
|
# This is kind of a hack, but it will make RSpec throw way nicer exceptions
|
78
|
-
example.metadata[:file_path]
|
83
|
+
example.metadata[:file_path] ||= feature_file
|
79
84
|
|
80
85
|
feature.backgrounds.map(&:steps).flatten.each do |step|
|
81
86
|
run_step(feature_file, step)
|
@@ -83,7 +88,7 @@ module Turnip
|
|
83
88
|
end
|
84
89
|
feature.scenarios.each do |scenario|
|
85
90
|
instance_eval <<-EOS, feature_file, scenario.line
|
86
|
-
describe scenario.name, scenario.metadata_hash do it(scenario.steps.map(&:
|
91
|
+
describe scenario.name, scenario.metadata_hash do it(scenario.steps.map(&:to_s).join(' -> ')) do
|
87
92
|
scenario.steps.each do |step|
|
88
93
|
run_step(feature_file, step)
|
89
94
|
end
|
@@ -104,4 +109,5 @@ end
|
|
104
109
|
config.include Turnip::RSpec::Execute, turnip: true
|
105
110
|
config.include Turnip::Steps, turnip: true
|
106
111
|
config.pattern << ",**/*.feature"
|
112
|
+
config.add_setting :raise_error_for_unimplemented_steps, :default => false
|
107
113
|
end
|
data/lib/turnip/version.rb
CHANGED
data/spec/builder_spec.rb
CHANGED
@@ -23,6 +23,14 @@ describe Turnip::Builder do
|
|
23
23
|
it 'extracts step keyword' do
|
24
24
|
steps.map(&:keyword).should eq(['Given ', 'When ', 'Then '])
|
25
25
|
end
|
26
|
+
|
27
|
+
it 'extracts full description' do
|
28
|
+
steps.map(&:to_s).should eq([
|
29
|
+
'Given there is a monster',
|
30
|
+
'When I attack it',
|
31
|
+
'Then it should die'
|
32
|
+
])
|
33
|
+
end
|
26
34
|
end
|
27
35
|
|
28
36
|
context "with scenario outlines" do
|
@@ -41,13 +41,13 @@ describe Turnip::Execute do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it "can be executed with a builder step" do
|
44
|
-
builder_step = double(:
|
44
|
+
builder_step = double(:description => "a cool step", :extra_args => [])
|
45
45
|
mod.step("a :test step") { |test| test.upcase }
|
46
46
|
obj.step(builder_step).should == "COOL"
|
47
47
|
end
|
48
48
|
|
49
49
|
it "sends in extra arg from a builder step" do
|
50
|
-
builder_step = double(:
|
50
|
+
builder_step = double(:description => "a cool step", :extra_args => ["foo"])
|
51
51
|
mod.step("a :test step") { |test, foo| test.upcase + foo }
|
52
52
|
obj.step(builder_step).should == "COOLfoo"
|
53
53
|
end
|
data/spec/dsl_spec.rb
CHANGED
@@ -55,5 +55,11 @@ describe Turnip::DSL do
|
|
55
55
|
context.placeholder('example') { true }
|
56
56
|
Turnip::Placeholder.send(:placeholders).should have_key('example')
|
57
57
|
end
|
58
|
+
|
59
|
+
it 'registers the multi placeholder globally' do
|
60
|
+
context.placeholder('example_1', 'example_2') { true }
|
61
|
+
Turnip::Placeholder.send(:placeholders).should have_key('example_1')
|
62
|
+
Turnip::Placeholder.send(:placeholders).should have_key('example_2')
|
63
|
+
end
|
58
64
|
end
|
59
65
|
end
|
data/spec/integration_spec.rb
CHANGED
@@ -7,15 +7,17 @@ describe 'The CLI', :type => :integration do
|
|
7
7
|
|
8
8
|
it "shows the correct description" do
|
9
9
|
@result.should include('A simple feature')
|
10
|
-
@result.should include('is a simple feature')
|
10
|
+
@result.should include('This is a simple feature')
|
11
|
+
@result.should include('Given there is a monster -> When I attack it -> Then it should die')
|
11
12
|
end
|
12
13
|
|
13
14
|
it "prints out failures and successes" do
|
14
|
-
@result.should include('
|
15
|
+
@result.should include('39 examples, 4 failures, 5 pending')
|
15
16
|
end
|
16
17
|
|
17
18
|
it "includes features in backtraces" do
|
18
19
|
@result.should include('examples/errors.feature:5:in `raise error')
|
20
|
+
@result.should include('examples/errors.feature:11:in `a step just does not exist')
|
19
21
|
end
|
20
22
|
|
21
23
|
it "includes the right step name when steps call steps" do
|
@@ -25,13 +27,17 @@ describe 'The CLI', :type => :integration do
|
|
25
27
|
it 'prints line numbers of pending/failure scenario' do
|
26
28
|
@result.should include('./examples/pending.feature:3')
|
27
29
|
@result.should include('./examples/errors.feature:4')
|
30
|
+
@result.should include('./examples/errors.feature:6')
|
31
|
+
@result.should include('./examples/errors.feature:11')
|
28
32
|
end
|
29
33
|
|
30
34
|
it 'conforms to line-number option' do
|
31
35
|
@result.should include('rspec ./examples/errors.feature:4')
|
32
36
|
@result.should include('rspec ./examples/errors.feature:6')
|
37
|
+
@result.should include('rspec ./examples/errors.feature:11')
|
33
38
|
result_with_line_number = %x(rspec -fd ./examples/errors.feature:4)
|
34
39
|
result_with_line_number.should include('rspec ./examples/errors.feature:4')
|
35
40
|
result_with_line_number.should_not include('rspec ./examples/errors.feature:6')
|
41
|
+
result_with_line_number.should_not include('rspec ./examples/errors.feature:11')
|
36
42
|
end
|
37
43
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,6 +4,14 @@ RSpec.configure do |config|
|
|
4
4
|
config.expect_with :rspec do |c|
|
5
5
|
c.syntax = [:should, :expect]
|
6
6
|
end
|
7
|
+
|
8
|
+
config.mock_with :rspec do |c|
|
9
|
+
c.syntax = [:should, :expect]
|
10
|
+
end
|
11
|
+
|
12
|
+
config.before(raise_error_for_unimplemented_steps: true) do
|
13
|
+
config.stub(:raise_error_for_unimplemented_steps) { true }
|
14
|
+
end
|
7
15
|
end
|
8
16
|
|
9
17
|
Dir.glob(File.expand_path("../examples/**/*steps.rb", File.dirname(__FILE__))) { |f| require f }
|
data/turnip.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_runtime_dependency "rspec", [">=2.0", "<4.0"]
|
21
|
+
s.add_runtime_dependency "rspec", [">=2.14.0", "<4.0"]
|
22
22
|
s.add_runtime_dependency "gherkin", ">= 2.5"
|
23
23
|
s.add_development_dependency "rake"
|
24
24
|
s.add_development_dependency "pry"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turnip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Nicklas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.14.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '4.0'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 2.14.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '4.0'
|
@@ -113,6 +113,9 @@ files:
|
|
113
113
|
- examples/tags.feature
|
114
114
|
- examples/with_backticks.feature
|
115
115
|
- examples/with_comments.feature
|
116
|
+
- gemfiles/Gemfile-rspec-2.14.x
|
117
|
+
- gemfiles/Gemfile-rspec-2.99.x
|
118
|
+
- gemfiles/Gemfile-rspec-3.0.x
|
116
119
|
- lib/turnip.rb
|
117
120
|
- lib/turnip/builder.rb
|
118
121
|
- lib/turnip/capybara.rb
|