Merge pull request #1137 from opf/fix/rspec-expect-syntax-style-fixes

Style fix: Replace do…end with {} in expect blocks
pull/1251/head
Martin Linkhorst 11 years ago
commit cf6e7af5b0
  1. 8
      lib/plugins/gravatar/spec/gravatar_spec.rb
  2. 4
      spec/controllers/api/v2/planning_element_type_colors_controller_spec.rb
  3. 20
      spec/controllers/api/v2/planning_element_types_controller_spec.rb
  4. 12
      spec/controllers/api/v2/planning_elements_controller_spec.rb
  5. 4
      spec/controllers/api/v2/project_associations_controller_spec.rb
  6. 4
      spec/controllers/api/v2/project_types_controller_spec.rb
  7. 4
      spec/controllers/api/v2/projects_controller_spec.rb
  8. 28
      spec/controllers/api/v2/reported_project_statuses_controller_spec.rb
  9. 4
      spec/controllers/api/v2/reportings_controller_spec.rb
  10. 8
      spec/controllers/api/v2/timelines_controller_spec.rb
  11. 2
      spec/controllers/search_controller_spec.rb
  12. 8
      spec/controllers/timelines_controller_spec.rb
  13. 6
      spec/controllers/work_packages/moves_controller_spec.rb
  14. 4
      spec/controllers/work_packages_controller_spec.rb
  15. 2
      spec/mailers/user_mailer_spec.rb
  16. 4
      spec/models/mail_handler_spec.rb
  17. 2
      spec/models/setting_spec.rb
  18. 8
      spec/models/user_spec.rb
  19. 2
      spec/views/users/edit.html.erb_spec.rb

@ -13,7 +13,7 @@ describe "gravatar_url with a custom default URL" do
end
it "should include the \"default\" argument in the result" do
@url.should match(/&default=no_avatar.png/)
expect(@url).to match(/&default=no_avatar.png/)
end
after(:each) do
@ -28,17 +28,17 @@ describe "gravatar_url with default settings" do
end
it "should have a nil default URL" do
DEFAULT_OPTIONS[:default].should be_nil
expect(DEFAULT_OPTIONS[:default]).to be_nil
end
it "should not include the \"default\" argument in the result" do
@url.should_not match(/&default=/)
expect(@url).not_to match(/&default=/)
end
end
describe "gravatar with a custom title option" do
it "should include the title in the result" do
gravatar('example@example.com', :title => "This is a title attribute").should match(/This is a title attribute/)
expect(gravatar('example@example.com', :title => "This is a title attribute")).to match(/This is a title attribute/)
end
end

@ -91,9 +91,9 @@ describe Api::V2::PlanningElementTypeColorsController do
else # but have to write it that way
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'show', :id => '1337', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
end

@ -51,9 +51,9 @@ describe Api::V2::PlanningElementTypesController do
describe 'with unknown project' do
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'index', :project_id => 'blah', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
@ -114,17 +114,17 @@ describe Api::V2::PlanningElementTypesController do
describe 'with unknown project' do
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'show', :project_id => 'blah', :id => '1337', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
describe 'with unknown planning element type' do
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'show', :project_id => project.identifier, :id => '1337', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
@ -134,9 +134,9 @@ describe Api::V2::PlanningElementTypesController do
end
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'show', :project_id => project.identifier, :id => '1337', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
@ -218,9 +218,9 @@ describe Api::V2::PlanningElementTypesController do
else # but have to write it that way
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'show', :id => '1337', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
end

@ -526,9 +526,9 @@ describe Api::V2::PlanningElementsController do
become_member_with_view_planning_element_permissions
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'show', :project_id => project.id, :id => '1337', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
end
@ -786,9 +786,9 @@ describe Api::V2::PlanningElementsController do
become_member_with_delete_planning_element_permissions
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'destroy', :project_id => project.id, :id => '1337', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
end
@ -834,9 +834,9 @@ describe Api::V2::PlanningElementsController do
it 'deletes the record' do
get 'destroy', :project_id => project.id, :id => planning_element.id, :format => 'xml'
expect do
expect {
planning_element.reload
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
end

@ -124,9 +124,9 @@ describe Api::V2::ProjectAssociationsController do
describe 'w/ the current user being a member' do
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'show', :project_id => project.id, :id => '1337', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
end

@ -77,9 +77,9 @@ describe Api::V2::ProjectTypesController do
describe 'show.xml' do
describe 'with unknown project type' do
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'show', :id => '1337', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end

@ -106,9 +106,9 @@ describe Api::V2::ProjectsController do
describe 'with unknown project' do
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'show', :id => 'unknown_project', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end

@ -46,9 +46,9 @@ describe Api::V2::ReportedProjectStatusesController do
describe 'index.xml' do
describe 'with unknown project_type' do
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'index', :project_type_id => '0', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
@ -106,17 +106,17 @@ describe Api::V2::ReportedProjectStatusesController do
describe 'with unknown project_type' do
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'show', :project_type_id => '0', :id => '1337', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
describe 'with unknown reported_project_status' do
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'show', :project_type_id => project_type.id, :id => '1337', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
@ -133,18 +133,18 @@ describe Api::V2::ReportedProjectStatusesController do
end
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'show', :project_type_id => project_type.id, :id => '1337', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
describe 'with reported_project_status not available for project_type' do
it 'raises ActiveRecord::RecordNotFound errors' do
available_reported_project_status
expect do
expect {
get 'show', :project_type_id => project_type.id, :id => '1337', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
@ -207,9 +207,9 @@ describe Api::V2::ReportedProjectStatusesController do
describe 'show.xml' do
describe 'with unknown reported_project_status' do
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'show', :id => '1337', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
@ -221,9 +221,9 @@ describe Api::V2::ReportedProjectStatusesController do
end
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'show', :id => '1337', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end

@ -131,9 +131,9 @@ describe Api::V2::ReportingsController do
let(:project) { FactoryGirl.create(:project, :identifier => 'test_project') }
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
get 'show', :project_id => project.id, :id => '1337', :format => 'xml'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
end

@ -165,9 +165,9 @@ describe Api::V2::TimelinesController do
become_member_with_all_permissions
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
fetch :project_id => project.id, :id => '1337'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
end
@ -189,9 +189,9 @@ describe Api::V2::TimelinesController do
let(:other_project) { FactoryGirl.create(:project, :identifier => 'other') }
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
fetch :project_id => other_project.identifier,:id => timeline.id
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end

@ -204,7 +204,7 @@ describe SearchController do
# NOTE: this is how it is favored to do in RSpec3
# expect(check_block).to receive :call
# but we have only RSpec2 here, so:
check_block.should_receive :call
expect(check_block).to receive :call
@controller.send(:scan_work_package_reference, query, &check_block)
end

@ -165,9 +165,9 @@ describe TimelinesController do
become_member_with_all_permissions
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
fetch :project_id => project.id, :id => '1337'
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
end
@ -189,9 +189,9 @@ describe TimelinesController do
let(:other_project) { FactoryGirl.create(:project, :identifier => 'other') }
it 'raises ActiveRecord::RecordNotFound errors' do
expect do
expect {
fetch :project_id => other_project.identifier,:id => timeline.id
end.to raise_error(ActiveRecord::RecordNotFound)
}.to raise_error(ActiveRecord::RecordNotFound)
end
end

@ -393,7 +393,7 @@ describe WorkPackages::MovesController do
end
before do
User.stub(:current).and_return(current_user)
allow(User).to receive(:current).and_return(current_user)
def self.copy_child_work_package
post :create,
@ -407,7 +407,7 @@ describe WorkPackages::MovesController do
context "when cross_project_work_package_relations is disabled" do
before do
Setting.stub(:cross_project_work_package_relations?).and_return(false)
allow(Setting).to receive(:cross_project_work_package_relations?).and_return(false)
copy_child_work_package
end
@ -419,7 +419,7 @@ describe WorkPackages::MovesController do
context "when cross_project_work_package_relations is enabled" do
before do
Setting.stub(:cross_project_work_package_relations?).and_return(true)
allow(Setting).to receive(:cross_project_work_package_relations?).and_return(true)
copy_child_work_package
end

@ -293,9 +293,9 @@ describe WorkPackagesController do
it "performs a successful export" do
wp = work_package
expect do
expect {
get :index, :format => 'csv'
end.to_not raise_error
}.to_not raise_error
data = CSV.parse(response.body)

@ -57,7 +57,7 @@ describe UserMailer do
# the name method uses a format setting to determine how to concatenate first name
# and last name whereby an unescaped comma will lead to have two email addresses
# defined instead of one (['Bobbi', 'bob.bobbi@example.com'] vs. ['bob.bobbi@example.com'])
test_user.stub(:name).and_return('Bobbi, Bob')
allow(test_user).to receive(:name).and_return('Bobbi, Bob')
end
it 'escapes the name attribute properly' do

@ -283,7 +283,7 @@ describe MailHandler do
Setting.default_language = 'en'
Role.non_member.update_attribute :permissions, [:add_work_packages]
project.update_attribute :is_public, true
expect do
expect {
work_package = submit_email('ticket_by_unknown_user.eml', {:issue => {:project => 'onlinestore'}, :unknown_user => 'create'})
work_package_created(work_package)
expect(work_package.author.active?).to be_true
@ -303,7 +303,7 @@ describe MailHandler do
expect(work_package.author).to eq(found_user)
expect(found_user.check_password?(password)).to be_true
end.to change(User, :count).by(1)
}.to change(User, :count).by(1)
end
# it "should not add an work_package if from header is missing" do

@ -108,7 +108,7 @@ describe Setting do
end
it "calls no callback on invalid setting" do
Setting.any_instance.stub(:valid?).and_return(false)
allow_any_instance_of(Setting).to receive(:valid?).and_return(false)
Setting.notified_events = 'invalid'
expect(collector).to be_empty
end

@ -325,11 +325,11 @@ describe User do
end
it 'creates a SystemUser' do
expect do
expect {
system_user = User.system
expect(system_user.new_record?).to be_false
expect(system_user.is_a?(SystemUser)).to be_true
end.to change(User, :count).by(1)
}.to change(User, :count).by(1)
end
end
@ -340,10 +340,10 @@ describe User do
end
it 'returns existing SystemUser' do
expect do
expect {
system_user = User.system
expect(system_user).to eq(@u)
end.to change(User, :count).by(0)
}.to change(User, :count).by(0)
end
end
end

@ -39,7 +39,7 @@ describe 'users/edit' do
assign(:user, user)
assign(:auth_sources, [])
view.stub(:current_user).and_return(current_user)
allow(view).to receive(:current_user).and_return(current_user)
render
end

Loading…
Cancel
Save