Commit 9a5a6e19274842a7c5b9c84eeb7b6a1558f8bb5d
1 parent
cdc8ec49
Exists in
master
and in
1 other branch
Improving test cases, especially out of date routing
Showing
11 changed files
with
233 additions
and
110 deletions
Show diff stats
spec/factories.rb
| @@ -5,6 +5,11 @@ end | @@ -5,6 +5,11 @@ end | ||
| 5 | Factory.define(:question) do |f| | 5 | Factory.define(:question) do |f| |
| 6 | f.sequence(:name) { |i| "Name #{i}" } | 6 | f.sequence(:name) { |i| "Name #{i}" } |
| 7 | end | 7 | end |
| 8 | +Factory.define(:aoi_question, :parent => :question) do |f| | ||
| 9 | + f.sequence(:name) { |i| "Name #{i}" } | ||
| 10 | + f.association :site, :factory => :user | ||
| 11 | + f.association :creator, :factory => :visitor | ||
| 12 | +end | ||
| 8 | 13 | ||
| 9 | Factory.define(:visitor) do |f| | 14 | Factory.define(:visitor) do |f| |
| 10 | f.sequence(:identifier) { |i| "Identifier #{i}" } | 15 | f.sequence(:identifier) { |i| "Identifier #{i}" } |
| @@ -17,3 +22,17 @@ end | @@ -17,3 +22,17 @@ end | ||
| 17 | Factory.define(:choice) do |f| | 22 | Factory.define(:choice) do |f| |
| 18 | f.sequence(:data) { |i| "Choice: #{i}" } | 23 | f.sequence(:data) { |i| "Choice: #{i}" } |
| 19 | end | 24 | end |
| 25 | + | ||
| 26 | +Factory.sequence :email do |n| | ||
| 27 | + "user#{n}@example.com" | ||
| 28 | +end | ||
| 29 | + | ||
| 30 | +Factory.define :user do |user| | ||
| 31 | + user.email { Factory.next :email } | ||
| 32 | + user.password { "password" } | ||
| 33 | + user.password_confirmation { "password" } | ||
| 34 | +end | ||
| 35 | + | ||
| 36 | +Factory.define :email_confirmed_user, :parent => :user do |user| | ||
| 37 | + user.email_confirmed { true } | ||
| 38 | +end |
spec/models/prompt_spec.rb
spec/models/question_spec.rb
| @@ -39,4 +39,4 @@ describe Question do | @@ -39,4 +39,4 @@ describe Question do | ||
| 39 | end | 39 | end |
| 40 | 40 | ||
| 41 | #q = @aoi_clone.create_question("foobarbaz", {:name => 'foo'}) | 41 | #q = @aoi_clone.create_question("foobarbaz", {:name => 'foo'}) |
| 42 | -end | ||
| 43 | \ No newline at end of file | 42 | \ No newline at end of file |
| 43 | +end |
spec/models/user_spec.rb
| @@ -29,7 +29,7 @@ describe User do | @@ -29,7 +29,7 @@ describe User do | ||
| 29 | end | 29 | end |
| 30 | 30 | ||
| 31 | it "should be able to record a visitor's vote" do | 31 | it "should be able to record a visitor's vote" do |
| 32 | - v = @aoi_clone.record_vote("johnnydoe", @prompt, 0) | 32 | + v = @aoi_clone.record_vote("johnnydoe", @prompt, 0, 304) |
| 33 | prompt_votes = @prompt.votes(true) | 33 | prompt_votes = @prompt.votes(true) |
| 34 | prompt_votes.should_not be_empty | 34 | prompt_votes.should_not be_empty |
| 35 | prompt_votes.size.should eql 1 | 35 | prompt_votes.size.should eql 1 |
| @@ -47,4 +47,4 @@ describe User do | @@ -47,4 +47,4 @@ describe User do | ||
| 47 | s = @aoi_clone.record_skip("johnnydoe", @prompt) | 47 | s = @aoi_clone.record_skip("johnnydoe", @prompt) |
| 48 | end | 48 | end |
| 49 | 49 | ||
| 50 | -end | ||
| 51 | \ No newline at end of file | 50 | \ No newline at end of file |
| 51 | +end |
spec/models/visitor_spec.rb
| @@ -38,7 +38,7 @@ describe Visitor do | @@ -38,7 +38,7 @@ describe Visitor do | ||
| 38 | it "should be able to vote for a prompt" do | 38 | it "should be able to vote for a prompt" do |
| 39 | #@prompt = @question.prompts.first | 39 | #@prompt = @question.prompts.first |
| 40 | @prompt.should_not be_nil | 40 | @prompt.should_not be_nil |
| 41 | - v = @v.vote_for! @prompt, 0 | 41 | + v = @v.vote_for! @prompt, 0, 340 |
| 42 | end | 42 | end |
| 43 | 43 | ||
| 44 | it "should be able to skip a prompt" do | 44 | it "should be able to skip a prompt" do |
| @@ -51,7 +51,7 @@ describe Visitor do | @@ -51,7 +51,7 @@ describe Visitor do | ||
| 51 | prev_winner_score = @lc.score | 51 | prev_winner_score = @lc.score |
| 52 | prev_loser_score = @rc.score | 52 | prev_loser_score = @rc.score |
| 53 | 53 | ||
| 54 | - vote = @v.vote_for! @prompt, 0 | 54 | + vote = @v.vote_for! @prompt, 0, 340 |
| 55 | 55 | ||
| 56 | @lc.reload | 56 | @lc.reload |
| 57 | @rc.reload | 57 | @rc.reload |
| @@ -66,7 +66,7 @@ describe Visitor do | @@ -66,7 +66,7 @@ describe Visitor do | ||
| 66 | prev_loser_losses = @rc.losses | 66 | prev_loser_losses = @rc.losses |
| 67 | prev_loser_wins = @rc.wins | 67 | prev_loser_wins = @rc.wins |
| 68 | 68 | ||
| 69 | - vote = @v.vote_for! @prompt, 0 | 69 | + vote = @v.vote_for! @prompt, 0, 340 |
| 70 | 70 | ||
| 71 | @lc.reload | 71 | @lc.reload |
| 72 | @rc.reload | 72 | @rc.reload |
spec/models/vote_spec.rb
| @@ -6,8 +6,10 @@ describe Vote do | @@ -6,8 +6,10 @@ describe Vote do | ||
| 6 | :tracking => "value for tracking", | 6 | :tracking => "value for tracking", |
| 7 | :site_id => 1, | 7 | :site_id => 1, |
| 8 | :voter_id => 1, | 8 | :voter_id => 1, |
| 9 | - :voteable_id => 1, | ||
| 10 | - :voteable_type => "value for voteable_type" | 9 | + :question_id => 1, |
| 10 | + :prompt_id => 1, | ||
| 11 | + :choice_id=> 1, | ||
| 12 | + :loser_choice_id=> 1, | ||
| 11 | } | 13 | } |
| 12 | end | 14 | end |
| 13 | 15 |
spec/routing/choices_routing_spec.rb
| 1 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | 1 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') |
| 2 | 2 | ||
| 3 | describe ChoicesController do | 3 | describe ChoicesController do |
| 4 | + before(:all) do | ||
| 5 | + | ||
| 6 | + @aoi_clone = Factory.create(:user, :email => "pius@alum.mit.edu", :password => "password", :password_confirmation => "password", :id => 8) | ||
| 7 | + @valid_attributes = { | ||
| 8 | + :site => @aoi_clone, | ||
| 9 | + :creator => @aoi_clone.default_visitor | ||
| 10 | + | ||
| 11 | + } | ||
| 12 | + @q = Question.create!(@valid_attributes) | ||
| 13 | + end | ||
| 4 | describe "route generation" do | 14 | describe "route generation" do |
| 5 | it "maps #index" do | 15 | it "maps #index" do |
| 6 | - route_for(:controller => "choices", :action => "index").should == "/choices" | 16 | + route_for(:controller => "choices", :action => "index", :question_id => @q.id.should == "/questions/#{@q.id}/choices" |
| 7 | end | 17 | end |
| 8 | 18 | ||
| 9 | it "maps #new" do | 19 | it "maps #new" do |
| 10 | - route_for(:controller => "choices", :action => "new").should == "/choices/new" | 20 | + route_for(:controller => "choices", :action => "new", :question_id => @q.id).should == "/questions/#{@q.id}/choices/new" |
| 11 | end | 21 | end |
| 12 | 22 | ||
| 13 | it "maps #show" do | 23 | it "maps #show" do |
| 14 | - route_for(:controller => "choices", :action => "show", :id => "1").should == "/choices/1" | 24 | + route_for(:controller => "choices", :action => "show", :id => "1", :question_id => @q.id).should == "/questions/#{@q.id}/choices/1" |
| 15 | end | 25 | end |
| 16 | 26 | ||
| 17 | it "maps #edit" do | 27 | it "maps #edit" do |
| 18 | - route_for(:controller => "choices", :action => "edit", :id => "1").should == "/choices/1/edit" | 28 | + route_for(:controller => "choices", :action => "edit", :id => "1", :question_id => @q.id).should == "/questions/#{@q.id}/choices/1/edit" |
| 19 | end | 29 | end |
| 20 | 30 | ||
| 21 | it "maps #create" do | 31 | it "maps #create" do |
| 22 | - route_for(:controller => "choices", :action => "create").should == {:path => "/choices", :method => :post} | 32 | + route_for(:controller => "choices", :action => "create", :question_id => @q.id).should == {:path => "/questions/#{@q.id}/choices", :method => :post} |
| 23 | end | 33 | end |
| 24 | 34 | ||
| 25 | it "maps #update" do | 35 | it "maps #update" do |
| 26 | - route_for(:controller => "choices", :action => "update", :id => "1").should == {:path =>"/choices/1", :method => :put} | 36 | + route_for(:controller => "choices", :action => "update", :id => "1", :question_id => @q.id).should == {:path =>"/questions/#{@q.id}/choices/1", :method => :put} |
| 27 | end | 37 | end |
| 28 | 38 | ||
| 29 | it "maps #destroy" do | 39 | it "maps #destroy" do |
| 30 | - route_for(:controller => "choices", :action => "destroy", :id => "1").should == {:path =>"/choices/1", :method => :delete} | 40 | + route_for(:controller => "choices", :action => "destroy", :id => "1", :question_id => @q.id).should == {:path =>"/questions/#{@q.id}/choices/1", :method => :delete} |
| 31 | end | 41 | end |
| 32 | end | 42 | end |
| 33 | 43 | ||
| 34 | describe "route recognition" do | 44 | describe "route recognition" do |
| 35 | it "generates params for #index" do | 45 | it "generates params for #index" do |
| 36 | - params_from(:get, "/choices").should == {:controller => "choices", :action => "index"} | 46 | + params_from(:get, "/questions/#{@q.id}/choices").should == {:controller => "choices", :action => "index", :question_id => @q.id} |
| 37 | end | 47 | end |
| 38 | 48 | ||
| 39 | it "generates params for #new" do | 49 | it "generates params for #new" do |
| 40 | - params_from(:get, "/choices/new").should == {:controller => "choices", :action => "new"} | 50 | + params_from(:get, "/questions/#{@q.id}/choices/new").should == {:controller => "choices", :action => "new", :question_id => @q.id} |
| 41 | end | 51 | end |
| 42 | 52 | ||
| 43 | it "generates params for #create" do | 53 | it "generates params for #create" do |
| 44 | - params_from(:post, "/choices").should == {:controller => "choices", :action => "create"} | 54 | + params_from(:post, "/questions/#{@q.id}/choices").should == {:controller => "choices", :action => "create", :question_id => @q.id} |
| 45 | end | 55 | end |
| 46 | 56 | ||
| 47 | it "generates params for #show" do | 57 | it "generates params for #show" do |
| 48 | - params_from(:get, "/choices/1").should == {:controller => "choices", :action => "show", :id => "1"} | 58 | + params_from(:get, "/questions/#{@q.id}/choices/1").should == {:controller => "choices", :action => "show", :id => "1", :question_id => @q.id} |
| 49 | end | 59 | end |
| 50 | 60 | ||
| 51 | it "generates params for #edit" do | 61 | it "generates params for #edit" do |
| 52 | - params_from(:get, "/choices/1/edit").should == {:controller => "choices", :action => "edit", :id => "1"} | 62 | + params_from(:get, "/questions/#{@q.id}/choices/1/edit").should == {:controller => "choices", :action => "edit", :id => "1", :question_id => @q.id} |
| 53 | end | 63 | end |
| 54 | 64 | ||
| 55 | it "generates params for #update" do | 65 | it "generates params for #update" do |
| 56 | - params_from(:put, "/choices/1").should == {:controller => "choices", :action => "update", :id => "1"} | 66 | + params_from(:put, "/questions/#{@q.id}/choices/1").should == {:controller => "choices", :action => "update", :id => "1", :question_id => @q.id} |
| 57 | end | 67 | end |
| 58 | 68 | ||
| 59 | it "generates params for #destroy" do | 69 | it "generates params for #destroy" do |
| 60 | - params_from(:delete, "/choices/1").should == {:controller => "choices", :action => "destroy", :id => "1"} | 70 | + params_from(:delete, "/questions/#{@q.id}/choices/1").should == {:controller => "choices", :action => "destroy", :id => "1", :question_id => @q.id} |
| 61 | end | 71 | end |
| 62 | end | 72 | end |
| 63 | end | 73 | end |
spec/routing/clicks_routing_spec.rb
| 1 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | 1 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') |
| 2 | 2 | ||
| 3 | describe ClicksController do | 3 | describe ClicksController do |
| 4 | - describe "route generation" do | ||
| 5 | - it "maps #index" do | ||
| 6 | - route_for(:controller => "clicks", :action => "index").should == "/clicks" | ||
| 7 | - end | ||
| 8 | - | ||
| 9 | - it "maps #new" do | ||
| 10 | - route_for(:controller => "clicks", :action => "new").should == "/clicks/new" | ||
| 11 | - end | ||
| 12 | - | ||
| 13 | - it "maps #show" do | ||
| 14 | - route_for(:controller => "clicks", :action => "show", :id => "1").should == "/clicks/1" | ||
| 15 | - end | ||
| 16 | - | ||
| 17 | - it "maps #edit" do | ||
| 18 | - route_for(:controller => "clicks", :action => "edit", :id => "1").should == "/clicks/1/edit" | ||
| 19 | - end | ||
| 20 | - | ||
| 21 | - it "maps #create" do | ||
| 22 | - route_for(:controller => "clicks", :action => "create").should == {:path => "/clicks", :method => :post} | ||
| 23 | - end | ||
| 24 | - | ||
| 25 | - it "maps #update" do | ||
| 26 | - route_for(:controller => "clicks", :action => "update", :id => "1").should == {:path =>"/clicks/1", :method => :put} | ||
| 27 | - end | ||
| 28 | - | ||
| 29 | - it "maps #destroy" do | ||
| 30 | - route_for(:controller => "clicks", :action => "destroy", :id => "1").should == {:path =>"/clicks/1", :method => :delete} | ||
| 31 | - end | ||
| 32 | - end | ||
| 33 | - | ||
| 34 | - describe "route recognition" do | ||
| 35 | - it "generates params for #index" do | ||
| 36 | - params_from(:get, "/clicks").should == {:controller => "clicks", :action => "index"} | ||
| 37 | - end | ||
| 38 | - | ||
| 39 | - it "generates params for #new" do | ||
| 40 | - params_from(:get, "/clicks/new").should == {:controller => "clicks", :action => "new"} | ||
| 41 | - end | ||
| 42 | - | ||
| 43 | - it "generates params for #create" do | ||
| 44 | - params_from(:post, "/clicks").should == {:controller => "clicks", :action => "create"} | ||
| 45 | - end | ||
| 46 | - | ||
| 47 | - it "generates params for #show" do | ||
| 48 | - params_from(:get, "/clicks/1").should == {:controller => "clicks", :action => "show", :id => "1"} | ||
| 49 | - end | ||
| 50 | - | ||
| 51 | - it "generates params for #edit" do | ||
| 52 | - params_from(:get, "/clicks/1/edit").should == {:controller => "clicks", :action => "edit", :id => "1"} | ||
| 53 | - end | ||
| 54 | - | ||
| 55 | - it "generates params for #update" do | ||
| 56 | - params_from(:put, "/clicks/1").should == {:controller => "clicks", :action => "update", :id => "1"} | ||
| 57 | - end | ||
| 58 | - | ||
| 59 | - it "generates params for #destroy" do | ||
| 60 | - params_from(:delete, "/clicks/1").should == {:controller => "clicks", :action => "destroy", :id => "1"} | ||
| 61 | - end | ||
| 62 | - end | 4 | + #clicks is no longer accessible |
| 63 | end | 5 | end |
spec/routing/items_routing_spec.rb
| 1 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | 1 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') |
| 2 | 2 | ||
| 3 | describe ItemsController do | 3 | describe ItemsController do |
| 4 | + before(:all) do | ||
| 5 | + | ||
| 6 | + @aoi_clone = Factory.create(:user, :email => "pius@alum.mit.edu", :password => "password", :password_confirmation => "password", :id => 8) | ||
| 7 | + @valid_attributes = { | ||
| 8 | + :site => @aoi_clone, | ||
| 9 | + :creator => @aoi_clone.default_visitor | ||
| 10 | + | ||
| 11 | + } | ||
| 12 | + @q = Question.create!(@valid_attributes) | ||
| 13 | + end | ||
| 14 | + | ||
| 4 | describe "route generation" do | 15 | describe "route generation" do |
| 5 | it "maps #index" do | 16 | it "maps #index" do |
| 6 | - route_for(:controller => "items", :action => "index").should == "/items" | 17 | + route_for(:controller => "items", :action => "index", :question_id => @q.id ).should == "/questions/#{@q.id}/items" |
| 7 | end | 18 | end |
| 8 | 19 | ||
| 9 | it "maps #new" do | 20 | it "maps #new" do |
| 10 | - route_for(:controller => "items", :action => "new").should == "/items/new" | 21 | + route_for(:controller => "items", :action => "new", :question_id => @q.id).should == "/questions/#{@q.id}/items/new" |
| 11 | end | 22 | end |
| 12 | 23 | ||
| 13 | it "maps #show" do | 24 | it "maps #show" do |
| 14 | - route_for(:controller => "items", :action => "show", :id => "1").should == "/items/1" | 25 | + route_for(:controller => "items", :action => "show", :id => "1", :question_id => @q.id).should == "/questions/#{@q.id}/items/1" |
| 15 | end | 26 | end |
| 16 | 27 | ||
| 17 | it "maps #edit" do | 28 | it "maps #edit" do |
| 18 | - route_for(:controller => "items", :action => "edit", :id => "1").should == "/items/1/edit" | 29 | + route_for(:controller => "items", :action => "edit", :id => "1", :question_id => @q.id).should == "/questions/#{@q.id}/items/1/edit" |
| 19 | end | 30 | end |
| 20 | 31 | ||
| 21 | it "maps #create" do | 32 | it "maps #create" do |
| 22 | - route_for(:controller => "items", :action => "create").should == {:path => "/items", :method => :post} | 33 | + route_for(:controller => "items", :action => "create", :question_id => @q.id).should == {:path => "/questions/#{@q.id}/items", :method => :post} |
| 23 | end | 34 | end |
| 24 | 35 | ||
| 25 | it "maps #update" do | 36 | it "maps #update" do |
| 26 | - route_for(:controller => "items", :action => "update", :id => "1").should == {:path =>"/items/1", :method => :put} | 37 | + route_for(:controller => "items", :action => "update", :id => "1", :question_id => @q.id).should == {:path =>"/questions/#{@q.id}/items/1", :method => :put} |
| 27 | end | 38 | end |
| 28 | 39 | ||
| 29 | it "maps #destroy" do | 40 | it "maps #destroy" do |
| 30 | - route_for(:controller => "items", :action => "destroy", :id => "1").should == {:path =>"/items/1", :method => :delete} | 41 | + route_for(:controller => "items", :action => "destroy", :id => "1", :question_id => @q.id).should == {:path =>"/questions/#{@q.id}/items/1", :method => :delete} |
| 31 | end | 42 | end |
| 32 | end | 43 | end |
| 33 | 44 | ||
| 34 | describe "route recognition" do | 45 | describe "route recognition" do |
| 35 | it "generates params for #index" do | 46 | it "generates params for #index" do |
| 36 | - params_from(:get, "/items").should == {:controller => "items", :action => "index"} | 47 | + params_from(:get, "/questions/#{@q.id}/items").should == {:controller => "items", :action => "index", :question_id => @q.id} |
| 37 | end | 48 | end |
| 38 | 49 | ||
| 39 | it "generates params for #new" do | 50 | it "generates params for #new" do |
| 40 | - params_from(:get, "/items/new").should == {:controller => "items", :action => "new"} | 51 | + params_from(:get, "/questions/#{@q.id}/items/new").should == {:controller => "items", :action => "new", :question_id => @q.id} |
| 41 | end | 52 | end |
| 42 | 53 | ||
| 43 | it "generates params for #create" do | 54 | it "generates params for #create" do |
| 44 | - params_from(:post, "/items").should == {:controller => "items", :action => "create"} | 55 | + params_from(:post, "/questions/#{@q.id}/items").should == {:controller => "items", :action => "create", :question_id => @q.id} |
| 45 | end | 56 | end |
| 46 | 57 | ||
| 47 | it "generates params for #show" do | 58 | it "generates params for #show" do |
| 48 | - params_from(:get, "/items/1").should == {:controller => "items", :action => "show", :id => "1"} | 59 | + params_from(:get, "/questions/#{@q.id}/items/1").should == {:controller => "items", :action => "show", :id => "1", :question_id => @q.id} |
| 49 | end | 60 | end |
| 50 | 61 | ||
| 51 | it "generates params for #edit" do | 62 | it "generates params for #edit" do |
| 52 | - params_from(:get, "/items/1/edit").should == {:controller => "items", :action => "edit", :id => "1"} | 63 | + params_from(:get, "/questions/#{@q.id}/items/1/edit").should == {:controller => "items", :action => "edit", :id => "1", :question_id => @q.id} |
| 53 | end | 64 | end |
| 54 | 65 | ||
| 55 | it "generates params for #update" do | 66 | it "generates params for #update" do |
| 56 | - params_from(:put, "/items/1").should == {:controller => "items", :action => "update", :id => "1"} | 67 | + params_from(:put, "/questions/#{@q.id}/items/1").should == {:controller => "items", :action => "update", :id => "1", :question_id => @q.id} |
| 57 | end | 68 | end |
| 58 | 69 | ||
| 59 | it "generates params for #destroy" do | 70 | it "generates params for #destroy" do |
| 60 | - params_from(:delete, "/items/1").should == {:controller => "items", :action => "destroy", :id => "1"} | 71 | + params_from(:delete, "/questions/#{@q.id}/items/1").should == {:controller => "items", :action => "destroy", :id => "1", :question_id => @q.id} |
| 61 | end | 72 | end |
| 62 | end | 73 | end |
| 63 | end | 74 | end |
spec/routing/prompts_routing_spec.rb
| 1 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | 1 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') |
| 2 | 2 | ||
| 3 | describe PromptsController do | 3 | describe PromptsController do |
| 4 | + before(:all) do | ||
| 5 | + | ||
| 6 | + @aoi_clone = Factory.create(:user, :email => "pius@alum.mit.edu", :password => "password", :password_confirmation => "password", :id => 8) | ||
| 7 | + @valid_attributes = { | ||
| 8 | + :site => @aoi_clone, | ||
| 9 | + :creator => @aoi_clone.default_visitor | ||
| 10 | + | ||
| 11 | + } | ||
| 12 | + @q = Question.create!(@valid_attributes) | ||
| 13 | + end | ||
| 14 | + | ||
| 4 | describe "route generation" do | 15 | describe "route generation" do |
| 5 | it "maps #index" do | 16 | it "maps #index" do |
| 6 | - route_for(:controller => "prompts", :action => "index").should == "/prompts" | 17 | + route_for(:controller => "prompts", :action => "index", :question_id => @q.id).should == "/questions/#{@q.id}/prompts" |
| 7 | end | 18 | end |
| 8 | 19 | ||
| 9 | it "maps #new" do | 20 | it "maps #new" do |
| 10 | - route_for(:controller => "prompts", :action => "new").should == "/prompts/new" | 21 | + route_for(:controller => "prompts", :action => "new", :question_id => @q.id).should == "/questions/#{@q.id}/prompts/new" |
| 11 | end | 22 | end |
| 12 | 23 | ||
| 13 | it "maps #show" do | 24 | it "maps #show" do |
| 14 | - route_for(:controller => "prompts", :action => "show", :id => "1").should == "/prompts/1" | 25 | + route_for(:controller => "prompts", :action => "show", :id => "1", :question_id => @q.id).should == "/questions/#{@q.id}/prompts/1" |
| 15 | end | 26 | end |
| 16 | 27 | ||
| 17 | it "maps #edit" do | 28 | it "maps #edit" do |
| 18 | - route_for(:controller => "prompts", :action => "edit", :id => "1").should == "/prompts/1/edit" | 29 | + route_for(:controller => "prompts", :action => "edit", :id => "1", :question_id => @q.id).should == "/questions/#{@q.id}/prompts/1/edit" |
| 19 | end | 30 | end |
| 20 | 31 | ||
| 21 | it "maps #create" do | 32 | it "maps #create" do |
| 22 | - route_for(:controller => "prompts", :action => "create").should == {:path => "/prompts", :method => :post} | 33 | + route_for(:controller => "prompts", :action => "create", :question_id => @q.id).should == {:path => "/questions/#{@q.id}/prompts", :method => :post} |
| 23 | end | 34 | end |
| 24 | 35 | ||
| 25 | it "maps #update" do | 36 | it "maps #update" do |
| 26 | - route_for(:controller => "prompts", :action => "update", :id => "1").should == {:path =>"/prompts/1", :method => :put} | 37 | + route_for(:controller => "prompts", :action => "update", :id => "1", :question_id => @q.id).should == {:path =>"/questions/#{@q.id}/prompts/1", :method => :put} |
| 27 | end | 38 | end |
| 28 | 39 | ||
| 29 | it "maps #destroy" do | 40 | it "maps #destroy" do |
| 30 | - route_for(:controller => "prompts", :action => "destroy", :id => "1").should == {:path =>"/prompts/1", :method => :delete} | 41 | + route_for(:controller => "prompts", :action => "destroy", :id => "1", :question_id => @q.id).should == {:path =>"/questions/#{@q.id}/prompts/1", :method => :delete} |
| 31 | end | 42 | end |
| 32 | end | 43 | end |
| 33 | 44 | ||
| 34 | describe "route recognition" do | 45 | describe "route recognition" do |
| 35 | it "generates params for #index" do | 46 | it "generates params for #index" do |
| 36 | - params_from(:get, "/prompts").should == {:controller => "prompts", :action => "index"} | 47 | + params_from(:get, "/questions/#{@q.id}/prompts").should == {:controller => "prompts", :action => "index", :question_id => @q.id} |
| 37 | end | 48 | end |
| 38 | 49 | ||
| 39 | it "generates params for #new" do | 50 | it "generates params for #new" do |
| 40 | - params_from(:get, "/prompts/new").should == {:controller => "prompts", :action => "new"} | 51 | + params_from(:get, "/questions/#{@q.id}/prompts/new").should == {:controller => "prompts", :action => "new", :question_id => @q.id} |
| 41 | end | 52 | end |
| 42 | 53 | ||
| 43 | it "generates params for #create" do | 54 | it "generates params for #create" do |
| 44 | - params_from(:post, "/prompts").should == {:controller => "prompts", :action => "create"} | 55 | + params_from(:post, "/questions/#{@q.id}/prompts").should == {:controller => "prompts", :action => "create", :question_id => @q.id} |
| 45 | end | 56 | end |
| 46 | 57 | ||
| 47 | it "generates params for #show" do | 58 | it "generates params for #show" do |
| 48 | - params_from(:get, "/prompts/1").should == {:controller => "prompts", :action => "show", :id => "1"} | 59 | + params_from(:get, "/questions/#{@q.id}/prompts/1").should == {:controller => "prompts", :action => "show", :id => "1", :question_id => @q.id} |
| 49 | end | 60 | end |
| 50 | 61 | ||
| 51 | it "generates params for #edit" do | 62 | it "generates params for #edit" do |
| 52 | - params_from(:get, "/prompts/1/edit").should == {:controller => "prompts", :action => "edit", :id => "1"} | 63 | + params_from(:get, "/questions/#{@q.id}/prompts/1/edit").should == {:controller => "prompts", :action => "edit", :id => "1", :question_id => @q.id} |
| 53 | end | 64 | end |
| 54 | 65 | ||
| 55 | it "generates params for #update" do | 66 | it "generates params for #update" do |
| 56 | - params_from(:put, "/prompts/1").should == {:controller => "prompts", :action => "update", :id => "1"} | 67 | + params_from(:put, "/questions/#{@q.id}/prompts/1").should == {:controller => "prompts", :action => "update", :id => "1", :question_id => @q.id} |
| 57 | end | 68 | end |
| 58 | 69 | ||
| 59 | it "generates params for #destroy" do | 70 | it "generates params for #destroy" do |
| 60 | - params_from(:delete, "/prompts/1").should == {:controller => "prompts", :action => "destroy", :id => "1"} | 71 | + params_from(:delete, "/questions/#{@q.id}/prompts/1").should == {:controller => "prompts", :action => "destroy", :id => "1", :question_id => @q.id} |
| 61 | end | 72 | end |
| 62 | end | 73 | end |
| 63 | end | 74 | end |
| @@ -0,0 +1,128 @@ | @@ -0,0 +1,128 @@ | ||
| 1 | +--- !ruby/object:Gem::Specification | ||
| 2 | +name: factory_girl | ||
| 3 | +version: !ruby/object:Gem::Version | ||
| 4 | + prerelease: false | ||
| 5 | + segments: | ||
| 6 | + - 1 | ||
| 7 | + - 2 | ||
| 8 | + - 3 | ||
| 9 | + version: 1.2.3 | ||
| 10 | +platform: ruby | ||
| 11 | +authors: | ||
| 12 | +- Joe Ferris | ||
| 13 | +autorequire: | ||
| 14 | +bindir: bin | ||
| 15 | +cert_chain: [] | ||
| 16 | + | ||
| 17 | +date: 2009-10-16 00:00:00 -04:00 | ||
| 18 | +default_executable: | ||
| 19 | +dependencies: [] | ||
| 20 | + | ||
| 21 | +description: |- | ||
| 22 | + factory_girl provides a framework and DSL for defining and | ||
| 23 | + using factories - less error-prone, more explicit, and | ||
| 24 | + all-around easier to work with than fixtures. | ||
| 25 | +email: jferris@thoughtbot.com | ||
| 26 | +executables: [] | ||
| 27 | + | ||
| 28 | +extensions: [] | ||
| 29 | + | ||
| 30 | +extra_rdoc_files: | ||
| 31 | +- README.rdoc | ||
| 32 | +files: | ||
| 33 | +- Changelog | ||
| 34 | +- CONTRIBUTION_GUIDELINES.rdoc | ||
| 35 | +- LICENSE | ||
| 36 | +- Rakefile | ||
| 37 | +- README.rdoc | ||
| 38 | +- lib/factory_girl/aliases.rb | ||
| 39 | +- lib/factory_girl/attribute/association.rb | ||
| 40 | +- lib/factory_girl/attribute/callback.rb | ||
| 41 | +- lib/factory_girl/attribute/dynamic.rb | ||
| 42 | +- lib/factory_girl/attribute/static.rb | ||
| 43 | +- lib/factory_girl/attribute.rb | ||
| 44 | +- lib/factory_girl/factory.rb | ||
| 45 | +- lib/factory_girl/proxy/attributes_for.rb | ||
| 46 | +- lib/factory_girl/proxy/build.rb | ||
| 47 | +- lib/factory_girl/proxy/create.rb | ||
| 48 | +- lib/factory_girl/proxy/stub.rb | ||
| 49 | +- lib/factory_girl/proxy.rb | ||
| 50 | +- lib/factory_girl/sequence.rb | ||
| 51 | +- lib/factory_girl/step_definitions.rb | ||
| 52 | +- lib/factory_girl/syntax/blueprint.rb | ||
| 53 | +- lib/factory_girl/syntax/generate.rb | ||
| 54 | +- lib/factory_girl/syntax/make.rb | ||
| 55 | +- lib/factory_girl/syntax/sham.rb | ||
| 56 | +- lib/factory_girl/syntax.rb | ||
| 57 | +- lib/factory_girl.rb | ||
| 58 | +- spec/factory_girl/aliases_spec.rb | ||
| 59 | +- spec/factory_girl/attribute/association_spec.rb | ||
| 60 | +- spec/factory_girl/attribute/callback_spec.rb | ||
| 61 | +- spec/factory_girl/attribute/dynamic_spec.rb | ||
| 62 | +- spec/factory_girl/attribute/static_spec.rb | ||
| 63 | +- spec/factory_girl/attribute_spec.rb | ||
| 64 | +- spec/factory_girl/factory_spec.rb | ||
| 65 | +- spec/factory_girl/proxy/attributes_for_spec.rb | ||
| 66 | +- spec/factory_girl/proxy/build_spec.rb | ||
| 67 | +- spec/factory_girl/proxy/create_spec.rb | ||
| 68 | +- spec/factory_girl/proxy/stub_spec.rb | ||
| 69 | +- spec/factory_girl/proxy_spec.rb | ||
| 70 | +- spec/factory_girl/sequence_spec.rb | ||
| 71 | +- spec/factory_girl/syntax/blueprint_spec.rb | ||
| 72 | +- spec/factory_girl/syntax/generate_spec.rb | ||
| 73 | +- spec/factory_girl/syntax/make_spec.rb | ||
| 74 | +- spec/factory_girl/syntax/sham_spec.rb | ||
| 75 | +- spec/integration_spec.rb | ||
| 76 | +- spec/models.rb | ||
| 77 | +- spec/spec_helper.rb | ||
| 78 | +has_rdoc: true | ||
| 79 | +homepage: http://thoughtbot.com/projects/factory_girl | ||
| 80 | +licenses: [] | ||
| 81 | + | ||
| 82 | +post_install_message: | ||
| 83 | +rdoc_options: | ||
| 84 | +- --line-numbers | ||
| 85 | +- --main | ||
| 86 | +- README.rdoc | ||
| 87 | +require_paths: | ||
| 88 | +- lib | ||
| 89 | +required_ruby_version: !ruby/object:Gem::Requirement | ||
| 90 | + requirements: | ||
| 91 | + - - ">=" | ||
| 92 | + - !ruby/object:Gem::Version | ||
| 93 | + segments: | ||
| 94 | + - 0 | ||
| 95 | + version: "0" | ||
| 96 | +required_rubygems_version: !ruby/object:Gem::Requirement | ||
| 97 | + requirements: | ||
| 98 | + - - ">=" | ||
| 99 | + - !ruby/object:Gem::Version | ||
| 100 | + segments: | ||
| 101 | + - 0 | ||
| 102 | + version: "0" | ||
| 103 | +requirements: [] | ||
| 104 | + | ||
| 105 | +rubyforge_project: | ||
| 106 | +rubygems_version: 1.3.6 | ||
| 107 | +signing_key: | ||
| 108 | +specification_version: 3 | ||
| 109 | +summary: factory_girl provides a framework and DSL for defining and using model instance factories. | ||
| 110 | +test_files: | ||
| 111 | +- spec/factory_girl/aliases_spec.rb | ||
| 112 | +- spec/factory_girl/attribute/association_spec.rb | ||
| 113 | +- spec/factory_girl/attribute/callback_spec.rb | ||
| 114 | +- spec/factory_girl/attribute/dynamic_spec.rb | ||
| 115 | +- spec/factory_girl/attribute/static_spec.rb | ||
| 116 | +- spec/factory_girl/attribute_spec.rb | ||
| 117 | +- spec/factory_girl/factory_spec.rb | ||
| 118 | +- spec/factory_girl/proxy/attributes_for_spec.rb | ||
| 119 | +- spec/factory_girl/proxy/build_spec.rb | ||
| 120 | +- spec/factory_girl/proxy/create_spec.rb | ||
| 121 | +- spec/factory_girl/proxy/stub_spec.rb | ||
| 122 | +- spec/factory_girl/proxy_spec.rb | ||
| 123 | +- spec/factory_girl/sequence_spec.rb | ||
| 124 | +- spec/factory_girl/syntax/blueprint_spec.rb | ||
| 125 | +- spec/factory_girl/syntax/generate_spec.rb | ||
| 126 | +- spec/factory_girl/syntax/make_spec.rb | ||
| 127 | +- spec/factory_girl/syntax/sham_spec.rb | ||
| 128 | +- spec/integration_spec.rb |