Permalink
Browse files

Improved spec syntax

  • Loading branch information...
1 parent 815ceb4 commit 2e6b21801b3cb646ed3e7af8b22ff6c0d677e322 Dimitrij Denissenko committed Sep 7, 2010
@@ -5,7 +5,7 @@
before(:each) do
@project = stub_current_project! :name => 'Retrospectiva'
@milestone = assigns[:milestone] = stub_model(Milestone, :to_param => '37')
- @sprint = assigns[:sprint] = stub_model(Sprint, :new_record? => true)
+ @sprint = assigns[:sprint] = stub_model(Sprint).as_new_record
template.stub!(:permitted?).and_return(true)
template.stub!(:sprint_location).and_return('#')
@@ -10,7 +10,7 @@
@milestone = assigns[:milestone] = stub_model(Milestone)
@sprint = assigns[:sprint] = stub_model(Sprint)
@story = assigns[:story] = stub_model(Story, :events => [@event], :title => 'My Story', :created_at => 4.days.ago)
- @comment = assigns[:story_comment] = stub_model(StoryComment, :new_record? => true)
+ @comment = assigns[:story_comment] = stub_model(StoryComment).as_new_record
template.stub!(:permitted?).and_return(true)
template.stub!(:stories_path).and_return('/path/to/stories')
@@ -93,7 +93,7 @@ def do_get
describe 'GET /new' do
before do
- @file = mock_model(WikiFile, :new_record? => true)
+ @file = stub_model(WikiFile).as_new_record
@files_proxy.stub!(:new).and_return(@file)
end
@@ -119,7 +119,7 @@ def do_get
describe 'POST /create' do
before do
- @file = mock_model(WikiFile, :new_record? => true, :wiki_title= => nil, :save => true)
+ @file = stub_model(WikiFile, :save => true).as_new_record
@files_proxy.stub!(:new).and_return(@file)
end
@@ -4,7 +4,7 @@
before(:each) do
stub_current_user! :admin? => true
- assigns[:group] = @group = stub_model(Group, :project_names => %w(P1 P2), :new_record? => false)
+ assigns[:group] = @group = stub_model(Group, :project_names => %w(P1 P2))
assigns[:projects] = [mock_model(Project, :name => 'P1')]
end
@@ -4,7 +4,7 @@
before(:each) do
stub_current_user! :admin? => true
- assigns[:group] = @group = stub_model(Group, :project_names => %w(P1 P2), :new_record? => true)
+ assigns[:group] = @group = stub_model(Group).as_new_record
assigns[:projects] = [stub_model(Project, :name => 'G1')]
end
@@ -4,7 +4,7 @@
before(:each) do
stub_current_user! :admin? => true
- assigns[:project] = @project = stub_model(Project, :new_record? => false, :short_name_was => 'any', :short_name => 'any')
+ assigns[:project] = @project = stub_model(Project, :short_name_was => 'any', :short_name => 'any').as_new_record
assigns[:repositories] = [stub_model(Repository::Git, :name => 'R1')]
end
@@ -4,7 +4,7 @@
before(:each) do
stub_current_user! :admin? => true
- assigns[:project] = @project = stub_model(Project, :new_record? => true, :short_name_was => 'any', :short_name => 'any')
+ assigns[:project] = @project = stub_model(Project, :short_name_was => 'any', :short_name => 'any').as_new_record
assigns[:repositories] = [stub_model(Repository::Git, :name => 'R1')]
end
@@ -4,7 +4,7 @@
before(:each) do
stub_current_user! :admin? => true
- assigns[:user] = @user = stub_model(User, :new_record? => false, :groups => [stub_model(Group)])
+ assigns[:user] = @user = stub_model(User, :groups => [stub_model(Group)])
assigns[:groups] = [stub_model(Group, :name => 'G1')]
end
@@ -4,7 +4,7 @@
before(:each) do
stub_current_user! :admin? => true
- assigns[:user] = @user = stub_model(User, :new_record? => true, :groups => [])
+ assigns[:user] = @user = stub_model(User, :groups => []).as_new_record
assigns[:groups] = [mock_model(Group, :name => 'G1')]
end
@@ -5,10 +5,7 @@
before(:each) do
@project = stub_current_project!
- @milestone = mock_model Milestone,
- :name => 'M1', :info => 'I1',
- :started_on => Date.today, :finished_on => nil, :due => nil
- @milestone.stub!(:new_record?).and_return(true)
+ @milestone = stub_model(Milestone).as_new_record
assigns[:milestone] = @milestone
render "/milestones/new.html.erb"
end

0 comments on commit 2e6b218

Please sign in to comment.