rspec-with-args 0.0.2 → 0.0.3

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: a1530585271d82b26e8b660bd8e8410d662fc783
4
- data.tar.gz: cfcb88f4968e0cfebcd0178fec8f71b4731d9232
3
+ metadata.gz: d2b1693f7729fe84dd3eccc918f906da525d7bf6
4
+ data.tar.gz: 820e8c2ca32946235f32dbc15cc088c4609ab442
5
5
  SHA512:
6
- metadata.gz: 3277d4f28ffc138c798df1bfc9ce5f5086da802636055a634616a0d88a9bd0ad0899f2b7f9745a6ce3718a5ba5b97fefc8df6c9952911daf343c9ea182eda359
7
- data.tar.gz: 4c67292d2063091a9b4a44a8076028c7f943e2572045294a67426bb05bc41b0c2769073830e2f3893280c3ad1071ee340d4992e8aa02c8ed3eb2120d9cffb408
6
+ metadata.gz: fabcbd30f599659998c1c91663d5eaf20a982c31241a0e1d9f5dfc128f8db135cfc04169d46a8684e4d4db89a89b8c54f646d3969c2e901018fe3b1f701cfa08
7
+ data.tar.gz: 6aa77e119a21766caf5003d5553f554858b55e7c8cc9334fa38dbb44e354727429230e5ca6486e976ce23a82133bac151a874b63f28a11bcf57e40549156b21f
@@ -1,169 +1,7 @@
1
- module RSpec::WithArgs
2
- module CommonClassMethods
3
- def descriptee(m)
4
- m[:example_group][:description_args].first
5
- end
6
- end
7
-
8
- module CommonInstanceMethods
9
- def subject_args
10
- args = metadata.fetch(:with_args,[])
11
- if args.is_a?(Array)
12
- args
13
- else
14
- Array.new
15
- end
16
- end
17
-
18
- def metadata
19
- self.class.metadata
20
- end
21
- end
22
-
23
- module ClassExampleGroup
24
- extend CommonClassMethods
25
- include CommonInstanceMethods
26
- RSpec.configure do |c|
27
- c.include self, {with_args:
28
- proc do |a, m|
29
- descriptee(m).is_a?(Class)
30
- end
31
- }
32
- end
33
-
34
- def self.included(base)
35
- set_subject_class_proc(base.metadata)
36
- set_initialization_args(base.metadata)
37
-
38
- base.subject do
39
- instance_eval &subject_class_proc
40
- end
41
- end
42
-
43
- def self.set_subject_class_proc(metadata)
44
- metadata[:subject_class_proc] ||= proc do |x|
45
- described_class.new(*initialization_args.map{|a| send(a)})
46
- end
47
- end
48
-
49
- def self.set_initialization_args(metadata)
50
- metadata[:initialization_args] = metadata.fetch(:with_args,[])
51
- end
52
-
53
- def subject_class_proc
54
- metadata[:subject_class_proc]
55
- end
56
-
57
- def initialization_args
58
- args = metadata[:initialization_args]
59
- if args.is_a?(Array)
60
- args
61
- else
62
- Array.new
63
- end
64
- end
65
- end
66
-
67
- module ClassMethodExampleGroup
68
- extend CommonClassMethods
69
- include CommonInstanceMethods
70
- RSpec.configure do |c|
71
- c.include self, {with_args:
72
- lambda do |a, m|
73
- descriptee(m).to_s.match(/^\./)
74
- end
75
- }
76
- end
77
-
78
- def self.included(base)
79
- set_subject_proc(base.metadata)
80
- set_subject_method_name(base.metadata)
81
-
82
- base.subject do
83
- instance_eval &subject_proc
84
- end
85
- end
86
-
87
- def self.set_subject_proc(metadata)
88
- metadata[:subject_proc] = proc do |x|
89
- described_class.send(
90
- subject_method_name,
91
- *subject_args.map{|a| send(a)}
92
- )
93
- end
94
- end
95
-
96
- def self.set_subject_method_name(metadata)
97
- case d = metadata[:example_group][:description_args].first
98
- when is_a?(Class)
99
- metadata[:subject_method_name] = d
100
- when /^[.#]/
101
- metadata[:subject_method_name] = d.gsub /^[.#]/, ""
102
- end
103
- end
104
-
105
- def subject_proc
106
- metadata[:subject_proc]
107
- end
108
-
109
- def subject_method_name
110
- metadata[:subject_method_name]
111
- end
112
- end
113
-
114
- module InstanceMethodExampleGroup
115
- extend CommonClassMethods
116
- include CommonInstanceMethods
117
- RSpec.configure do |c|
118
- c.include self, {with_args:
119
- lambda do |a, m|
120
- descriptee(m).to_s.match(/^#/)
121
- end
122
- }
123
- end
124
-
125
- def self.included(base)
126
- set_subject_method_proc(base.metadata)
127
- set_subject_method_name(base.metadata)
128
-
129
- base.subject do
130
- callee
131
- end
132
- end
133
-
134
- def self.set_subject_method_proc(metadata)
135
- metadata[:subject_method_proc] = proc do |x|
136
- x.send(
137
- subject_method_name,
138
- *subject_args.map{|a| send(a)}
139
- )
140
- end
141
- end
142
-
143
- def self.set_subject_method_name(metadata)
144
- case d = metadata[:example_group][:description_args].first
145
- when is_a?(Class)
146
- metadata[:subject_method_name] = d
147
- when /^[.#]/
148
- metadata[:subject_method_name] = d.gsub /^[.#]/, ""
149
- end
150
- end
151
-
152
- def callee
153
- instance_exec parent_callee, &subject_method_proc
154
- end
155
-
156
- def parent_callee
157
- instance_eval &metadata[:subject_class_proc]
158
- end
159
-
160
- def subject_method_proc
161
- metadata[:subject_method_proc]
162
- end
163
-
164
- def subject_method_name
165
- metadata[:subject_method_name]
166
- end
167
- end
1
+ path = File.expand_path('../with_args', __FILE__)
2
+ module RSpec::WithArgs; end
168
3
 
4
+ require "#{path}/common_methods"
5
+ Dir["#{path}/*"].each do |file|
6
+ require file
169
7
  end
@@ -1,8 +1,4 @@
1
- require 'rspec-with-args'
2
-
3
- RSpec.configure do |c|
4
- c.treat_symbols_as_metadata_keys_with_true_values = true
5
- end
1
+ require 'rspec-with_args'
6
2
 
7
3
  class Bar
8
4
  def foo
@@ -10,14 +6,6 @@ class Bar
10
6
  end
11
7
  end
12
8
 
13
- describe Bar, :with_args do
14
- context "instance methods with no args" do
15
- describe "#foo" do
16
- it { should eq "bar" }
17
- end
18
- end
19
- end
20
-
21
9
  class Foo < Struct.new(:arg1, :arg2)
22
10
  def foo(m_arg1)
23
11
  m_arg1 + arg1
@@ -28,6 +16,18 @@ class Foo < Struct.new(:arg1, :arg2)
28
16
  end
29
17
  end
30
18
 
19
+ RSpec.configure do |c|
20
+ c.treat_symbols_as_metadata_keys_with_true_values = true
21
+ end
22
+
23
+ describe Bar, :with_args do
24
+ context "instance methods with no args" do
25
+ describe "#foo" do
26
+ it { should eq "bar" }
27
+ end
28
+ end
29
+ end
30
+
31
31
  describe Foo, with_args: [:bar, :baz] do
32
32
  let(:bar) { "bar" }
33
33
  let(:baz) { "baz" }
metadata CHANGED
@@ -1,16 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-with-args
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Stannard
8
8
  - Kelly Stannard
9
9
  - Kelly Stannard
10
+ - Kelly Stannard
11
+ - Kelly Stannard
12
+ - Kelly Stannard
13
+ - Kelly Stannard
14
+ - Kelly Stannard
15
+ - Kelly Stannard
16
+ - Kelly Stannard
17
+ - Kelly Stannard
10
18
  autorequire:
11
19
  bindir: bin
12
20
  cert_chain: []
13
- date: 2013-10-09 00:00:00.000000000 Z
21
+ date: 2014-06-21 00:00:00.000000000 Z
14
22
  dependencies: []
15
23
  description: |
16
24
  rspec-with-args attempts to cut out having to explicitly write the subject of your example group when trying to call methods or add arguments to methods. It works by reading the conventional description syntax to determine what the subject is. Then allowing you to explicitly state what variables will be passed in as arguments.
@@ -21,7 +29,7 @@ executables: []
21
29
  extensions: []
22
30
  extra_rdoc_files: []
23
31
  files:
24
- - lib/rspec-with-args.rb
32
+ - lib/rspec-with_args.rb
25
33
  - lib/with_args.rb
26
34
  - spec/with_args_spec.rb
27
35
  homepage: https://github.com/kwstannard/rspec-with-args
@@ -34,17 +42,17 @@ require_paths:
34
42
  - lib
35
43
  required_ruby_version: !ruby/object:Gem::Requirement
36
44
  requirements:
37
- - - '>='
45
+ - - ">="
38
46
  - !ruby/object:Gem::Version
39
47
  version: '0'
40
48
  required_rubygems_version: !ruby/object:Gem::Requirement
41
49
  requirements:
42
- - - '>='
50
+ - - ">="
43
51
  - !ruby/object:Gem::Version
44
52
  version: '0'
45
53
  requirements: []
46
54
  rubyforge_project:
47
- rubygems_version: 2.0.3
55
+ rubygems_version: 2.2.2
48
56
  signing_key:
49
57
  specification_version: 4
50
58
  summary: adding arguments to the subject