From 3b72bc68b3b51736c86770497ab4c6e1e33d472a Mon Sep 17 00:00:00 2001 From: Geoff Massanek Date: Mon, 29 Jun 2015 14:55:21 -0500 Subject: [PATCH] Move spec/models to spec/unit and add spec to rubocop --- .rubocop.yml | 1 - fantasy-celebrity-front-end | 2 +- .../api/v1/leagues/point_categories_spec.rb | 6 +- .../api/v1/leagues/positions_spec.rb | 6 +- spec/acceptance/api/v1/teams_spec.rb | 36 ++++----- spec/models/league_player_spec.rb | 4 - spec/models/league_point_category_spec.rb | 4 - spec/models/league_position_spec.rb | 4 - spec/models/league_template_spec.rb | 4 - spec/models/player_spec.rb | 4 - spec/models/point_category_spec.rb | 4 - spec/models/position_spec.rb | 4 - spec/models/roster_slot_spec.rb | 4 - spec/models/team_spec.rb | 4 - spec/rails_helper.rb | 9 +-- spec/spec_helper.rb | 76 ------------------- spec/unit/league_player_spec.rb | 4 + spec/unit/league_point_category_spec.rb | 4 + spec/unit/league_position_spec.rb | 4 + spec/{models => unit}/league_spec.rb | 8 +- spec/unit/league_template_spec.rb | 4 + spec/unit/player_spec.rb | 4 + spec/unit/point_category_spec.rb | 4 + spec/unit/position_spec.rb | 4 + spec/unit/roster_manager_spec.rb | 5 ++ spec/unit/roster_slot_spec.rb | 4 + spec/unit/team_spec.rb | 4 + 27 files changed, 74 insertions(+), 147 deletions(-) delete mode 100644 spec/models/league_player_spec.rb delete mode 100644 spec/models/league_point_category_spec.rb delete mode 100644 spec/models/league_position_spec.rb delete mode 100644 spec/models/league_template_spec.rb delete mode 100644 spec/models/player_spec.rb delete mode 100644 spec/models/point_category_spec.rb delete mode 100644 spec/models/position_spec.rb delete mode 100644 spec/models/roster_slot_spec.rb delete mode 100644 spec/models/team_spec.rb create mode 100644 spec/unit/league_player_spec.rb create mode 100644 spec/unit/league_point_category_spec.rb create mode 100644 spec/unit/league_position_spec.rb rename spec/{models => unit}/league_spec.rb (96%) create mode 100644 spec/unit/league_template_spec.rb create mode 100644 spec/unit/player_spec.rb create mode 100644 spec/unit/point_category_spec.rb create mode 100644 spec/unit/position_spec.rb create mode 100644 spec/unit/roster_manager_spec.rb create mode 100644 spec/unit/roster_slot_spec.rb create mode 100644 spec/unit/team_spec.rb diff --git a/.rubocop.yml b/.rubocop.yml index 0809c33..48cb2ae 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,7 +5,6 @@ AllCops: - db/schema.rb - db/migrate/**/* - agile-direction-ui/**/* - - spec/**/*.rb - vendor/bundle/**/* - fantasy-celebrity-front-end/**/* diff --git a/fantasy-celebrity-front-end b/fantasy-celebrity-front-end index 96c91b8..514d5b3 160000 --- a/fantasy-celebrity-front-end +++ b/fantasy-celebrity-front-end @@ -1 +1 @@ -Subproject commit 96c91b898a8b825e908b31255bb26062a22a80d4 +Subproject commit 514d5b305362572a5571eb755c49272d2c1cac45 diff --git a/spec/acceptance/api/v1/leagues/point_categories_spec.rb b/spec/acceptance/api/v1/leagues/point_categories_spec.rb index 21d6c15..47047ae 100644 --- a/spec/acceptance/api/v1/leagues/point_categories_spec.rb +++ b/spec/acceptance/api/v1/leagues/point_categories_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -RSpec.describe "League Point Categories", :type => :request do +RSpec.describe "League Point Categories", { type: :request } do describe "INDEX" do let(:league_template) { LeagueTemplate.find_by!({ title: "Bad Celebrity" }) } @@ -10,7 +10,7 @@ get "/api/v1/leagues/#{league.id}/point_categories" expect(response).to be_success - expect(json_body['pointCategories'].size).to eq(league_template.point_categories.size) + expect(json_body["pointCategories"].size).to eq(league_template.point_categories.size) end end end diff --git a/spec/acceptance/api/v1/leagues/positions_spec.rb b/spec/acceptance/api/v1/leagues/positions_spec.rb index 468ee81..04d0f84 100644 --- a/spec/acceptance/api/v1/leagues/positions_spec.rb +++ b/spec/acceptance/api/v1/leagues/positions_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -RSpec.describe "League Positions", :type => :request do +RSpec.describe "League Positions", { type: :request } do describe "INDEX" do let(:league_template) { LeagueTemplate.find_by!({ title: "Bad Celebrity" }) } @@ -10,7 +10,7 @@ get "/api/v1/leagues/#{league.id}/positions" expect(response).to be_success - expect(json_body['positions'].size).to eq(league_template.positions.size) + expect(json_body["positions"].size).to eq(league_template.positions.size) end end end diff --git a/spec/acceptance/api/v1/teams_spec.rb b/spec/acceptance/api/v1/teams_spec.rb index 4e23921..d3f504d 100644 --- a/spec/acceptance/api/v1/teams_spec.rb +++ b/spec/acceptance/api/v1/teams_spec.rb @@ -1,43 +1,43 @@ -require 'rails_helper' +require "rails_helper" -RSpec.describe "Teams", :type => :request do +RSpec.describe "Teams", { type: :request } do describe "SHOW" do - #let(:league_template) { LeagueTemplate.find_by!({ title: "Bad Celebrity" }) } - #let(:league) { League.find_by!({ title: "Sample league" }) } + # let(:league_template) { LeagueTemplate.find_by!({ title: "Bad Celebrity" }) } + # let(:league) { League.find_by!({ title: "Sample league" }) } let(:team) { Team.find_by!({ title: "New Team" }) } it "includes base team attributes" do get "/api/v1/teams/#{team.id}" expect(response).to be_success - expect(json_body['team']['id']).to eq(team.id) - expect(json_body['team']['title']).to eq(team.title) - expect(json_body['team']['roster_slot_ids'].size).to eq(team.roster_slots.size) + expect(json_body["team"]["id"]).to eq(team.id) + expect(json_body["team"]["title"]).to eq(team.title) + expect(json_body["team"]["roster_slot_ids"].size).to eq(team.roster_slots.size) end it "includes roster_slots" do get "/api/v1/teams/#{team.id}" expect(response).to be_success - expect(json_body['roster_slots'].size).to eq(team.roster_slots.size) - expect(json_body['roster_slots'][0]['id']).to be - expect(json_body['roster_slots'][0]['league_player_id']).to be - expect(json_body['roster_slots'][0]['league_position_id']).to be + expect(json_body["roster_slots"].size).to eq(team.roster_slots.size) + expect(json_body["roster_slots"][0]["id"]).to be + expect(json_body["roster_slots"][0]["league_player_id"]).to be + expect(json_body["roster_slots"][0]["league_position_id"]).to be end it "includes league_players" do get "/api/v1/teams/#{team.id}" expect(response).to be_success - expect(json_body['league_players'].size).to eq(team.roster_slots.size) - expect(json_body['league_players'][0]['id']).to be - expect(json_body['league_players'][0]['first_name']).to be - expect(json_body['league_players'][0]['last_name']).to be + expect(json_body["league_players"].size).to eq(team.roster_slots.size) + expect(json_body["league_players"][0]["id"]).to be + expect(json_body["league_players"][0]["first_name"]).to be + expect(json_body["league_players"][0]["last_name"]).to be end it "includes league_positions" do get "/api/v1/teams/#{team.id}" expect(response).to be_success - expect(json_body['league_positions'].size).to eq(team.roster_slots.map(&:league_position_id).uniq.size) - expect(json_body['league_positions'][0]['id']).to be - expect(json_body['league_positions'][0]['title']).to be + expect(json_body["league_positions"].size).to eq(team.roster_slots.map(&:league_position_id).uniq.size) + expect(json_body["league_positions"][0]["id"]).to be + expect(json_body["league_positions"][0]["title"]).to be end end end diff --git a/spec/models/league_player_spec.rb b/spec/models/league_player_spec.rb deleted file mode 100644 index 51e1535..0000000 --- a/spec/models/league_player_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -RSpec.describe LeaguePlayer, :type => :model do -end diff --git a/spec/models/league_point_category_spec.rb b/spec/models/league_point_category_spec.rb deleted file mode 100644 index 1a4d9d9..0000000 --- a/spec/models/league_point_category_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -RSpec.describe LeaguePointCategory, :type => :model do -end diff --git a/spec/models/league_position_spec.rb b/spec/models/league_position_spec.rb deleted file mode 100644 index b822397..0000000 --- a/spec/models/league_position_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -RSpec.describe LeaguePosition, :type => :model do -end diff --git a/spec/models/league_template_spec.rb b/spec/models/league_template_spec.rb deleted file mode 100644 index 697431d..0000000 --- a/spec/models/league_template_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -RSpec.describe LeagueTemplate, :type => :model do -end diff --git a/spec/models/player_spec.rb b/spec/models/player_spec.rb deleted file mode 100644 index b72c5a5..0000000 --- a/spec/models/player_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -RSpec.describe Player, :type => :model do -end diff --git a/spec/models/point_category_spec.rb b/spec/models/point_category_spec.rb deleted file mode 100644 index cd32dfb..0000000 --- a/spec/models/point_category_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -RSpec.describe PointCategory, :type => :model do -end diff --git a/spec/models/position_spec.rb b/spec/models/position_spec.rb deleted file mode 100644 index 0c49def..0000000 --- a/spec/models/position_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -RSpec.describe Position, :type => :model do -end diff --git a/spec/models/roster_slot_spec.rb b/spec/models/roster_slot_spec.rb deleted file mode 100644 index b0eec63..0000000 --- a/spec/models/roster_slot_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -RSpec.describe RosterSlot, :type => :model do -end diff --git a/spec/models/team_spec.rb b/spec/models/team_spec.rb deleted file mode 100644 index dd7438c..0000000 --- a/spec/models/team_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -RSpec.describe Team, :type => :model do -end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 037379b..b1ec254 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,14 +1,13 @@ -# This file is copied to spec/ when you run 'rails generate rspec:install' -ENV["RAILS_ENV"] ||= 'test' -require 'spec_helper' +ENV["RAILS_ENV"] ||= "test" +require "spec_helper" require File.expand_path("../../config/environment", __FILE__) -require 'rspec/rails' +require "rspec/rails" require Rails.root.join("db/seeds") ActiveRecord::Migration.maintain_test_schema! RSpec.configure do |config| - # If you're not using ActiveRecord, or you'd prefer not to run each of your + # If you"re not using ActiveRecord, or you"d prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. config.use_transactional_fixtures = true diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3c37e71..5d232ba 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,87 +1,11 @@ -# This file was generated by the `rails generate rspec:install` command. Conventionally, all -# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause this -# file to always be loaded, without a need to explicitly require it in any files. -# -# Given that it is always loaded, you are encouraged to keep this file as -# light-weight as possible. Requiring heavyweight dependencies from this file -# will add to the boot time of your test suite on EVERY test run, even for an -# individual file that may not need all of that loaded. Instead, consider making -# a separate helper file that requires the additional dependencies and performs -# the additional setup, and require it from the spec files that actually need it. -# -# The `.rspec` file also contains a few flags that are not defaults but that -# users commonly want. -# -# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| - # rspec-expectations config goes here. You can use an alternate - # assertion/expectation library such as wrong or the stdlib/minitest - # assertions if you prefer. config.expect_with :rspec do |expectations| - # This option will default to `true` in RSpec 4. It makes the `description` - # and `failure_message` of custom matchers include text for helper methods - # defined using `chain`, e.g.: - # be_bigger_than(2).and_smaller_than(4).description - # # => "be bigger than 2 and smaller than 4" - # ...rather than: - # # => "be bigger than 2" expectations.include_chain_clauses_in_custom_matcher_descriptions = true end - # rspec-mocks config goes here. You can use an alternate test double - # library (such as bogus or mocha) by changing the `mock_with` option here. config.mock_with :rspec do |mocks| - # Prevents you from mocking or stubbing a method that does not exist on - # a real object. This is generally recommended, and will default to - # `true` in RSpec 4. mocks.verify_partial_doubles = true end - -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # These two settings work together to allow you to limit a spec run - # to individual examples or groups you care about by tagging them with - # `:focus` metadata. When nothing is tagged with `:focus`, all examples - # get run. - config.filter_run :focus - config.run_all_when_everything_filtered = true - - # Limits the available syntax to the non-monkey patched syntax that is recommended. - # For more details, see: - # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax - # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching - config.disable_monkey_patching! - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = 'doc' - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end end def json_body diff --git a/spec/unit/league_player_spec.rb b/spec/unit/league_player_spec.rb new file mode 100644 index 0000000..1e6cc1a --- /dev/null +++ b/spec/unit/league_player_spec.rb @@ -0,0 +1,4 @@ +require "rails_helper" + +RSpec.describe LeaguePlayer, { type: :model } do +end diff --git a/spec/unit/league_point_category_spec.rb b/spec/unit/league_point_category_spec.rb new file mode 100644 index 0000000..677a3dc --- /dev/null +++ b/spec/unit/league_point_category_spec.rb @@ -0,0 +1,4 @@ +require "rails_helper" + +RSpec.describe LeaguePointCategory, { type: :model } do +end diff --git a/spec/unit/league_position_spec.rb b/spec/unit/league_position_spec.rb new file mode 100644 index 0000000..104f153 --- /dev/null +++ b/spec/unit/league_position_spec.rb @@ -0,0 +1,4 @@ +require "rails_helper" + +RSpec.describe LeaguePosition, { type: :model } do +end diff --git a/spec/models/league_spec.rb b/spec/unit/league_spec.rb similarity index 96% rename from spec/models/league_spec.rb rename to spec/unit/league_spec.rb index ec6b201..c826229 100644 --- a/spec/models/league_spec.rb +++ b/spec/unit/league_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -RSpec.describe League, :type => :model do +RSpec.describe League, { type: :model } do describe "create_point_categories_from_league_template" do let(:league_template) { LeagueTemplate.find_by!({ title: "Bad Celebrity" }) } @@ -29,7 +29,7 @@ it "does not clobber point overrides" do league = League.create!({ league_template: league_template }) league.create_point_categories_from_league_template! - league.point_categories[0].update(value: 100) + league.point_categories[0].update({ value: 100 }) expect(league.point_categories[0].value).to eq(100) end @@ -70,7 +70,7 @@ it "does not clobber point overrides" do league = League.create!({ league_template: league_template }) league.create_positions_from_league_template! - league.positions[0].update(count: 10) + league.positions[0].update({ count: 10 }) expect(league.positions[0].count).to eq(10) end diff --git a/spec/unit/league_template_spec.rb b/spec/unit/league_template_spec.rb new file mode 100644 index 0000000..e3095f6 --- /dev/null +++ b/spec/unit/league_template_spec.rb @@ -0,0 +1,4 @@ +require "rails_helper" + +RSpec.describe LeagueTemplate, { type: :model } do +end diff --git a/spec/unit/player_spec.rb b/spec/unit/player_spec.rb new file mode 100644 index 0000000..fdb99c0 --- /dev/null +++ b/spec/unit/player_spec.rb @@ -0,0 +1,4 @@ +require "rails_helper" + +RSpec.describe Player, { type: :model } do +end diff --git a/spec/unit/point_category_spec.rb b/spec/unit/point_category_spec.rb new file mode 100644 index 0000000..e58786c --- /dev/null +++ b/spec/unit/point_category_spec.rb @@ -0,0 +1,4 @@ +require "rails_helper" + +RSpec.describe PointCategory, { type: :model } do +end diff --git a/spec/unit/position_spec.rb b/spec/unit/position_spec.rb new file mode 100644 index 0000000..3a0abb4 --- /dev/null +++ b/spec/unit/position_spec.rb @@ -0,0 +1,4 @@ +require "rails_helper" + +RSpec.describe Position, { type: :model } do +end diff --git a/spec/unit/roster_manager_spec.rb b/spec/unit/roster_manager_spec.rb new file mode 100644 index 0000000..1302458 --- /dev/null +++ b/spec/unit/roster_manager_spec.rb @@ -0,0 +1,5 @@ +require "rails_helper" +require "roster_manager" + +RSpec.describe Team, { type: :model } do +end diff --git a/spec/unit/roster_slot_spec.rb b/spec/unit/roster_slot_spec.rb new file mode 100644 index 0000000..379fe5b --- /dev/null +++ b/spec/unit/roster_slot_spec.rb @@ -0,0 +1,4 @@ +require "rails_helper" + +RSpec.describe RosterSlot, { type: :model } do +end diff --git a/spec/unit/team_spec.rb b/spec/unit/team_spec.rb new file mode 100644 index 0000000..21ce528 --- /dev/null +++ b/spec/unit/team_spec.rb @@ -0,0 +1,4 @@ +require "rails_helper" + +RSpec.describe Team, { type: :model } do +end