rspec_attr_extensions 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.textile
CHANGED
@@ -6,36 +6,41 @@ h2. Installation
|
|
6
6
|
|
7
7
|
bc. $ gem install rspec_attr_extensions
|
8
8
|
|
9
|
-
h2.
|
9
|
+
h2. An example
|
10
10
|
|
11
|
-
|
11
|
+
p. Let's test that TheHoff contains various attr_* methods.
|
12
|
+
|
13
|
+
<pre><code>class TheHoff
|
12
14
|
|
13
15
|
def initialize
|
14
|
-
@
|
16
|
+
@hair_style = "curly"
|
17
|
+
@smash_hit = "Looking for Freedom"
|
18
|
+
@date_of_birth = "July 17, 1952"
|
15
19
|
end
|
16
20
|
|
17
|
-
attr_reader :
|
18
|
-
attr_writer :
|
21
|
+
attr_reader :smash_hit, :date_of_birth
|
22
|
+
attr_writer :smash_hit
|
19
23
|
|
20
|
-
attr_accessor :
|
24
|
+
attr_accessor :hair_style
|
21
25
|
|
22
26
|
end
|
23
27
|
</pre></code>
|
24
28
|
|
25
|
-
|
29
|
+
p. Load rspec_attr_extensions in your spec_helper file.
|
26
30
|
|
27
|
-
bc.
|
28
|
-
|
29
|
-
end
|
31
|
+
bc. require "spec"
|
32
|
+
require "rspec_attr_extensions"
|
30
33
|
|
31
|
-
|
34
|
+
p. And use the test methods provided by this library to clean up your specs.
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
+
<pre><code>require "spec_helper"
|
37
|
+
|
38
|
+
describe TheHoff do
|
39
|
+
|
40
|
+
it_should_have_an_attr_reader_for :smash_hit, :date_of_birth
|
41
|
+
it_should_have_an_attr_writer_for :smash_hit
|
36
42
|
|
37
|
-
|
43
|
+
it_should_have_an_attr_accessor_for :hair_style
|
38
44
|
|
39
|
-
bc. describe TestClass do
|
40
|
-
it_should_have_an_attr_accessor_for :name
|
41
45
|
end
|
46
|
+
</code></pre>
|
@@ -3,7 +3,7 @@ def it_should_have_an_attr_reader_for(*one_or_more_fields)
|
|
3
3
|
|
4
4
|
one_or_more_fields.each do |field|
|
5
5
|
it "should have an attr_reader for #{field}" do
|
6
|
-
model.
|
6
|
+
model.method_defined? field
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -13,7 +13,7 @@ def it_should_have_an_attr_writer_for(*one_or_more_fields)
|
|
13
13
|
|
14
14
|
one_or_more_fields.each do |field|
|
15
15
|
it "should have an attr_writer for #{field}" do
|
16
|
-
model.
|
16
|
+
model.method_defined? "#{field}="
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe TheHoff do
|
4
4
|
|
5
|
-
it_should_have_an_attr_reader_for :
|
6
|
-
it_should_have_an_attr_writer_for :
|
5
|
+
it_should_have_an_attr_reader_for :smash_hit, :date_of_birth
|
6
|
+
it_should_have_an_attr_writer_for :smash_hit
|
7
7
|
|
8
|
-
it_should_have_an_attr_accessor_for :
|
8
|
+
it_should_have_an_attr_accessor_for :hair_style
|
9
9
|
|
10
10
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,15 +3,17 @@ require "spec"
|
|
3
3
|
|
4
4
|
require "rspec_attr_extensions"
|
5
5
|
|
6
|
-
class
|
6
|
+
class TheHoff
|
7
7
|
|
8
8
|
def initialize
|
9
|
-
@
|
9
|
+
@hair_style = "curly"
|
10
|
+
@smash_hit = "Looking for Freedom"
|
11
|
+
@date_of_birth = "July 17, 1952"
|
10
12
|
end
|
11
13
|
|
12
|
-
attr_reader :
|
13
|
-
attr_writer :
|
14
|
+
attr_reader :smash_hit, :date_of_birth
|
15
|
+
attr_writer :smash_hit
|
14
16
|
|
15
|
-
attr_accessor :
|
17
|
+
attr_accessor :hair_style
|
16
18
|
|
17
19
|
end
|