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.
@@ -6,36 +6,41 @@ h2. Installation
6
6
 
7
7
  bc. $ gem install rspec_attr_extensions
8
8
 
9
- h2. The TestClass
9
+ h2. An example
10
10
 
11
- <pre><code>class TestClass
11
+ p. Let's test that TheHoff contains various attr_* methods.
12
+
13
+ <pre><code>class TheHoff
12
14
 
13
15
  def initialize
14
- @user_id, @name, @admin = 123, "Jungle Julia", false
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 :user_id, :admin
18
- attr_writer :admin
21
+ attr_reader :smash_hit, :date_of_birth
22
+ attr_writer :smash_hit
19
23
 
20
- attr_accessor :name
24
+ attr_accessor :hair_style
21
25
 
22
26
  end
23
27
  </pre></code>
24
28
 
25
- h2. TestClass should have an attr_reader for :user_id and :admin
29
+ p. Load rspec_attr_extensions in your spec_helper file.
26
30
 
27
- bc. describe TestClass do
28
- it_should_have_an_attr_reader_for :user_id, :admin
29
- end
31
+ bc. require "spec"
32
+ require "rspec_attr_extensions"
30
33
 
31
- h2. TestClass should have an attr_writer for :admin
34
+ p. And use the test methods provided by this library to clean up your specs.
32
35
 
33
- bc. describe TestClass do
34
- it_should_have_an_attr_writer_for :admin
35
- end
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
- h2. TestClass should have an attr_accessor for :name
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.instance_methods.should include(field.to_s)
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.instance_methods.should include("#{field}=")
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 TestClass do
3
+ describe TheHoff do
4
4
 
5
- it_should_have_an_attr_reader_for :user_id, :admin
6
- it_should_have_an_attr_writer_for :admin
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 :name
8
+ it_should_have_an_attr_accessor_for :hair_style
9
9
 
10
10
  end
@@ -3,15 +3,17 @@ require "spec"
3
3
 
4
4
  require "rspec_attr_extensions"
5
5
 
6
- class TestClass
6
+ class TheHoff
7
7
 
8
8
  def initialize
9
- @user_id, @name, @admin = 123, "Jungle Julia", false
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 :user_id, :admin
13
- attr_writer :admin
14
+ attr_reader :smash_hit, :date_of_birth
15
+ attr_writer :smash_hit
14
16
 
15
- attr_accessor :name
17
+ attr_accessor :hair_style
16
18
 
17
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_attr_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Harrington