Skip to content
This repository has been archived by the owner on Dec 20, 2019. It is now read-only.

Commit

Permalink
Improved spec syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitrij Denissenko committed Sep 7, 2010
1 parent 815ceb4 commit 2e6b218
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 14 deletions.
Expand Up @@ -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('#')
Expand Down
2 changes: 1 addition & 1 deletion extensions/agile_pm/spec/views/stories/show.js.rjs_spec.rb
Expand Up @@ -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')
Expand Down
Expand Up @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/views/admin/groups/edit.html.erb_spec.rb
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/views/admin/groups/new.html.erb_spec.rb
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/views/admin/projects/edit.html.erb_spec.rb
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/views/admin/projects/new.html.erb_spec.rb
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/views/admin/users/edit.html.erb_spec.rb
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/views/admin/users/new.html.erb_spec.rb
Expand Up @@ -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

Expand Down
5 changes: 1 addition & 4 deletions spec/views/milestones/new.html.erb_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 2e6b218

Please sign in to comment.