static-model 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +13 -1
- data/lib/spec/static_model.rb +15 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/static_model_spec.rb +5 -0
- data/static-model.gemspec +1 -1
- metadata +4 -1
data/README.markdown
CHANGED
@@ -67,12 +67,24 @@ To use this class in a Rails controller, you’d do something like
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
+
Testing
|
71
|
+
-------
|
72
|
+
|
73
|
+
There is an RSpec shared example group named `StaticModel` that you can use to test your subclasses to ensure they contain all the necessary behavior. To make it available simply paste
|
74
|
+
|
75
|
+
require('spec/static_model')
|
76
|
+
|
77
|
+
into `spec/spec_helper.rb`. Then in your subclass’s spec simply use
|
78
|
+
|
79
|
+
it_should_behave_like('StaticModel')
|
80
|
+
|
70
81
|
Colophon
|
71
82
|
--------
|
72
83
|
|
73
84
|
### See also
|
74
85
|
|
75
|
-
If you like this gem, you may also want to check out [
|
86
|
+
If you like this gem, you may also want to check out [Active Model Email Validator](http://codyrobbins.com/software/active-model-email-validator), [Email Test Helpers](http://codyrobbins.com/software/email-test-helpers), or [HTTP Error](http://codyrobbins.com/software/http\
|
87
|
+
-error).
|
76
88
|
|
77
89
|
### Tested with
|
78
90
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
shared_examples_for 'StaticModel' do
|
2
|
+
describe '#initialize' do
|
3
|
+
it 'sets the attributes' do
|
4
|
+
described_class.any_instance.expects(:attribute_1=).with(1)
|
5
|
+
described_class.any_instance.expects(:attribute_2=).with(2)
|
6
|
+
|
7
|
+
described_class.new(:attribute_1 => 1, :attribute_2 => 2)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#persisted?' do
|
12
|
+
subject { described_class.new.persisted? }
|
13
|
+
it { should be_false }
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require('spec/static_model')
|
data/static-model.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: static-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: "1.
|
5
|
+
version: "1.1"
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Cody Robbins
|
@@ -37,7 +37,10 @@ files:
|
|
37
37
|
- .yardopts
|
38
38
|
- LICENSE
|
39
39
|
- README.markdown
|
40
|
+
- lib/spec/static_model.rb
|
40
41
|
- lib/static-model.rb
|
42
|
+
- spec/spec_helper.rb
|
43
|
+
- spec/static_model_spec.rb
|
41
44
|
- static-model.gemspec
|
42
45
|
has_rdoc: true
|
43
46
|
homepage: http://codyrobbins.com/software/static-model
|