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.
- data/lib/simple_bdd/version.rb +1 -1
- data/lib/simple_bdd.rb +5 -16
- data/spec/pending_feature_spec.rb +19 -2
- data/spec/simple_bdd_spec.rb +5 -5
- data/spec/spec_helper.rb +0 -4
- metadata +2 -2
data/lib/simple_bdd/version.rb
CHANGED
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
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
|
data/spec/simple_bdd_spec.rb
CHANGED
@@ -18,20 +18,20 @@ describe SimpleBddExample do
|
|
18
18
|
|
19
19
|
describe "#methodize" do
|
20
20
|
it "removes special chars" do
|
21
|
-
|
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
|
-
|
25
|
+
subject.send(:methodize, "HELLO WORLD").should == "hello_world"
|
26
26
|
end
|
27
27
|
|
28
28
|
it "compacts adjacent separators" do
|
29
|
-
|
30
|
-
|
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
|
-
|
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
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.
|
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-
|
12
|
+
date: 2013-05-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|