simple_bdd 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module SimpleBdd
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/simple_bdd.rb CHANGED
@@ -3,12 +3,11 @@ require "simple_bdd/version"
3
3
  module SimpleBdd
4
4
  %w[Given When Then And Also].each do |method|
5
5
  define_method(method) do |message|
6
- begin
7
- send methodize(message)
8
- rescue NoMethodError => error
9
- message_does_not_exist(
10
- methodize(message), error
11
- )
6
+ method_name = methodize(message)
7
+ if respond_to? method_name || !defined?(::RSpec)
8
+ send method_name
9
+ else
10
+ pending(method_name)
12
11
  end
13
12
  end
14
13
 
@@ -24,14 +23,4 @@ module SimpleBdd
24
23
  .gsub(/[^#{PRESERVED_CHARS}#{CONVERTED_CHARS}]/, "")
25
24
  .gsub(/[#{CONVERTED_CHARS}]+/, "_")
26
25
  end
27
-
28
- if defined?(::RSpec)
29
- def message_does_not_exist(message, error)
30
- pending(message)
31
- end
32
- else
33
- def message_does_not_exist(message, error)
34
- raise error
35
- end
36
- end
37
26
  end
@@ -1,8 +1,25 @@
1
1
  require 'spec_helper'
2
2
 
3
+ class SimpleBddExample
4
+ include SimpleBdd
5
+
6
+ def i_call_an_undefined_method
7
+ undefined_method_raises_error()
8
+ end
9
+ end
10
+
3
11
  describe "Pending features in rspec" do
12
+
13
+ subject { SimpleBddExample.new }
14
+
4
15
  it "should make the step pending" do
5
- self.should_receive(:pending).with("i_have_not_defined_a_step")
6
- Given "I have not defined a step"
16
+ subject.should_receive(:pending).with("i_have_not_defined_a_step")
17
+ subject.Given "I have not defined a step"
18
+ end
19
+
20
+ it "should still raise NoMethodError in code under test" do
21
+ expect {
22
+ subject.Then "I call an undefined method"
23
+ }.to raise_error(NoMethodError, /raises_error/)
7
24
  end
8
25
  end
@@ -18,20 +18,20 @@ describe SimpleBddExample do
18
18
 
19
19
  describe "#methodize" do
20
20
  it "removes special chars" do
21
- subject.send(:methodize, "bond, james bond").should == "bond_james_bond"
21
+ subject.send(:methodize, "bond, james bond").should == "bond_james_bond"
22
22
  end
23
23
 
24
24
  it "converts to lower case" do
25
- subject.send(:methodize, "HELLO WORLD").should == "hello_world"
25
+ subject.send(:methodize, "HELLO WORLD").should == "hello_world"
26
26
  end
27
27
 
28
28
  it "compacts adjacent separators" do
29
- subject.send(:methodize, "Bates & Lolcat Realty").should == "bates_lolcat_realty"
30
- subject.send(:methodize, "Ruby / Python / Scala, same deal").should == "ruby_python_scala_same_deal"
29
+ subject.send(:methodize, "Bates & Lolcat Realty").should == "bates_lolcat_realty"
30
+ subject.send(:methodize, "Ruby / Python / Scala, same deal").should == "ruby_python_scala_same_deal"
31
31
  end
32
32
 
33
33
  it "underscores slashes" do
34
- subject.send(:methodize, "Chocolate/Vanilla Cake").should == "chocolate_vanilla_cake"
34
+ subject.send(:methodize, "Chocolate/Vanilla Cake").should == "chocolate_vanilla_cake"
35
35
  end
36
36
  end
37
37
  end
data/spec/spec_helper.rb CHANGED
@@ -5,8 +5,4 @@ RSpec.configure do |config|
5
5
  config.order = 'random'
6
6
 
7
7
  require File.dirname(__FILE__) + '/../lib/simple_bdd'
8
-
9
- RSpec.configure do |config|
10
- config.include SimpleBdd
11
- end
12
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_bdd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-14 00:00:00.000000000 Z
12
+ date: 2013-05-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec