rspec-with-args 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/with_args.rb +12 -2
- data/spec/with_args_spec.rb +18 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1530585271d82b26e8b660bd8e8410d662fc783
|
4
|
+
data.tar.gz: cfcb88f4968e0cfebcd0178fec8f71b4731d9232
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3277d4f28ffc138c798df1bfc9ce5f5086da802636055a634616a0d88a9bd0ad0899f2b7f9745a6ce3718a5ba5b97fefc8df6c9952911daf343c9ea182eda359
|
7
|
+
data.tar.gz: 4c67292d2063091a9b4a44a8076028c7f943e2572045294a67426bb05bc41b0c2769073830e2f3893280c3ad1071ee340d4992e8aa02c8ed3eb2120d9cffb408
|
data/lib/with_args.rb
CHANGED
@@ -7,7 +7,12 @@ module RSpec::WithArgs
|
|
7
7
|
|
8
8
|
module CommonInstanceMethods
|
9
9
|
def subject_args
|
10
|
-
metadata.fetch(:with_args,[])
|
10
|
+
args = metadata.fetch(:with_args,[])
|
11
|
+
if args.is_a?(Array)
|
12
|
+
args
|
13
|
+
else
|
14
|
+
Array.new
|
15
|
+
end
|
11
16
|
end
|
12
17
|
|
13
18
|
def metadata
|
@@ -50,7 +55,12 @@ module RSpec::WithArgs
|
|
50
55
|
end
|
51
56
|
|
52
57
|
def initialization_args
|
53
|
-
metadata[:initialization_args]
|
58
|
+
args = metadata[:initialization_args]
|
59
|
+
if args.is_a?(Array)
|
60
|
+
args
|
61
|
+
else
|
62
|
+
Array.new
|
63
|
+
end
|
54
64
|
end
|
55
65
|
end
|
56
66
|
|
data/spec/with_args_spec.rb
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
require 'rspec-with-args'
|
2
2
|
|
3
|
+
RSpec.configure do |c|
|
4
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
5
|
+
end
|
6
|
+
|
7
|
+
class Bar
|
8
|
+
def foo
|
9
|
+
"bar"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
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
|
+
|
3
21
|
class Foo < Struct.new(:arg1, :arg2)
|
4
22
|
def foo(m_arg1)
|
5
23
|
m_arg1 + arg1
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-with-args
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Stannard
|
8
8
|
- Kelly Stannard
|
9
|
+
- Kelly Stannard
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2013-09
|
13
|
+
date: 2013-10-09 00:00:00.000000000 Z
|
13
14
|
dependencies: []
|
14
15
|
description: |
|
15
16
|
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.
|