rspec_attr_extensions 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +41 -0
- data/Rakefile +27 -0
- data/lib/rspec_attr_extensions.rb +26 -0
- data/spec/rspec_attr_extensions_spec/rspec_attr_extensions_spec.rb +10 -0
- data/spec/spec_helper.rb +17 -0
- metadata +73 -0
data/README.textile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
h1. RSpec attr extensions
|
2
|
+
|
3
|
+
p. "RDoc":http://rdoc.info/projects/rubiii/rspec_attr_extensions | "Continuous Integration":http://runcoderun.com/rubiii/rspec_attr_extensions | "Metrics":http://getcaliper.com/caliper/project?repo=git://github.com/rubiii/rspec_attr_extensions.git
|
4
|
+
|
5
|
+
h2. Installation
|
6
|
+
|
7
|
+
bc. $ gem install rspec_attr_extensions
|
8
|
+
|
9
|
+
h2. The TestClass
|
10
|
+
|
11
|
+
<pre><code>class TestClass
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@user_id, @name, @admin = 123, "Jungle Julia", false
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_reader :user_id, :admin
|
18
|
+
attr_writer :admin
|
19
|
+
|
20
|
+
attr_accessor :name
|
21
|
+
|
22
|
+
end
|
23
|
+
</pre></code>
|
24
|
+
|
25
|
+
h2. TestClass should have an attr_reader for :user_id and :admin
|
26
|
+
|
27
|
+
bc. describe TestClass do
|
28
|
+
it_should_have_an_attr_reader_for :user_id, :admin
|
29
|
+
end
|
30
|
+
|
31
|
+
h2. TestClass should have an attr_writer for :admin
|
32
|
+
|
33
|
+
bc. describe TestClass do
|
34
|
+
it_should_have_an_attr_writer_for :admin
|
35
|
+
end
|
36
|
+
|
37
|
+
h2. TestClass should have an attr_accessor for :name
|
38
|
+
|
39
|
+
bc. describe TestClass do
|
40
|
+
it_should_have_an_attr_accessor_for :name
|
41
|
+
end
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "rake"
|
2
|
+
require "spec/rake/spectask"
|
3
|
+
require "spec/rake/verify_rcov"
|
4
|
+
require "rake/rdoctask"
|
5
|
+
|
6
|
+
task :default => :spec
|
7
|
+
|
8
|
+
Spec::Rake::SpecTask.new do |spec|
|
9
|
+
spec.spec_files = FileList["spec/**/*_spec.rb"]
|
10
|
+
spec.spec_opts << "--color"
|
11
|
+
spec.libs += ["lib", "spec"]
|
12
|
+
spec.rcov = true
|
13
|
+
spec.rcov_opts = ['--exclude', 'spec/spec_helper']
|
14
|
+
spec.rcov_dir = "rcov"
|
15
|
+
end
|
16
|
+
|
17
|
+
RCov::VerifyTask.new(:spec_verify => :spec) do |verify|
|
18
|
+
verify.threshold = 100.0
|
19
|
+
verify.index_html = "rcov/index.html"
|
20
|
+
end
|
21
|
+
|
22
|
+
Rake::RDocTask.new do |rdoc|
|
23
|
+
rdoc.title = "RSpec attr extensions"
|
24
|
+
rdoc.rdoc_dir = "rdoc"
|
25
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
26
|
+
rdoc.options = ["--line-numbers", "--inline-source"]
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
def it_should_have_an_attr_reader_for(*one_or_more_fields)
|
2
|
+
model = described_type
|
3
|
+
|
4
|
+
one_or_more_fields.each do |field|
|
5
|
+
it "should have an attr_reader for #{field}" do
|
6
|
+
model.instance_methods.should include(field.to_s)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def it_should_have_an_attr_writer_for(*one_or_more_fields)
|
12
|
+
model = described_type
|
13
|
+
|
14
|
+
one_or_more_fields.each do |field|
|
15
|
+
it "should have an attr_writer for #{field}" do
|
16
|
+
model.instance_methods.should include("#{field}=")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def it_should_have_an_attr_accessor_for(*one_or_more_fields)
|
22
|
+
one_or_more_fields.each do |field|
|
23
|
+
it_should_have_an_attr_reader_for *one_or_more_fields
|
24
|
+
it_should_have_an_attr_writer_for *one_or_more_fields
|
25
|
+
end
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "spec"
|
3
|
+
|
4
|
+
require "rspec_attr_extensions"
|
5
|
+
|
6
|
+
class TestClass
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@user_id, @name, @admin = 123, "Jungle Julia", false
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :user_id, :admin
|
13
|
+
attr_writer :admin
|
14
|
+
|
15
|
+
attr_accessor :name
|
16
|
+
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec_attr_extensions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Harrington
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-24 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.8
|
24
|
+
version:
|
25
|
+
description:
|
26
|
+
email: me@rubiii.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.textile
|
33
|
+
files:
|
34
|
+
- Rakefile
|
35
|
+
- README.textile
|
36
|
+
- lib/rspec_attr_extensions.rb
|
37
|
+
- spec/rspec_attr_extensions_spec/rspec_attr_extensions_spec.rb
|
38
|
+
- spec/spec_helper.rb
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: http://github.com/rubiii/rspec_attr_extensions
|
41
|
+
licenses: []
|
42
|
+
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options:
|
45
|
+
- --charset=UTF-8
|
46
|
+
- --title
|
47
|
+
- RSpec attr extensions
|
48
|
+
- --line-numbers
|
49
|
+
- --inline-source
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
version:
|
64
|
+
requirements: []
|
65
|
+
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.3.5
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: Ruby attribute extensions for RSpec
|
71
|
+
test_files:
|
72
|
+
- spec/rspec_attr_extensions_spec/rspec_attr_extensions_spec.rb
|
73
|
+
- spec/spec_helper.rb
|