Permalink
Browse files

Missing steps should be marked as pending in Rspec.

  • Loading branch information...
berlin-ab authored and robb1e committed Apr 6, 2013
1 parent d1a61a4 commit fc615e8635ac6262d6d57302028333c3a9686427
Showing with 34 additions and 2 deletions.
  1. +21 −1 lib/simple_bdd.rb
  2. +8 −0 spec/pending_feature_spec.rb
  3. +5 −1 spec/spec_helper.rb
View
@@ -3,9 +3,29 @@
module SimpleBdd
%w[Given When Then And Also].each do |method|
define_method(method) do |message|
- send message.downcase.gsub(" ", "_").gsub(/\W/, "")
+ begin
+ send translate(message)
+ rescue NoMethodError => error
+ message_does_not_exist(
+ translate(message), error
+ )
+ end
end
alias_method method.downcase, method
end
+
+ def translate(message)
+ message.downcase.gsub(" ", "_").gsub(/\W/, "")
+ end
+
+ if defined?(::RSpec)
+ def message_does_not_exist(message, error)
+ pending(message)
+ end
+ else
+ def message_does_not_exist(message, error)
+ raise error
+ end
+ end
end
@@ -0,0 +1,8 @@
+require 'spec_helper'
+
+describe "Pending features in rspec" do
+ it "should make the step pending" do
+ self.should_receive(:pending).with("i_have_not_defined_a_step")
+ Given "I have not defined a step"
+ end
+end
View
@@ -3,6 +3,10 @@
config.run_all_when_everything_filtered = true
config.filter_run :focus
config.order = 'random'
-
+
require File.dirname(__FILE__) + '/../lib/simple_bdd'
+
+ RSpec.configure do |config|
+ config.include SimpleBdd
+ end
end

0 comments on commit fc615e8

Please sign in to comment.