turnip 1.2.2 → 1.2.3

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: bdb367c9acc76b2fb0f4abbbedf8730ce97f3d33
4
- data.tar.gz: 69314b7771dfcd5a645b4a41b01d1c99c84ae5e6
3
+ metadata.gz: 55812553e9b4c345d85bd1d9d0561c1480306486
4
+ data.tar.gz: 3ffd467efff8bdc43ed27623b46370dd53c665e6
5
5
  SHA512:
6
- metadata.gz: 0ba3f6f9153835411c293efb95224f4e3a0a22e6f896a2df4ab52739c9ae66a661658c10e214a7a06bb6bb625c16c8bb4105739c93d0abcf8b2d3b63ea190e8b
7
- data.tar.gz: 2305ebaeee98b1da8a8f599fc3a94c51c27487732e9af2d5762f56260cebf186665a38e1123249860f6330f8ca7865276d974d00c116bf33455c6be2ac20ce8b
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
@@ -3,3 +3,7 @@ rvm:
3
3
  - 2.0.0
4
4
  - 2.1.0
5
5
  - jruby-19mode
6
+ gemfile:
7
+ - gemfiles/Gemfile-rspec-2.14.x
8
+ - gemfiles/Gemfile-rspec-2.99.x
9
+ - gemfiles/Gemfile-rspec-3.0.x
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):
@@ -6,3 +6,6 @@ Feature: raises errors
6
6
  Scenario: Incorrect expectation
7
7
  Given there is a monster
8
8
  Then it should die
9
+ @raise_error_for_unimplemented_steps
10
+ Scenario: Step missing and raise_error_for_unimplemented_steps is set
11
+ When a step just does not exist
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in turnip.gemspec
4
+ gemspec :path => '..'
5
+
6
+ gem 'rspec', '~> 2.14.0'
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in turnip.gemspec
4
+ gemspec :path => '..'
5
+
6
+ gem 'rspec', '~> 2.99.0'
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in turnip.gemspec
4
+ gemspec :path => '..'
5
+
6
+ gem 'rspec', '~> 3.0.0'
data/lib/turnip.rb CHANGED
@@ -29,5 +29,3 @@ Turnip.type = :feature
29
29
  Module.send(:include, Turnip::Define)
30
30
 
31
31
  self.extend Turnip::DSL
32
-
33
- require "turnip/rspec"
@@ -116,7 +116,7 @@ module Turnip
116
116
  end
117
117
 
118
118
  def to_s
119
- description
119
+ "#{keyword}#{description}"
120
120
  end
121
121
  end
122
122
 
@@ -2,8 +2,8 @@ require 'capybara/rspec'
2
2
 
3
3
  RSpec.configure do |config|
4
4
  config.before do
5
- current_example = example if respond_to?(:example)
6
- current_example ||= RSpec.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
@@ -1,7 +1,9 @@
1
1
  module Turnip
2
2
  module DSL
3
- def placeholder(name, &block)
4
- Turnip::Placeholder.add(name, &block)
3
+ def placeholder(*name, &block)
4
+ name.each do |n|
5
+ Turnip::Placeholder.add(n, &block)
6
+ end
5
7
  end
6
8
 
7
9
  def step(description, &block)
@@ -1,11 +1,16 @@
1
1
  module Turnip
2
2
  module Execute
3
- def step(description, *extra_args)
4
- extra_args.concat(description.extra_args) if description.respond_to?(:extra_args)
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.to_s)
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.push "#{feature_file}:#{step.line}:in `#{step.description}'"
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] = feature_file
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(&:description).join(' -> ')) do
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
@@ -1,3 +1,3 @@
1
1
  module Turnip
2
- VERSION = "1.2.2"
2
+ VERSION = '1.2.3'
3
3
  end
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(:to_s => "a cool step", :extra_args => [])
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(:to_s => "a cool step", :extra_args => ["foo"])
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
@@ -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('38 examples, 3 failures, 5 pending')
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.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-07-12 00:00:00.000000000 Z
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: '2.0'
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: '2.0'
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