style check

This commit is contained in:
Tanguy PATTE 2015-08-20 17:30:17 +02:00
parent a7e6931303
commit d557cee249
24 changed files with 67 additions and 78 deletions

View file

@ -5,7 +5,7 @@ describe EntrepriseDecorator do
let(:raison_sociale) { 'GRTGaz' }
let(:nom) { 'mon nom' }
let(:prenom) { 'mon prenom' }
let(:entreprise_params) {
let(:entreprise_params) do
{
capital_social: 123_000,
code_effectif_entreprise: code_effectif,
@ -14,11 +14,11 @@ describe EntrepriseDecorator do
prenom: prenom
}
}
end
let(:entreprise) { create(:entreprise, entreprise_params) }
subject { entreprise.decorate }
describe '#raison_sociale_or_name' do
subject { super().raison_sociale_or_name}
subject { super().raison_sociale_or_name }
context 'when raison_sociale exist' do
let(:raison_sociale) { 'ma super raison_sociale' }
it 'display raison_sociale' do
@ -56,4 +56,4 @@ describe EntrepriseDecorator do
expect(subject.pretty_date_creation).to eq('05-11-2001')
end
end
end
end

View file

@ -1,5 +1,4 @@
FactoryGirl.define do
factory :cerfa do
end
end
end

View file

@ -1,5 +1,4 @@
FactoryGirl.define do
factory :commentaire do
end
end
end

View file

@ -11,4 +11,4 @@ FactoryGirl.define do
end
end
end
end
end

View file

@ -11,4 +11,4 @@ FactoryGirl.define do
code_effectif_entreprise '51'
date_creation 1_004_914_800
end
end
end

View file

@ -13,4 +13,4 @@ FactoryGirl.define do
localite 'BOIS COLOMBES'
code_insee_localite '92009'
end
end
end

View file

@ -1,5 +1,4 @@
FactoryGirl.define do
factory :piece_jointe do
end
end
end

View file

@ -1,5 +1,4 @@
FactoryGirl.define do
factory :type_piece_jointe do
end
end
end

View file

@ -1,12 +1,11 @@
require 'spec_helper'
describe SIADE::API do
describe '.entreprise' do
subject { SIADE::API.entreprise(siren) }
subject { described_class.entreprise(siren) }
before do
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}").
to_return(:status => status, :body => body)
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
.to_return(status: status, body: body)
end
context 'when siren does not exist' do
let(:siren) { '111111111' }
@ -14,7 +13,7 @@ describe SIADE::API do
let(:body) { '' }
it 'raises RestClient::ResourceNotFound' do
expect{ subject }.to raise_error(RestClient::ResourceNotFound)
expect { subject }.to raise_error(RestClient::ResourceNotFound)
end
end
context 'when siret exist' do
@ -29,10 +28,10 @@ describe SIADE::API do
end
describe '.etablissement' do
subject { SIADE::API.etablissement(siret) }
subject { described_class.etablissement(siret) }
before do
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}").
to_return(:status => status, :body => body)
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
.to_return(status: status, body: body)
end
context 'when siret does not exist' do
@ -41,7 +40,7 @@ describe SIADE::API do
let(:body) { '' }
it 'raises RestClient::ResourceNotFound' do
expect{ subject }.to raise_error(RestClient::ResourceNotFound)
expect { subject }.to raise_error(RestClient::ResourceNotFound)
end
end
@ -55,4 +54,4 @@ describe SIADE::API do
end
end
end
end
end

View file

@ -1,11 +1,11 @@
require 'spec_helper'
describe SIADE::EntrepriseAdapter do
subject { SIADE::EntrepriseAdapter.new('418166096').to_params }
subject { described_class.new('418166096').to_params }
before do
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/418166096?token=#{SIADETOKEN}")
.to_return(body: File.read('spec/support/files/entreprise.json', status: 200))
.to_return(body: File.read('spec/support/files/entreprise.json', status: 200))
end
it '#to_params class est une Hash ?' do
@ -18,7 +18,7 @@ describe SIADE::EntrepriseAdapter do
end
it 'L\'entreprise contient bien un capital_social' do
expect(subject[:capital_social]).to eq(372795)
expect(subject[:capital_social]).to eq(372_795)
end
it 'L\'entreprise contient bien un numero_tva_intracommunautaire' do
@ -50,7 +50,7 @@ describe SIADE::EntrepriseAdapter do
end
it 'L\'entreprise contient bien une date_creation' do
expect(subject[:date_creation]).to eq(891381600)
expect(subject[:date_creation]).to eq(891_381_600)
end
it 'L\'entreprise contient bien un nom' do
@ -61,4 +61,4 @@ describe SIADE::EntrepriseAdapter do
expect(subject[:prenom]).to eq('test_prenom')
end
end
end
end

View file

@ -1,14 +1,13 @@
require 'spec_helper'
describe SIADE::EtablissementAdapter do
context 'SIRET valide' do
let(:siret){41816609600051}
subject { SIADE::EtablissementAdapter.new(siret).to_params }
let(:siret) { 41_816_609_600_051 }
subject { described_class.new(siret).to_params }
before do
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
.to_return(body: File.read('spec/support/files/etablissement.json', status: 200))
.to_return(body: File.read('spec/support/files/etablissement.json', status: 200))
end
it '#to_params class est une Hash ?' do
@ -16,7 +15,6 @@ describe SIADE::EtablissementAdapter do
end
context 'Attributs Etablissements' do
it 'L\'entreprise contient bien un siret' do
expect(subject[:siret]).to eq('41816609600051')
end
@ -71,16 +69,16 @@ describe SIADE::EtablissementAdapter do
end
context 'when siret is not found' do
let(:bad_siret){ 11111111111111 }
subject { SIADE::EtablissementAdapter.new(bad_siret).to_params }
let(:bad_siret) { 11_111_111_111_111 }
subject { described_class.new(bad_siret).to_params }
before do
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{bad_siret}?token=#{SIADETOKEN}")
.to_return(body: 'Fake body', status: 404)
.to_return(body: 'Fake body', status: 404)
end
it 'raises exception RestClient::ResourceNotFound' do
expect{subject}.to raise_error(RestClient::ResourceNotFound)
expect { subject }.to raise_error(RestClient::ResourceNotFound)
end
end
end
end

View file

@ -2,7 +2,7 @@ require 'spec_helper'
describe Cerfa do
describe 'database columns' do
it { is_expected.to have_db_column(:content)}
it { is_expected.to have_db_column(:content) }
end
describe 'associations' do
@ -10,7 +10,7 @@ describe Cerfa do
end
describe 'empty?' do
subject { create(:cerfa, content: content)}
subject { create(:cerfa, content: content) }
context 'when content exist' do
let(:content) { File.open('./spec/support/files/piece_jointe_388.pdf') }
it { expect(subject).not_to be_empty }
@ -20,4 +20,4 @@ describe Cerfa do
it { expect(subject).to be_empty }
end
end
end
end

View file

@ -6,4 +6,4 @@ describe Commentaire do
it { is_expected.to have_db_column(:created_at) }
it { is_expected.to have_db_column(:updated_at) }
it { is_expected.to belong_to(:dossier) }
end
end

View file

@ -1,7 +1,6 @@
require 'spec_helper'
describe Dossier do
describe 'database columns' do
it { is_expected.to have_db_column(:description) }
it { is_expected.to have_db_column(:autorisation_donnees) }
@ -26,7 +25,7 @@ describe Dossier do
it { is_expected.to have_one(:entreprise) }
end
describe "delegation" do
describe 'delegation' do
it { is_expected.to delegate_method(:siren).to(:entreprise) }
it { is_expected.to delegate_method(:siret).to(:etablissement) }
it { is_expected.to delegate_method(:types_piece_jointe).to(:formulaire) }
@ -49,11 +48,11 @@ describe Dossier do
describe 'creation' do
it 'create default cerfa' do
expect{Dossier.create}.to change{ Cerfa.count }.by(1)
expect { described_class.create }.to change { Cerfa.count }.by(1)
end
it 'link cerfa to dossier' do
dossier = Dossier.create
dossier = described_class.create
expect(dossier.cerfa).to eq(Cerfa.last)
end
end
@ -81,4 +80,4 @@ describe Dossier do
end
end
end
end
end

View file

@ -20,4 +20,4 @@ describe Entreprise do
it { is_expected.to belong_to(:dossier) }
it { is_expected.to have_one(:etablissement) }
end
end
end

View file

@ -13,9 +13,9 @@ describe EvenementVie do
end
describe '.for_admi_facile' do
let(:evenement_for_admi_facile) { EvenementVie.where(use_admi_facile: true).first }
let(:evenement_not_for_admi_facile) { EvenementVie.where(use_admi_facile: false).first }
subject { EvenementVie.for_admi_facile }
let(:evenement_for_admi_facile) { described_class.where(use_admi_facile: true).first }
let(:evenement_not_for_admi_facile) { described_class.where(use_admi_facile: false).first }
subject { described_class.for_admi_facile }
it 'returns elements where use_admi_facile is true' do
expect(subject).to include(evenement_for_admi_facile)
end
@ -23,4 +23,4 @@ describe EvenementVie do
expect(subject).not_to include(evenement_not_for_admi_facile)
end
end
end
end

View file

@ -26,8 +26,8 @@ describe Formulaire do
describe '.for_admi_facile' do
it 'retruns Formulaire where use_admi_facile is true' do
expect(Formulaire.for_admi_facile.size).to eq(Formulaire.where(use_admi_facile: true).count)
expect(Formulaire.for_admi_facile).to include(Formulaire.where(use_admi_facile: true).first)
expect(described_class.for_admi_facile.size).to eq(described_class.where(use_admi_facile: true).count)
expect(described_class.for_admi_facile).to include(described_class.where(use_admi_facile: true).first)
end
end
end
end

View file

@ -27,4 +27,4 @@ describe PieceJointe do
it { is_expected.to be_falsey }
end
end
end
end

View file

@ -19,4 +19,4 @@ describe TypePieceJointe do
it { is_expected.to have_many(:pieces_jointes) }
it { is_expected.to belong_to(:formulaire) }
end
end
end

View file

@ -17,9 +17,9 @@
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
ENV["RAILS_ENV"] ||= 'test'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
require 'database_cleaner'
@ -31,26 +31,23 @@ require 'factory_girl'
require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, {js_errors:true, port:44678+ENV['TEST_ENV_NUMBER'].to_i, phantomjs_options:['--proxy-type=none'], timeout:180})
Capybara::Poltergeist::Driver.new(app, js_errors: true, port: 44_678 + ENV['TEST_ENV_NUMBER'].to_i, phantomjs_options: ['--proxy-type=none'], timeout: 180)
end
Capybara.default_wait_time = 1
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
Dir[Rails.root.join("spec/factories/**/*.rb")].each { |f| require f }
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
Dir[Rails.root.join('spec/factories/**/*.rb')].each { |f| require f }
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
DatabaseCleaner.strategy = :truncation, {:except => %w[evenement_vies formulaires types_piece_jointe]}
DatabaseCleaner.strategy = :truncation, { except: %w(evenement_vies formulaires types_piece_jointe) }
if !(defined? SIADETOKEN)
SIADETOKEN = :valid_token
end
SIADETOKEN = :valid_token unless defined? SIADETOKEN
include Warden::Test::Helpers
@ -64,9 +61,9 @@ RSpec.configure do |config|
config.infer_base_class_for_anonymous_controllers = false
config.order = "random"
config.order = 'random'
config.include Devise::TestHelpers, :type => :controller
config.include Devise::TestHelpers, type: :controller
config.include FactoryGirl::Syntax::Methods
end

View file

@ -1,7 +1,7 @@
module ControllerHelpers
def sign_in(user = double('test@localhost.com'))
if user.nil?
allow(request.env['warden']).to receive(:authenticate!).and_throw(:warden, {:scope => :user})
allow(request.env['warden']).to receive(:authenticate!).and_throw(:warden, scope: :user)
allow(controller).to receive(:current_user).and_return(nil)
else
allow(request.env['warden']).to receive(:authenticate!).and_return(user)
@ -11,6 +11,6 @@ module ControllerHelpers
end
RSpec.configure do |config|
config.include Devise::TestHelpers, :type => :controller
config.include ControllerHelpers, :type => :controller
end
config.include Devise::TestHelpers, type: :controller
config.include ControllerHelpers, type: :controller
end

View file

@ -1,6 +1,6 @@
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation, {:except => %w[evenement_vies formulaires types_piece_jointe]})
DatabaseCleaner.clean_with(:truncation, except: %w(evenement_vies formulaires types_piece_jointe))
end
config.before(:each) do

View file

@ -13,4 +13,4 @@ end
RSpec.configure do |config|
config.include FeatureHelpers, type: :feature
end
end

View file

@ -12,4 +12,4 @@ describe 'dossiers/show.html.haml', type: :view do
it 'have autorisation_donnees check box' do
expect(rendered).to have_css('#dossier_autorisation_donnees')
end
end
end