simple_bdd 0.0.6 → 0.0.7

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: ddea2617ea76a8759d41af6c9fe3856697e0c87e
4
- data.tar.gz: 93411bfde2e6c997fd3d031c0a40f8ce23d3998f
3
+ metadata.gz: 2563a3bf2a35ea7ac7f31270833b6fe27b7fb33a
4
+ data.tar.gz: e8a8cd3214239544fbac50bbc470b4dfd5225734
5
5
  SHA512:
6
- metadata.gz: 4c359e91b53df2715bbec30916a2cc6c029a07097ffc3203ef35a1d227553fa2a39a0fcdd7f332dc07a5f966ccdd6aa81f4a7f91dcb0056f861e54a0d4e4103f
7
- data.tar.gz: 384e798b2c537ed118e8f14d937a46f21fcea407b1f7bdaa97b586780fdfe78595773ad103ef6fcc807e2697326a7628416593bbe361f28d9d09cb1ddef4f191
6
+ metadata.gz: 8d96c689534b38d9f6ae26b66705478fb68c05fe6a6aec419bff07851f1e4077eadae43fb012bf4e3d2f302c9fbdf10bc4a61f87727566d5180f681992371581
7
+ data.tar.gz: a6d7b3bcbbfea5da2e40738584d336ea9f442e24b1be9c6f5b4b614b91f1fe02b8d14dc78fbbe3541fd6fc70271da46961289a32abf64c5442430d25a6bc409a
data/README.md CHANGED
@@ -64,6 +64,13 @@ You'll need to require SimpleBDD in the spec helper and include it into your tes
64
64
  config.include SimpleBdd
65
65
  end
66
66
 
67
+ By default, SimpleBDD marks specs pending on missing step implementations.
68
+ You can change this behavior to raise an error instead in the spec helper:
69
+
70
+ RSpec.configure do |config|
71
+ config.raise_error_on_missing_step_implementation = true
72
+ end
73
+
67
74
  ## Contributing
68
75
 
69
76
  1. Fork it
@@ -1,3 +1,3 @@
1
1
  module SimpleBdd
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/lib/simple_bdd.rb CHANGED
@@ -1,13 +1,22 @@
1
1
  require "simple_bdd/version"
2
2
 
3
3
  module SimpleBdd
4
+ class StepNotImplemented < StandardError; end
5
+
6
+ RSpec.configuration.add_setting(:raise_error_on_missing_step_implementation,
7
+ default: false) if defined?(::RSpec)
8
+
4
9
  %w[Given When Then And Also But].each do |method|
5
10
  define_method(method) do |message|
6
11
  method_name = methodize(message)
7
12
  if respond_to? method_name || !defined?(::RSpec)
8
13
  send method_name
9
14
  else
10
- pending(method_name)
15
+ if RSpec.configuration.raise_error_on_missing_step_implementation?
16
+ raise StepNotImplemented, method_name
17
+ else
18
+ pending(method_name)
19
+ end
11
20
  end
12
21
  end
13
22
 
@@ -12,9 +12,37 @@ describe "Pending features in rspec" do
12
12
 
13
13
  subject { SimpleBddExample.new }
14
14
 
15
- it "should make the step pending" do
16
- subject.should_receive(:pending).with("i_have_not_defined_a_step")
17
- subject.Given "I have not defined a step"
15
+ context "when raise_error_on_missing_step_implementation is true" do
16
+ before(:each) do
17
+ @raise_error = RSpec.configuration.raise_error_on_missing_step_implementation
18
+ RSpec.configuration.raise_error_on_missing_step_implementation = true
19
+ end
20
+
21
+ it "raises an error on missing step implementations" do
22
+ expect {
23
+ subject.Given "I have not defined a step"
24
+ }.to raise_error SimpleBdd::StepNotImplemented
25
+ end
26
+
27
+ after(:each) do
28
+ RSpec.configuration.raise_error_on_missing_step_implementation = @raise_error
29
+ end
30
+ end
31
+
32
+ context "when raise_error_on_missing_step_implementation is false" do
33
+ before(:each) do
34
+ @raise_error = RSpec.configuration.raise_error_on_missing_step_implementation
35
+ RSpec.configuration.raise_error_on_missing_step_implementation = false
36
+ end
37
+
38
+ it "makes the step pending" do
39
+ subject.should_receive(:pending).with("i_have_not_defined_a_step")
40
+ expect { subject.Given "I have not defined a step" }.to_not raise_error
41
+ end
42
+
43
+ after(:each) do
44
+ RSpec.configuration.raise_error_on_missing_step_implementation = @raise_error
45
+ end
18
46
  end
19
47
 
20
48
  it "should still raise NoMethodError in code under test" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_bdd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robbie Clutton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-02 00:00:00.000000000 Z
11
+ date: 2014-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec