Skip to content

Commit

Permalink
Move spec/models to spec/unit and add spec to rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
gmassanek committed Jun 29, 2015
1 parent 20b48e5 commit 3b72bc6
Show file tree
Hide file tree
Showing 27 changed files with 74 additions and 147 deletions.
1 change: 0 additions & 1 deletion .rubocop.yml
Expand Up @@ -5,7 +5,6 @@ AllCops:
- db/schema.rb
- db/migrate/**/*
- agile-direction-ui/**/*
- spec/**/*.rb
- vendor/bundle/**/*
- fantasy-celebrity-front-end/**/*

Expand Down
6 changes: 3 additions & 3 deletions 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" }) }

Expand All @@ -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
6 changes: 3 additions & 3 deletions 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" }) }

Expand All @@ -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
36 changes: 18 additions & 18 deletions 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
4 changes: 0 additions & 4 deletions spec/models/league_player_spec.rb

This file was deleted.

4 changes: 0 additions & 4 deletions spec/models/league_point_category_spec.rb

This file was deleted.

4 changes: 0 additions & 4 deletions spec/models/league_position_spec.rb

This file was deleted.

4 changes: 0 additions & 4 deletions spec/models/league_template_spec.rb

This file was deleted.

4 changes: 0 additions & 4 deletions spec/models/player_spec.rb

This file was deleted.

4 changes: 0 additions & 4 deletions spec/models/point_category_spec.rb

This file was deleted.

4 changes: 0 additions & 4 deletions spec/models/position_spec.rb

This file was deleted.

4 changes: 0 additions & 4 deletions spec/models/roster_slot_spec.rb

This file was deleted.

4 changes: 0 additions & 4 deletions spec/models/team_spec.rb

This file was deleted.

9 changes: 4 additions & 5 deletions 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
Expand Down
76 changes: 0 additions & 76 deletions 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
Expand Down
4 changes: 4 additions & 0 deletions spec/unit/league_player_spec.rb
@@ -0,0 +1,4 @@
require "rails_helper"

RSpec.describe LeaguePlayer, { type: :model } do
end
4 changes: 4 additions & 0 deletions spec/unit/league_point_category_spec.rb
@@ -0,0 +1,4 @@
require "rails_helper"

RSpec.describe LeaguePointCategory, { type: :model } do
end
4 changes: 4 additions & 0 deletions spec/unit/league_position_spec.rb
@@ -0,0 +1,4 @@
require "rails_helper"

RSpec.describe LeaguePosition, { type: :model } do
end
8 changes: 4 additions & 4 deletions spec/models/league_spec.rb → 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" }) }

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions spec/unit/league_template_spec.rb
@@ -0,0 +1,4 @@
require "rails_helper"

RSpec.describe LeagueTemplate, { type: :model } do
end
4 changes: 4 additions & 0 deletions spec/unit/player_spec.rb
@@ -0,0 +1,4 @@
require "rails_helper"

RSpec.describe Player, { type: :model } do
end
4 changes: 4 additions & 0 deletions spec/unit/point_category_spec.rb
@@ -0,0 +1,4 @@
require "rails_helper"

RSpec.describe PointCategory, { type: :model } do
end
4 changes: 4 additions & 0 deletions spec/unit/position_spec.rb
@@ -0,0 +1,4 @@
require "rails_helper"

RSpec.describe Position, { type: :model } do
end
5 changes: 5 additions & 0 deletions spec/unit/roster_manager_spec.rb
@@ -0,0 +1,5 @@
require "rails_helper"
require "roster_manager"

RSpec.describe Team, { type: :model } do
end
4 changes: 4 additions & 0 deletions spec/unit/roster_slot_spec.rb
@@ -0,0 +1,4 @@
require "rails_helper"

RSpec.describe RosterSlot, { type: :model } do
end
4 changes: 4 additions & 0 deletions spec/unit/team_spec.rb
@@ -0,0 +1,4 @@
require "rails_helper"

RSpec.describe Team, { type: :model } do
end

0 comments on commit 3b72bc6

Please sign in to comment.