simple_bdd 0.0.9 → 0.1.0

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: 852885477abe136c0b58509e089f22aab842661e
4
- data.tar.gz: 7feaa604ec7b4841ffb5f918ac977a71bca73e9d
3
+ metadata.gz: 388c44d69b8bf6e79d99d88929bfe79b9513d055
4
+ data.tar.gz: 12ba43717656e2bb7561001583afd45e209a458c
5
5
  SHA512:
6
- metadata.gz: e18bffd470b4116a1d3676048a9ed7b18c77fabe7e81f8c85357da527042bfe49a803b5bdac83704dc1c5ab1717424e6da0181b27670cae21f75a9f77f15cc7c
7
- data.tar.gz: 0fef3a1d10d3621c003fb8b012340c13b1e9f2f7da0a3a5b563195abfe1788eabc454347c945852e5a320443a1ba343efdde8e2dd7084daee85833a23374d2f9
6
+ metadata.gz: 4a9c9e4ccd69866f3cd4cdff5bb41b31a1a71f5a34f368d0ba4a23eb6af7908374464f6e68c5c625ac69d3454c96c4e0b87f3ac2d2224ae1619509f6c59d6065
7
+ data.tar.gz: 151b7b2bee2d67c2514f33976e39e02630ddc486e56b87703b425ad65fef20a1948d6c5999b339dc10dfa48b9d1c9ab056b3982eb48ded134079386fe16fc129
@@ -1,7 +1,13 @@
1
1
  require "simple_bdd/version"
2
+ require "simple_bdd/step_not_implemented"
3
+ require "simple_bdd/step_notification"
4
+
5
+ begin
6
+ require "rspec/core"
7
+ rescue LoadError
8
+ end
2
9
 
3
10
  module SimpleBdd
4
- class StepNotImplemented < StandardError; end
5
11
 
6
12
  RSpec.configuration.add_setting(:raise_error_on_missing_step_implementation,
7
13
  default: false) if defined?(::RSpec)
@@ -10,13 +16,14 @@ module SimpleBdd
10
16
  define_method(method) do |message|
11
17
  method_name = methodize(message)
12
18
  if respond_to? method_name || !defined?(::RSpec)
19
+ notification = StepNotification.new(method, message)
20
+ RSpec.configuration.reporter.notify :before_step, notification
13
21
  send method_name
14
22
  else
15
- if RSpec.configuration.raise_error_on_missing_step_implementation?
16
- raise StepNotImplemented, method_name
17
- else
23
+ unless RSpec.configuration.raise_error_on_missing_step_implementation?
18
24
  pending(method_name)
19
25
  end
26
+ raise StepNotImplemented, method_name
20
27
  end
21
28
  end
22
29
 
@@ -1,4 +1,5 @@
1
1
  require 'simple_bdd'
2
+ require "rspec/core"
2
3
 
3
4
  RSpec.configure do |config|
4
5
  config.include SimpleBdd
@@ -0,0 +1,4 @@
1
+ module SimpleBdd
2
+ class StepNotImplemented < StandardError
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module SimpleBdd
2
+ class StepNotification < Struct.new(:method, :message)
3
+ end
4
+ end
@@ -1,3 +1,3 @@
1
1
  module SimpleBdd
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -36,8 +36,8 @@ describe "Pending features in rspec" do
36
36
  end
37
37
 
38
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
39
+ expect(subject).to receive(:pending).with("i_have_not_defined_a_step")
40
+ expect { subject.Given "I have not defined a step" }.to raise_error SimpleBdd::StepNotImplemented
41
41
  end
42
42
 
43
43
  after(:each) do
@@ -7,35 +7,58 @@ end
7
7
  describe SimpleBddExample do
8
8
  let(:subject) { SimpleBddExample.new }
9
9
 
10
+ let(:reporter) do
11
+ double(:reporter, notify: nil)
12
+ end
13
+
14
+ before(:each) do
15
+ RSpec.configuration.stub(:reporter).and_return(reporter)
16
+ end
17
+ after(:each) do
18
+ RSpec.configuration.unstub(:reporter)
19
+ end
20
+
10
21
  describe "#given, #when, #then, #and, #also, #but" do
11
22
  ["given", "when", "then", "and", "Given", "When", "Then", "And", "Also", "also", "But", "but"].each do |method|
12
23
  it "calls the method after translating the string" do
13
- subject.should_receive(:something)
24
+ expect(subject).to receive(:something)
25
+ subject.send(method, "something")
26
+ end
27
+
28
+ it "sends the appropriate before_step notification" do
29
+ allow(subject).to receive(:something)
30
+
31
+ expect(reporter).to receive(:notify) do |type, notification|
32
+ @notification = notification if type == :before_step
33
+ end
34
+
14
35
  subject.send(method, "something")
36
+ expect(@notification.method).to eq(method.capitalize)
37
+ expect(@notification.message).to eq("something")
15
38
  end
16
39
  end
17
40
  end
18
41
 
19
42
  describe "#methodize" do
20
43
  it "removes special chars" do
21
- subject.send(:methodize, "bond, james bond").should == "bond_james_bond"
44
+ expect(subject.send(:methodize, "bond, james bond")).to eq "bond_james_bond"
22
45
  end
23
46
 
24
47
  it "converts to lower case" do
25
- subject.send(:methodize, "HELLO WORLD").should == "hello_world"
48
+ expect(subject.send(:methodize, "HELLO WORLD")).to eq "hello_world"
26
49
  end
27
50
 
28
51
  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"
52
+ expect(subject.send(:methodize, "Bates & Lolcat Realty")).to eq "bates_lolcat_realty"
53
+ expect(subject.send(:methodize, "Ruby / Python / Scala, same deal")).to eq "ruby_python_scala_same_deal"
31
54
  end
32
55
 
33
56
  it "underscores slashes" do
34
- subject.send(:methodize, "Chocolate/Vanilla Cake").should == "chocolate_vanilla_cake"
57
+ expect(subject.send(:methodize, "Chocolate/Vanilla Cake")).to eq "chocolate_vanilla_cake"
35
58
  end
36
59
 
37
60
  it "underscores hyphens" do
38
- subject.send(:methodize, "Red-Velvet Cake").should == "red_velvet_cake"
61
+ expect(subject.send(:methodize, "Red-Velvet Cake")).to eq "red_velvet_cake"
39
62
  end
40
63
  end
41
64
 
@@ -47,7 +70,7 @@ describe SimpleBddExample do
47
70
  called = true
48
71
  end
49
72
 
50
- expect(called).to be_true
73
+ expect(called).to eq true
51
74
  end
52
75
  end
53
76
  end
@@ -1,5 +1,4 @@
1
1
  RSpec.configure do |config|
2
- config.treat_symbols_as_metadata_keys_with_true_values = true
3
2
  config.run_all_when_everything_filtered = true
4
3
  config.filter_run :focus
5
4
  config.order = 'random'
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_bdd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robbie Clutton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-14 00:00:00.000000000 Z
11
+ date: 2014-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: zeus
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: Gherkin methods that turn strings into methods
@@ -59,14 +59,16 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - ".gitignore"
63
- - ".rspec"
62
+ - .gitignore
63
+ - .rspec
64
64
  - Gemfile
65
65
  - LICENSE.txt
66
66
  - README.md
67
67
  - Rakefile
68
68
  - lib/simple_bdd.rb
69
69
  - lib/simple_bdd/rspec.rb
70
+ - lib/simple_bdd/step_not_implemented.rb
71
+ - lib/simple_bdd/step_notification.rb
70
72
  - lib/simple_bdd/version.rb
71
73
  - simple_bdd.gemspec
72
74
  - spec/pending_feature_spec.rb
@@ -82,12 +84,12 @@ require_paths:
82
84
  - lib
83
85
  required_ruby_version: !ruby/object:Gem::Requirement
84
86
  requirements:
85
- - - ">="
87
+ - - '>='
86
88
  - !ruby/object:Gem::Version
87
89
  version: '0'
88
90
  required_rubygems_version: !ruby/object:Gem::Requirement
89
91
  requirements:
90
- - - ">="
92
+ - - '>='
91
93
  - !ruby/object:Gem::Version
92
94
  version: '0'
93
95
  requirements: []