Convert specs to RSpec 2.99.0 syntax with Transpec

This conversion is done by Transpec 1.12.0 with the following command:
    transpec

* 100 conversions
    from: it { should ... }
      to: it { is_expected.to ... }

* 17 conversions
    from: expect(collection).to have(n).items
      to: expect(collection.size).to eq(n)

* 10 conversions
    from: obj.stub(:message)
      to: allow(obj).to receive(:message)

* 9 conversions
    from: be_true
      to: be_truthy

* 9 conversions
    from: expect(obj).to have(n).errors_on(...)
      to: expect(obj.errors_on(...).size).to eq(n)

* 8 conversions
    from: obj.should
      to: expect(obj).to

* 4 conversions
    from: Klass.any_instance.stub(:message)
      to: allow_any_instance_of(Klass).to receive(:message)

* 2 conversions
    from: be_false
      to: be_falsey

* 2 conversions
    from: expect(obj).to have(n).error_on(...)
      to: expect(obj.error_on(...).size).to eq(n)

* 2 conversions
    from: pending 'is an example' { }
      to: skip 'is an example' { }

* 1 conversion
    from: before { example }
      to: before { |example| example }

* 1 conversion
    from: expect(collection).to have_at_least(n).items
      to: expect(collection.size).to be >= n

* 1 conversion
    from: obj.unstub(:message)
      to: allow(obj).to receive(:message).and_call_original

* 1 conversion
    from: pending
      to: skip
pull/1461/head
Alex Coles 11 years ago
parent 39cb37d3dc
commit efe24e1049
  1. 16
      spec/api/work_package_resource_spec.rb
  2. 2
      spec/controllers/account_controller_spec.rb
  3. 14
      spec/controllers/api/v3/work_packages_controller_spec.rb
  4. 2
      spec/controllers/application_controller_spec.rb
  5. 2
      spec/controllers/members_controller_spec.rb
  6. 2
      spec/controllers/news_controller_spec.rb
  7. 2
      spec/controllers/work_packages_controller_spec.rb
  8. 4
      spec/features/accessibility/custom_fields_spec.rb
  9. 2
      spec/features/accessibility/work_packages/work_package_query_spec.rb
  10. 2
      spec/helpers/application_helper_spec.rb
  11. 6
      spec/lib/open_project/content_type_detector_spec.rb
  12. 4
      spec/lib/open_project/file_command_content_type_detector_spec.rb
  13. 12
      spec/models/custom_field_spec.rb
  14. 14
      spec/models/news_spec.rb
  15. 2
      spec/models/query_spec.rb
  16. 4
      spec/models/user_spec.rb
  17. 2
      spec/models/version_spec.rb
  18. 18
      spec/models/work_package/work_package_validations_spec.rb
  19. 12
      spec/models/work_package_spec.rb
  20. 2
      spec/spec_helper.rb
  21. 12
      spec/views/api/v3/groups/index_api_json_spec.rb
  22. 18
      spec/views/api/v3/projects/index_api_json_spec.rb
  23. 14
      spec/views/api/v3/projects/show_api_json_spec.rb
  24. 14
      spec/views/api/v3/queries/available_columns_api_json_spec.rb
  25. 24
      spec/views/api/v3/queries/grouped_api_json_spec.rb
  26. 12
      spec/views/api/v3/roles/index_api_json_spec.rb
  27. 12
      spec/views/api/v3/versions/index_api_json_spec.rb
  28. 12
      spec/views/api/v3/work_packages/column_data_api_json_spec.rb
  29. 12
      spec/views/api/v3/work_packages/column_sums_api_json_spec.rb
  30. 66
      spec/views/api/v3/work_packages/index_api_json_spec.rb
  31. 14
      spec/views/layouts/base.html.erb_spec.rb

@ -63,24 +63,24 @@ describe 'API v3 Work package resource' do
end
it 'should respond with 200' do
last_response.status.should eq(200)
expect(last_response.status).to eq(200)
end
it 'should respond with work package in HAL+JSON format' do
parsed_response = JSON.parse(last_response.body)
parsed_response.should eq(expected_response)
expect(parsed_response).to eq(expected_response)
end
context 'requesting nonexistent work package' do
let(:get_path) { "/api/v3/work_packages/909090" }
it 'should respond with 404' do
last_response.status.should eq(404)
expect(last_response.status).to eq(404)
end
it 'should respond with explanatory error message' do
parsed_errors = JSON.parse(last_response.body)['errors']
parsed_errors.should eq([{ 'key' => 'not_found', 'messages' => ['Couldn\'t find WorkPackage with id=909090']}])
expect(parsed_errors).to eq([{ 'key' => 'not_found', 'messages' => ['Couldn\'t find WorkPackage with id=909090']}])
end
end
end
@ -92,12 +92,12 @@ describe 'API v3 Work package resource' do
end
it 'should respond with 403' do
last_response.status.should eq(403)
expect(last_response.status).to eq(403)
end
it 'should respond with explanatory error message' do
parsed_errors = JSON.parse(last_response.body)['errors']
parsed_errors.should eq([{ 'key' => 'not_authorized', 'messages' => ['You are not authorize to access this resource']}])
expect(parsed_errors).to eq([{ 'key' => 'not_authorized', 'messages' => ['You are not authorize to access this resource']}])
end
end
@ -108,12 +108,12 @@ describe 'API v3 Work package resource' do
end
it 'should respond with 401' do
last_response.status.should eq(401)
expect(last_response.status).to eq(401)
end
it 'should respond with explanatory error message' do
parsed_errors = JSON.parse(last_response.body)['errors']
parsed_errors.should eq([{ 'key' => 'not_authenticated', 'messages' => ['You need to be authenticated to access this resource']}])
expect(parsed_errors).to eq([{ 'key' => 'not_authenticated', 'messages' => ['You need to be authenticated to access this resource']}])
end
end

@ -151,7 +151,7 @@ describe AccountController do
end
it 'should not login the user' do
expect(@controller.send(:current_user).anonymous?).to be_true
expect(@controller.send(:current_user).anonymous?).to be_truthy
end
end
end

@ -100,7 +100,7 @@ describe Api::V3::WorkPackagesController do
query.stub_chain(:results, :total_entries).and_return([])
# FIXME: METADATA TOO TRICKY TO DEAL WITH
controller.stub(:set_work_packages_meta_data)
allow(controller).to receive(:set_work_packages_meta_data)
end
context 'with 2 work packages' do
@ -112,12 +112,12 @@ describe Api::V3::WorkPackagesController do
expect(assigns(:work_packages).size).to eq(2)
expect(assigns(:can).size).to eq(6)
expect(assigns(:can)['edit']).to be_true
expect(assigns(:can)['log_time']).to be_true
expect(assigns(:can)['update']).to be_true
expect(assigns(:can)['move']).to be_true
expect(assigns(:can)['copy']).to be_false
expect(assigns(:can)['delete']).to be_true
expect(assigns(:can)['edit']).to be_truthy
expect(assigns(:can)['log_time']).to be_truthy
expect(assigns(:can)['update']).to be_truthy
expect(assigns(:can)['move']).to be_truthy
expect(assigns(:can)['copy']).to be_falsey
expect(assigns(:can)['delete']).to be_truthy
expect(assigns(:projects)).to eq([project_1])
expect(assigns(:project)).to eq(project_1)

@ -98,7 +98,7 @@ describe ApplicationController do
@controller.send :handle_unverified_request
expect(@controller.send(:current_user).anonymous?).to be_true
expect(@controller.send(:current_user).anonymous?).to be_truthy
end
end

@ -61,7 +61,7 @@ describe MembersController do
[admin, user].each do |u|
u.reload
expect(u.memberships).to have_at_least(1).item
expect(u.memberships.size).to be >= 1
expect(u.memberships.find do |m|
expect(m.roles).to include(role)

@ -114,7 +114,7 @@ describe NewsController do
expect(news.author).to eq user
expect(news.project).to eq project
expect(ActionMailer::Base.deliveries).to have(1).element
expect(ActionMailer::Base.deliveries.size).to eq(1)
end
end

@ -147,7 +147,7 @@ describe WorkPackagesController do
query.stub_chain(:results, :work_package_count_by_group).and_return([])
query.stub_chain(:results, :column_total_sums).and_return([])
query.stub_chain(:results, :column_group_sums).and_return([])
query.stub(:as_json).and_return("")
allow(query).to receive(:as_json).and_return("")
end
describe 'html' do

@ -212,7 +212,7 @@ describe 'Custom field accessibility' do
include_context "index page with query"
pending # it_behaves_like "localized table header"
skip # it_behaves_like "localized table header"
end
context "de" do
@ -220,7 +220,7 @@ describe 'Custom field accessibility' do
include_context "index page with query"
pending # it_behaves_like "localized table header"
skip # it_behaves_like "localized table header"
end
end

@ -61,7 +61,7 @@ describe 'Work package index accessibility' do
it { expect(select_all_link[:alt]).to eq(I18n.t(:button_check_all)) }
it do
pending("This test is failing because of what seems to be a bug in selenium. " \
skip("This test is failing because of what seems to be a bug in selenium. " \
"The hidden-for-sighted elements cannot be found using because they are styled with " \
"absolute positioning and have an x index off the side of the page. If you remove " \
"the x coord then it will find them but that doesn't seem like a satisfactory solution.")

@ -171,7 +171,7 @@ describe ApplicationHelper do
end
after do
User.unstub(:current)
allow(User).to receive(:current).and_call_original
Setting.enabled_scm.delete "Filesystem"
end

@ -69,8 +69,8 @@ describe OpenProject::ContentTypeDetector do
end
it 'returns content type of file if it is an acceptable type' do
MIME::Types.stub(:type_for).and_return([MIME::Type.new('application/mp4'), MIME::Type.new('video/mp4'), MIME::Type.new('audio/mp4')])
Cocaine::CommandLine.any_instance.stub(:run).and_return("video/mp4")
allow(MIME::Types).to receive(:type_for).and_return([MIME::Type.new('application/mp4'), MIME::Type.new('video/mp4'), MIME::Type.new('audio/mp4')])
allow_any_instance_of(Cocaine::CommandLine).to receive(:run).and_return("video/mp4")
@filename = "my_file.mp4"
assert_equal "video/mp4", OpenProject::ContentTypeDetector.new(@filename).detect
end
@ -91,7 +91,7 @@ describe OpenProject::ContentTypeDetector do
end
it 'returns a sensible default when the file command is missing' do
Cocaine::CommandLine.any_instance.stub(:run).and_raise(Cocaine::CommandLineError.new)
allow_any_instance_of(Cocaine::CommandLine).to receive(:run).and_raise(Cocaine::CommandLineError.new)
@filename = "/path/to/something"
assert_equal "application/binary", OpenProject::ContentTypeDetector.new(@filename).detect
end

@ -69,14 +69,14 @@ describe OpenProject::FileCommandContentTypeDetector do
end
it 'returns a sensible default when the file command is missing' do
Cocaine::CommandLine.any_instance.stub(:run).and_raise(Cocaine::CommandLineError.new)
allow_any_instance_of(Cocaine::CommandLine).to receive(:run).and_raise(Cocaine::CommandLineError.new)
@filename = "/path/to/something"
assert_equal "application/binary",
OpenProject::FileCommandContentTypeDetector.new(@filename).detect
end
it 'returns a sensible default on the odd chance that run returns nil' do
Cocaine::CommandLine.any_instance.stub(:run).and_return(nil)
allow_any_instance_of(Cocaine::CommandLine).to receive(:run).and_return(nil)
assert_equal "application/binary",
OpenProject::FileCommandContentTypeDetector.new("windows").detect
end

@ -119,7 +119,7 @@ describe CustomField do
"locale" => "de" } ]
end
it { expect(field).to have(1).translations }
it { expect(field.size).to eq(1) }
it { expect(field.name(:de)).to eq("Feld") }
it { expect(field.default_value(:de)).to eq("zwei") }
it { expect(field.possible_values(:locale => :de)).to eq(["eins", "zwei", "drei"]) }
@ -130,7 +130,7 @@ describe CustomField do
field.translations_attributes = [ { "locale" => "de" } ]
end
it { expect(field).to have(0).translations }
it { expect(field.size).to eq(0) }
end
describe "WHEN providing a hash with a locale and blank values" do
@ -141,7 +141,7 @@ describe CustomField do
"locale" => "de" } ]
end
it { expect(field).to have(0).translations }
it { expect(field.size).to eq(0) }
end
describe "WHEN providing a hash with a locale and only one values" do
@ -150,7 +150,7 @@ describe CustomField do
"locale" => "de" } ]
end
it { expect(field).to have(1).translations }
it { expect(field.size).to eq(1) }
it { expect(field.name(:de)).to eq("Feld") }
end
@ -162,7 +162,7 @@ describe CustomField do
"locale" => "" } ]
end
it { expect(field).to have(0).translations }
it { expect(field.size).to eq(0) }
end
describe "WHEN already having a translation and wishing to delete it" do
@ -182,7 +182,7 @@ describe CustomField do
field.save!
end
it { expect(field).to have(1).translations }
it { expect(field.size).to eq(1) }
end
end

@ -66,22 +66,22 @@ describe News do
10.times { FactoryGirl.create(:news, project: project) }
expect(News.latest(User.current, 2)).to have(2).elements
expect(News.latest(User.current, 6)).to have(6).elements
expect(News.latest(User.current, 15)).to have(10).elements
expect(News.latest(User.current, 2).size).to eq(2)
expect(News.latest(User.current, 6).size).to eq(6)
expect(News.latest(User.current, 15).size).to eq(10)
end
it "returns five news elements by default" do
News.delete_all
2.times { FactoryGirl.create(:news, project: project) }
expect(News.latest).to have(2).elements
expect(News.latest.size).to eq(2)
3.times { FactoryGirl.create(:news, project: project) }
expect(News.latest).to have(5).elements
expect(News.latest.size).to eq(5)
2.times { FactoryGirl.create(:news, project: project) }
expect(News.latest).to have(5).elements
expect(News.latest.size).to eq(5)
end
end
@ -94,7 +94,7 @@ describe News do
with_settings notified_events: ['news_added'] do
FactoryGirl.create(:news, project: project)
expect(ActionMailer::Base.deliveries).to have(1).element
expect(ActionMailer::Base.deliveries.size).to eq(1)
end
end
end

@ -73,7 +73,7 @@ describe Query do
let(:query) { FactoryGirl.build(:query).tap {|q| q.filters = []} }
it 'is valid' do
expect(query.valid?).to be_true
expect(query.valid?).to be_truthy
end
end

@ -327,8 +327,8 @@ describe User do
it 'creates a SystemUser' do
expect {
system_user = User.system
expect(system_user.new_record?).to be_false
expect(system_user.is_a?(SystemUser)).to be_true
expect(system_user.new_record?).to be_falsey
expect(system_user.is_a?(SystemUser)).to be_truthy
}.to change(User, :count).by(1)
end
end

@ -39,7 +39,7 @@ describe Version do
version.effective_date = '2012-01-01'
expect(version).not_to be_valid
expect(version.errors).to have(1).error_on(:effective_date)
expect(version.errors.error_on(:effective_date).size).to eq(1)
end
context 'deprecated methods' do

@ -46,13 +46,13 @@ describe WorkPackage do
it "validates, that start-date is before end-date" do
wp = FactoryGirl.build(:work_package, start_date: 1.day.from_now, due_date: 1.day.ago)
expect(wp).to have(1).errors_on(:due_date)
expect(wp.errors_on(:due_date).size).to eq(1)
end
it "validates, that correct formats are properly parsed" do
wp = FactoryGirl.build(:work_package, start_date: "01/01/13", due_date: "31/01/13")
expect(wp).to have(:no).errors_on(:start_date)
expect(wp).to have(:no).errors_on(:due_date)
expect(wp.errors_on(:start_date).size).to eq(:no)
expect(wp.errors_on(:due_date).size).to eq(:no)
end
describe "hierarchical work_package-validations" do
@ -92,7 +92,7 @@ describe WorkPackage do
successor.start_date = "01/01/13"
expect(successor).not_to be_valid
expect(successor).to have(1).errors_on(:start_date)
expect(successor.errors_on(:start_date).size).to eq(1)
end
@ -116,7 +116,7 @@ describe WorkPackage do
wp.fixed_version = non_assignable_version
expect(wp).not_to be_valid
expect(wp).to have(1).errors_on(:fixed_version_id)
expect(wp.errors_on(:fixed_version_id).size).to eq(1)
end
it "validate, that closed or locked versions cannot be assigned" do
@ -128,7 +128,7 @@ describe WorkPackage do
wp.fixed_version = non_assignable_version
expect(wp).not_to be_valid
expect(wp).to have(1).errors_on(:fixed_version_id)
expect(wp.errors_on(:fixed_version_id).size).to eq(1)
end
end
@ -148,14 +148,14 @@ describe WorkPackage do
work_package.type = new_type
expect(work_package).not_to be_valid
expect(work_package).to have(1).errors_on(:type_id)
expect(work_package.errors_on(:type_id).size).to eq(1)
end
it "validate, that the selected type is enabled for the project the wp was moved into" do
work_package.project = new_project
expect(work_package).not_to be_valid
expect(work_package).to have(1).errors_on(:type_id)
expect(work_package.errors_on(:type_id).size).to eq(1)
end
end
@ -186,7 +186,7 @@ describe WorkPackage do
it "should not validate on an inactive priority" do
wp.priority = inactive_priority
expect(wp).not_to be_valid
expect(wp).to have(1).errors_on(:priority_id)
expect(wp.errors_on(:priority_id).size).to eq(1)
end
end

@ -834,12 +834,12 @@ describe WorkPackage do
subject { WorkPackage.with_author(user).length }
context "one work package in active projects" do
it { should eq(1) }
it { is_expected.to eq(1) }
context "and one work package in archived projects" do
before { work_package_in_archived_project }
it { should eq(2) }
it { is_expected.to eq(2) }
end
end
end
@ -1126,7 +1126,7 @@ describe WorkPackage do
"activity_id" => activity.id.to_s,
"comments" => "blubs" } } )
expect(instance).to have(1).time_entries
expect(instance.size).to eq(1)
entry = instance.time_entries.first
@ -1145,7 +1145,7 @@ describe WorkPackage do
"activity_id" => activity.id.to_s,
"comments" => "blubs" } } )
expect(instance).to have(1).time_entries
expect(instance.size).to eq(1)
entry = instance.time_entries.first
@ -1159,7 +1159,7 @@ describe WorkPackage do
instance.update_by!(user, :time_entry => time_attributes)
expect(instance).to have(0).time_entries
expect(instance.size).to eq(0)
end
end
@ -1261,7 +1261,7 @@ describe WorkPackage do
end
it "should have a validation error" do
expect(instance).to have(1).error_on(:due_date)
expect(instance.error_on(:due_date).size).to eq(1)
end
end

@ -72,7 +72,7 @@ RSpec.configure do |config|
DatabaseCleaner.clean_with :truncation
end
config.before(:each) do
config.before(:each) do |example|
if example.metadata[:js]
DatabaseCleaner.strategy = :truncation
else

@ -41,8 +41,8 @@ describe 'api/v3/groups/index.api.rabl' do
describe 'with no groups available' do
let(:groups) { [] }
it { should have_json_path('groups') }
it { should have_json_size(0).at_path('groups') }
it { is_expected.to have_json_path('groups') }
it { is_expected.to have_json_size(0).at_path('groups') }
end
describe 'with 2 groups available' do
@ -50,10 +50,10 @@ describe 'api/v3/groups/index.api.rabl' do
FactoryGirl.build(:group), FactoryGirl.build(:group)
] }
it { should have_json_path('groups') }
it { should have_json_size(2).at_path('groups') }
it { is_expected.to have_json_path('groups') }
it { is_expected.to have_json_size(2).at_path('groups') }
it { should have_json_type(Object).at_path('groups/1') }
it { should have_json_path('groups/1/name') }
it { is_expected.to have_json_type(Object).at_path('groups/1') }
it { is_expected.to have_json_path('groups/1/name') }
end
end

@ -41,8 +41,8 @@ describe 'api/v3/projects/index.api.rabl' do
describe 'with no projects available' do
let(:projects) { [] }
it { should have_json_path('projects') }
it { should have_json_size(0).at_path('projects') }
it { is_expected.to have_json_path('projects') }
it { is_expected.to have_json_size(0).at_path('projects') }
end
describe 'with 2 projects available' do
@ -50,13 +50,13 @@ describe 'api/v3/projects/index.api.rabl' do
FactoryGirl.build(:project), FactoryGirl.build(:project)
] }
it { should have_json_path('projects') }
it { should have_json_size(2).at_path('projects') }
it { is_expected.to have_json_path('projects') }
it { is_expected.to have_json_size(2).at_path('projects') }
it { should have_json_type(Object).at_path('projects/1') }
it { should have_json_path('projects/1/name') }
it { should have_json_path('projects/1/embedded/possible_responsibles') }
it { should have_json_path('projects/1/embedded/possible_assignees') }
it { should have_json_path('projects/1/embedded/types') }
it { is_expected.to have_json_type(Object).at_path('projects/1') }
it { is_expected.to have_json_path('projects/1/name') }
it { is_expected.to have_json_path('projects/1/embedded/possible_responsibles') }
it { is_expected.to have_json_path('projects/1/embedded/possible_assignees') }
it { is_expected.to have_json_path('projects/1/embedded/types') }
end
end

@ -48,13 +48,13 @@ describe 'api/v3/projects/show.api.rabl' do
subject { response.body }
it { should have_json_path('project') }
it { should have_json_path('project/name') }
it { is_expected.to have_json_path('project') }
it { is_expected.to have_json_path('project/name') }
it { should have_json_path('project/embedded/possible_responsibles') }
it { should have_json_path('project/embedded/possible_assignees') }
it { is_expected.to have_json_path('project/embedded/possible_responsibles') }
it { is_expected.to have_json_path('project/embedded/possible_assignees') }
it { should have_json_size(3).at_path('project/embedded/possible_responsibles') }
it { should have_json_size(3).at_path('project/embedded/possible_assignees') }
it { should have_json_size(2).at_path('project/embedded/types') }
it { is_expected.to have_json_size(3).at_path('project/embedded/possible_responsibles') }
it { is_expected.to have_json_size(3).at_path('project/embedded/possible_assignees') }
it { is_expected.to have_json_size(2).at_path('project/embedded/types') }
end

@ -41,8 +41,8 @@ describe 'api/v3/queries/available_columns.api.rabl' do
describe 'with no available columns' do
let(:available_columns) { [] }
it { should have_json_path('available_columns') }
it { should have_json_size(0).at_path('available_columns') }
it { is_expected.to have_json_path('available_columns') }
it { is_expected.to have_json_size(0).at_path('available_columns') }
end
describe 'with 2 available columns' do
@ -78,12 +78,12 @@ describe 'api/v3/queries/available_columns.api.rabl' do
]
}
it { should have_json_path('available_columns') }
it { should have_json_size(2).at_path('available_columns') }
it { is_expected.to have_json_path('available_columns') }
it { is_expected.to have_json_size(2).at_path('available_columns') }
it { should have_json_type(FalseClass).at_path('available_columns/1/custom_field') }
it { should have_json_type(Object).at_path('available_columns/1/meta_data') }
it { should have_json_type(String).at_path('available_columns/1/meta_data/link/model_type') }
it { is_expected.to have_json_type(FalseClass).at_path('available_columns/1/custom_field') }
it { is_expected.to have_json_type(Object).at_path('available_columns/1/meta_data') }
it { is_expected.to have_json_type(String).at_path('available_columns/1/meta_data/link/model_type') }
end
end

@ -47,12 +47,12 @@ describe 'api/v3/queries/grouped.api.rabl' do
[]
}
it { should have_json_path('user_queries') }
it { should have_json_type(Array).at_path('user_queries') }
it { should have_json_size(0).at_path('user_queries') }
it { should have_json_path('queries') }
it { should have_json_type(Array).at_path('queries') }
it { should have_json_size(0).at_path('queries') }
it { is_expected.to have_json_path('user_queries') }
it { is_expected.to have_json_type(Array).at_path('user_queries') }
it { is_expected.to have_json_size(0).at_path('user_queries') }
it { is_expected.to have_json_path('queries') }
it { is_expected.to have_json_type(Array).at_path('queries') }
it { is_expected.to have_json_size(0).at_path('queries') }
end
describe 'with 2 queries and no user queries' do
@ -63,9 +63,9 @@ describe 'api/v3/queries/grouped.api.rabl' do
[]
}
it { should have_json_path('user_queries') }
it { should have_json_type(Array).at_path('user_queries') }
it { should have_json_size(2).at_path('user_queries') }
it { is_expected.to have_json_path('user_queries') }
it { is_expected.to have_json_type(Array).at_path('user_queries') }
it { is_expected.to have_json_size(2).at_path('user_queries') }
end
describe 'with 2 user queries and no queries' do
@ -76,9 +76,9 @@ describe 'api/v3/queries/grouped.api.rabl' do
[["query1", 1], ["query2", 2]]
}
it { should have_json_path('queries') }
it { should have_json_type(Array).at_path('queries') }
it { should have_json_size(2).at_path('queries') }
it { is_expected.to have_json_path('queries') }
it { is_expected.to have_json_type(Array).at_path('queries') }
it { is_expected.to have_json_size(2).at_path('queries') }
end
end

@ -41,8 +41,8 @@ describe 'api/v3/roles/index.api.rabl' do
describe 'with no roles available' do
let(:roles) { [] }
it { should have_json_path('roles') }
it { should have_json_size(0).at_path('roles') }
it { is_expected.to have_json_path('roles') }
it { is_expected.to have_json_size(0).at_path('roles') }
end
describe 'with 2 roles available' do
@ -50,10 +50,10 @@ describe 'api/v3/roles/index.api.rabl' do
FactoryGirl.build(:role), FactoryGirl.build(:role)
] }
it { should have_json_path('roles') }
it { should have_json_size(2).at_path('roles') }
it { is_expected.to have_json_path('roles') }
it { is_expected.to have_json_size(2).at_path('roles') }
it { should have_json_type(Object).at_path('roles/1') }
it { should have_json_path('roles/1/name') }
it { is_expected.to have_json_type(Object).at_path('roles/1') }
it { is_expected.to have_json_path('roles/1/name') }
end
end

@ -41,8 +41,8 @@ describe 'api/v3/versions/index.api.rabl' do
describe 'with no versions available' do
let(:versions) { [] }
it { should have_json_path('versions') }
it { should have_json_size(0).at_path('versions') }
it { is_expected.to have_json_path('versions') }
it { is_expected.to have_json_size(0).at_path('versions') }
end
describe 'with 2 versions available' do
@ -50,10 +50,10 @@ describe 'api/v3/versions/index.api.rabl' do
FactoryGirl.build(:version), FactoryGirl.build(:version)
] }
it { should have_json_path('versions') }
it { should have_json_size(2).at_path('versions') }
it { is_expected.to have_json_path('versions') }
it { is_expected.to have_json_size(2).at_path('versions') }
it { should have_json_type(Object).at_path('versions/1') }
it { should have_json_path('versions/1/name') }
it { is_expected.to have_json_type(Object).at_path('versions/1') }
it { is_expected.to have_json_path('versions/1/name') }
end
end

@ -41,16 +41,16 @@ describe 'api/v3/work_packages/column_data.api.rabl' do
describe 'with no column data' do
let(:columns_data) { [] }
it { should have_json_path('columns_data') }
it { should have_json_size(0).at_path('columns_data') }
it { is_expected.to have_json_path('columns_data') }
it { is_expected.to have_json_size(0).at_path('columns_data') }
end
describe 'with column data' do
let(:columns_data) { [[{ id: 1, name: 'Dairy Queen' }, { id: 2, name: 'Baskin Robbins' }]] }
it { should have_json_path('columns_data') }
it { should have_json_type(Array).at_path('columns_data') }
it { should have_json_type(Array).at_path('columns_data/0') }
it { should have_json_type(Object).at_path('columns_data/0/0') }
it { is_expected.to have_json_path('columns_data') }
it { is_expected.to have_json_type(Array).at_path('columns_data') }
it { is_expected.to have_json_type(Array).at_path('columns_data/0') }
it { is_expected.to have_json_type(Object).at_path('columns_data/0/0') }
end
end

@ -41,17 +41,17 @@ describe 'api/v3/work_packages/column_sums.api.rabl' do
describe 'with no summed columns' do
let(:column_sums) { [] }
it { should have_json_path('column_sums') }
it { should have_json_size(0).at_path('column_sums') }
it { is_expected.to have_json_path('column_sums') }
it { is_expected.to have_json_size(0).at_path('column_sums') }
end
describe 'with 4 summed columns' do
let(:column_sums) { [45, 67, 12.99, 44444444444] }
it { should have_json_path('column_sums') }
it { should have_json_size(4).at_path('column_sums') }
it { is_expected.to have_json_path('column_sums') }
it { is_expected.to have_json_size(4).at_path('column_sums') }
it { should have_json_type(Float).at_path('column_sums/2') }
it { should have_json_type(Integer).at_path('column_sums/3') }
it { is_expected.to have_json_type(Float).at_path('column_sums/2') }
it { is_expected.to have_json_type(Integer).at_path('column_sums/3') }
end
end

@ -49,8 +49,8 @@ describe 'api/v3/work_packages/index.api.rabl' do
let(:column_names) { [] }
let(:custom_field_column_names) { [] }
it { should have_json_path('work_packages') }
it { should have_json_size(0).at_path('work_packages') }
it { is_expected.to have_json_path('work_packages') }
it { is_expected.to have_json_size(0).at_path('work_packages') }
end
describe 'with 3 work packages but no columns' do
@ -62,10 +62,10 @@ describe 'api/v3/work_packages/index.api.rabl' do
let(:column_names) { [] }
let(:custom_field_column_names) { [] }
it { should have_json_path('work_packages') }
it { should have_json_size(3).at_path('work_packages') }
it { is_expected.to have_json_path('work_packages') }
it { is_expected.to have_json_size(3).at_path('work_packages') }
it { should have_json_type(Object).at_path('work_packages/2') }
it { is_expected.to have_json_type(Object).at_path('work_packages/2') }
end
describe 'with 2 work packages and columns' do
@ -76,13 +76,13 @@ describe 'api/v3/work_packages/index.api.rabl' do
let(:column_names) { %w(subject description due_date) }
let(:custom_field_column_names) { [] }
it { should have_json_path('work_packages') }
it { should have_json_size(2).at_path('work_packages') }
it { is_expected.to have_json_path('work_packages') }
it { is_expected.to have_json_size(2).at_path('work_packages') }
it { should have_json_type(Object).at_path('work_packages/1') }
it { should have_json_path('work_packages/1/subject') }
it { should have_json_path('work_packages/1/description') }
it { should have_json_path('work_packages/1/due_date') }
it { is_expected.to have_json_type(Object).at_path('work_packages/1') }
it { is_expected.to have_json_path('work_packages/1/subject') }
it { is_expected.to have_json_path('work_packages/1/description') }
it { is_expected.to have_json_path('work_packages/1/due_date') }
end
describe 'with project column' do
@ -90,8 +90,8 @@ describe 'api/v3/work_packages/index.api.rabl' do
let(:column_names) { %w(subject project) }
let(:custom_field_column_names) { [] }
it { should have_json_path('work_packages/0/project') }
it { should have_json_path('work_packages/0/project/identifier') }
it { is_expected.to have_json_path('work_packages/0/project') }
it { is_expected.to have_json_path('work_packages/0/project/identifier') }
end
context 'with actions, links based on permissions' do
@ -100,13 +100,13 @@ describe 'api/v3/work_packages/index.api.rabl' do
let(:custom_field_column_names) { [] }
context 'with no actions' do
it { should have_json_path('work_packages/0/_actions') }
it { should have_json_type(Array).at_path('work_packages/0/_actions') }
it { should have_json_size(0).at_path('work_packages/0/_actions') }
it { is_expected.to have_json_path('work_packages/0/_actions') }
it { is_expected.to have_json_type(Array).at_path('work_packages/0/_actions') }
it { is_expected.to have_json_size(0).at_path('work_packages/0/_actions') }
it { should have_json_path('work_packages/0/_links') }
it { should have_json_type(Hash).at_path('work_packages/0/_links') }
it { should have_json_size(0).at_path('work_packages/0/_links') }
it { is_expected.to have_json_path('work_packages/0/_links') }
it { is_expected.to have_json_type(Hash).at_path('work_packages/0/_links') }
it { is_expected.to have_json_size(0).at_path('work_packages/0/_links') }
end
context 'with some actions' do
@ -120,13 +120,13 @@ describe 'api/v3/work_packages/index.api.rabl' do
}
}
it { should have_json_path('work_packages/0/_actions') }
it { should have_json_type(Array).at_path('work_packages/0/_actions') }
it { should have_json_size(2).at_path('work_packages/0/_actions') }
it { is_expected.to have_json_path('work_packages/0/_actions') }
it { is_expected.to have_json_type(Array).at_path('work_packages/0/_actions') }
it { is_expected.to have_json_size(2).at_path('work_packages/0/_actions') }
it { should have_json_path('work_packages/0/_links') }
it { should have_json_type(Hash).at_path('work_packages/0/_links') }
it { should have_json_size(2).at_path('work_packages/0/_links') }
it { is_expected.to have_json_path('work_packages/0/_links') }
it { is_expected.to have_json_type(Hash).at_path('work_packages/0/_links') }
it { is_expected.to have_json_size(2).at_path('work_packages/0/_links') }
specify {
expect(parse_json(subject, 'work_packages/0/_links/log_time')).to match(%r{/work_packages/(\d+)/time_entries/new})
@ -144,10 +144,10 @@ describe 'api/v3/work_packages/index.api.rabl' do
}
}
it { should have_json_path('work_packages/0/_actions') }
it { should have_json_type(Array).at_path('work_packages/0/_actions') }
it { should have_json_size(7).at_path('work_packages/0/_actions') }
it { should have_json_path('work_packages/0/_actions/' ) }
it { is_expected.to have_json_path('work_packages/0/_actions') }
it { is_expected.to have_json_type(Array).at_path('work_packages/0/_actions') }
it { is_expected.to have_json_size(7).at_path('work_packages/0/_actions') }
it { is_expected.to have_json_path('work_packages/0/_actions/' ) }
specify {
expect(parse_json(subject, 'work_packages/0/_actions/5')).to match(%r{copy})
@ -156,11 +156,11 @@ describe 'api/v3/work_packages/index.api.rabl' do
expect(parse_json(subject, 'work_packages/0/_actions/6')).to match(%r{duplicate})
}
it { should have_json_path('work_packages/0/_links') }
it { should have_json_type(Hash).at_path('work_packages/0/_links') }
it { is_expected.to have_json_path('work_packages/0/_links') }
it { is_expected.to have_json_type(Hash).at_path('work_packages/0/_links') }
# FIXME: check missing permission
it { should have_json_size(6).at_path('work_packages/0/_links') }
it { is_expected.to have_json_size(6).at_path('work_packages/0/_links') }
specify {
expect(parse_json(subject, 'work_packages/0/_links/copy')).to match(%r{/work_packages/move/new\?copy\=true})
@ -174,7 +174,7 @@ describe 'api/v3/work_packages/index.api.rabl' do
expect(parse_json(subject, 'work_packages/0/_links/delete')).to match(%r{/work_packages/bulk\?ids(.+)method\=delete})
}
it { should have_json_size(4).at_path('_bulk_links') }
it { is_expected.to have_json_size(4).at_path('_bulk_links') }
specify {
expect(parse_json(subject, '_bulk_links/edit')).to match(%r{/work_packages/bulk/edit})

@ -7,16 +7,16 @@ describe "layouts/base" do
let!(:anonymous) { FactoryGirl.create(:anonymous) }
before do
view.stub(:current_menu_item).and_return("overview")
view.stub(:default_breadcrumb)
controller.stub(:default_search_scope)
allow(view).to receive(:current_menu_item).and_return("overview")
allow(view).to receive(:default_breadcrumb)
allow(controller).to receive(:default_search_scope)
end
describe "projects menu visibility" do
context "when the user is not logged in" do
before do
User.stub(:current).and_return anonymous
view.stub(:current_user).and_return anonymous
allow(User).to receive(:current).and_return anonymous
allow(view).to receive(:current_user).and_return anonymous
render
end
@ -27,8 +27,8 @@ describe "layouts/base" do
context "when the user is logged in" do
before do
User.stub(:current).and_return user
view.stub(:current_user).and_return user
allow(User).to receive(:current).and_return user
allow(view).to receive(:current_user).and_return user
render
end

Loading…
Cancel
Save