Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 70 lines (53 sloc) 2.449 kb
02fd5de Matt Jankowski change to use rspec
mjankowski authored
1 require 'spec_helper'
2
3 describe 'State' do
4
5 before do
a619187 Matt Jankowski avoid factory girl syntax deprecation warnings
mjankowski authored
6 @draft_post = create :post, :publication_state => 'Draft'
7 @final_post = create :post, :publication_state => 'Final'
8 @free_post = create :post, :post_type => 'Free'
9 @open_post = create :post, :post_type => 'Open'
02fd5de Matt Jankowski change to use rspec
mjankowski authored
10
11 @post = Post.new
12 Post::PUBLICATION_STATES.should_not be_nil
13 end
14
15 it "should set the correct expected values for a column_state _state method" do
16 Post.publication_state_draft.should == [@draft_post]
17 end
18
19 it "should set the correct expected values for a column_not_state _state method" do
20 Post.publication_state_not_draft.should == [@final_post]
21 end
22
23 it "should set the correct expected values for a column_state _type method" do
24 Post.post_type_free.should == [@free_post]
25 end
26
27 it "should set the correct expected values for a column_not_state _type method" do
28 Post.post_type_not_free.should == [@open_post]
29 end
30
31 it "should set the correct expected values for a column_state method" do
32 Post.post_type('Open').should == [@open_post]
33 end
34
35 it "should set the correct expected values for a column_state_not method" do
36 Post.post_type_not('Open').should == [@free_post]
37 end
38
39 Post::PUBLICATION_STATES.each do |state|
40 it "should have a query method for a #{state} state value" do
41 @post.should respond_to("publication_state_#{state.downcase}?")
42 end
43
44 it "should have a non query method for a #{state} state value" do
45 @post.should respond_to("publication_state_not_#{state.downcase}?")
46 end
47
48 it "should respond true to query method for a #{state} state value when in that state" do
49 @post.publication_state = state
50 @post.send("publication_state_#{state.downcase}?").should be_true
51 end
52
53 it "should respond false to not query method for a #{state} state value when in that state" do
54 @post.publication_state = state
55 @post.send("publication_state_not_#{state.downcase}?").should be_false
56 end
57
58 it "should respond false to query method for a #{state} state value when not in that state" do
59 @post.publication_state = 'Invalid'
60 @post.send("publication_state_#{state.downcase}?").should be_false
61 end
62
63 it "should respond true to not query method for a #{state} state value when not in that state" do
64 @post.publication_state = 'Invalid'
65 @post.send("publication_state_not_#{state.downcase}?").should be_true
66 end
67 end
68
69 end
Something went wrong with that request. Please try again.