rspec_explain 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,6 +18,8 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
+ require 'rspec_explain'
22
+
21
23
  describe 'Usage' do
22
24
  subject { Usage.new }
23
25
 
@@ -43,7 +45,10 @@ Or install it yourself as:
43
45
  2 => 4
44
46
  10 => 100
45
47
  ...
48
+
49
+ ## Alternatives
46
50
 
51
+ * https://github.com/oggy/rspec_outlines
47
52
 
48
53
  ## Contributing
49
54
 
@@ -5,20 +5,25 @@ RSpec.configure do |config|
5
5
  end
6
6
 
7
7
  module RSpecExplain
8
- def explain method, examples, run='subject.%s(%s)'
8
+ def explain method, examples, shoulder=:should ##, run='subject.%s(%s)'
9
9
 
10
10
  examples = prepare examples
11
11
 
12
12
  context "##{method}" do
13
13
  examples.each do |input,output|
14
14
  specify "#{input} => #{output}" do
15
- eval(run % [method, input.inspect]).should == output #subject.send(:method, input)
15
+ ##eval(run % [method, input.inspect]).should == output
16
+ subject.send(method, input).send(shoulder) == output #should == output
16
17
  end
17
18
  end
18
19
  end
19
20
 
20
21
  end
21
22
 
23
+ def explain_not method, examples
24
+ explain method, examples, :should_not
25
+ end
26
+
22
27
  private
23
28
  def prepare table
24
29
  case table
@@ -1,3 +1,3 @@
1
1
  module RSpecExplain
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -76,7 +76,15 @@ class Usage
76
76
  3*2 => 2*3
77
77
  1*1 => 1**1
78
78
  EX
79
- end
79
+ end
80
+
81
+ def usage_7
82
+ point = Struct.new(:x,:y)
83
+ p = ->(x,y){ point.new x, y }
84
+
85
+ explain :equal, [p.(1,1),p.(1,1), p.(10,10),p.(10,10)]
86
+ explain_not :equal, [p.(1,1),p.(2,2), p.(3,3),p.(4,4)]
87
+ end
80
88
 
81
89
  def should_be_red
82
90
  explain :equal, <<-EX
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_explain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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: 2012-10-24 00:00:00.000000000 Z
12
+ date: 2012-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec