From 3137a0c84815ade891a13bc2a5c23ecc548d4195 Mon Sep 17 00:00:00 2001 From: Rafael Reggiain Manzo Date: Thu, 23 Jan 2014 16:51:27 -0200 Subject: [PATCH] Tests should pass now! --- app/controllers/repositories_controller.rb | 2 +- features/step_definitions/repository_steps.rb | 2 +- spec/controllers/repositories_controller_spec.rb | 6 +++--- spec/models/configuration_spec.rb | 12 ++++++------ spec/models/mezuro_configuration_spec.rb | 5 ----- spec/routing/configuration_routing_spec.rb | 26 -------------------------- spec/routing/mezuro_configuration_routing_spec.rb | 26 ++++++++++++++++++++++++++ 7 files changed, 37 insertions(+), 42 deletions(-) delete mode 100644 spec/models/mezuro_configuration_spec.rb delete mode 100644 spec/routing/configuration_routing_spec.rb create mode 100644 spec/routing/mezuro_configuration_routing_spec.rb diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 493d623..a89d497 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -108,7 +108,7 @@ private end def set_configuration - @configuration = KalibroGem::Entities::Configuration.find(@repository.configuration_id) #FIXME: As soon as the Configuration model gets created refactor this! + @configuration = MezuroConfiguration.find(@repository.configuration_id) end # Never trust parameters from the scary internet, only allow the white list through. diff --git a/features/step_definitions/repository_steps.rb b/features/step_definitions/repository_steps.rb index 8130230..40baaad 100644 --- a/features/step_definitions/repository_steps.rb +++ b/features/step_definitions/repository_steps.rb @@ -2,7 +2,7 @@ Given(/^I have a sample configuration with native metrics$/) do reading_group = FactoryGirl.create(:reading_group, id: nil) reading = FactoryGirl.create(:reading, {id: nil, group_id: reading_group.id}) range = FactoryGirl.build(:range, {id: nil, reading_id: reading.id, beginning: '-INF', :end => '+INF'}) - @configuration = FactoryGirl.create(:configuration, id: nil) + @configuration = FactoryGirl.create(:mezuro_configuration, id: nil) metric_configuration = FactoryGirl.create(:metric_configuration, {id: nil, metric: FactoryGirl.build(:loc), diff --git a/spec/controllers/repositories_controller_spec.rb b/spec/controllers/repositories_controller_spec.rb index 9c2b87a..76b256c 100644 --- a/spec/controllers/repositories_controller_spec.rb +++ b/spec/controllers/repositories_controller_spec.rb @@ -83,7 +83,7 @@ describe RepositoriesController do before :each do processing = FactoryGirl.build(:processing) - KalibroGem::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) + MezuroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:mezuro_configuration)) Repository.expects(:find).with(repository.id).returns(repository) get :show, id: repository.id.to_s, project_id: project.id.to_s @@ -97,7 +97,7 @@ describe RepositoriesController do before :each do processing = FactoryGirl.build(:processing) - KalibroGem::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) + MezuroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:mezuro_configuration)) Repository.expects(:find).with(repository.id).returns(repository) get :show, id: repository.id.to_s, project_id: project.id.to_s @@ -330,7 +330,7 @@ describe RepositoriesController do subject.expects(:repository_owner?).returns true repository.expects(:process) Repository.expects(:find).at_least_once.with(repository.id).returns(repository) - KalibroGem::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) + MezuroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:mezuro_configuration)) get :process_repository, project_id: project.id.to_s, id: repository.id end it { should render_template(:show) } diff --git a/spec/models/configuration_spec.rb b/spec/models/configuration_spec.rb index 93d05d6..b2de81d 100644 --- a/spec/models/configuration_spec.rb +++ b/spec/models/configuration_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' -describe Configuration do - subject { FactoryGirl.build(:configuration) } +describe MezuroConfiguration do + subject { FactoryGirl.build(:mezuro_configuration) } describe 'methods' do describe 'persisted?' do before :each do - Configuration.expects(:exists?).with(subject.id).returns(false) + MezuroConfiguration.expects(:exists?).with(subject.id).returns(false) end it 'should return false' do @@ -15,7 +15,7 @@ describe Configuration do describe 'update' do before :each do - @subject_params = Hash[FactoryGirl.attributes_for(:configuration).map { |k,v| [k.to_s, v.to_s] }] #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with sybols and integers + @subject_params = Hash[FactoryGirl.attributes_for(:mezuro_configuration).map { |k,v| [k.to_s, v.to_s] }] #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with sybols and integers end context 'with valid attributes' do @@ -43,14 +43,14 @@ describe Configuration do describe 'validations' do context 'active model validations' do before :each do - Configuration.expects(:all).at_least_once.returns([]) + MezuroConfiguration.expects(:all).at_least_once.returns([]) end it { should validate_presence_of(:name) } end context 'kalibro validations' do before :each do - Configuration.expects(:request).returns(42) + MezuroConfiguration.expects(:request).returns(42) end it 'should validate uniqueness' do diff --git a/spec/models/mezuro_configuration_spec.rb b/spec/models/mezuro_configuration_spec.rb deleted file mode 100644 index f29b91e..0000000 --- a/spec/models/mezuro_configuration_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe MezuroConfiguration do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/routing/configuration_routing_spec.rb b/spec/routing/configuration_routing_spec.rb deleted file mode 100644 index 58c8b39..0000000 --- a/spec/routing/configuration_routing_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require "spec_helper" - -describe ConfigurationsController do - describe "routing" do - it { should route(:get, '/configurations/new'). - to(controller: :configurations, action: :new) } - - it { should route(:get, '/configurations'). - to(controller: :configurations, action: :index) } - - it { should route(:post, '/configurations'). - to(controller: :configurations, action: :create) } - - it { should route(:get, '/configurations/1'). - to(controller: :configurations, action: :show, id: "1") } - - it { should route(:get, '/configurations/1/edit'). - to(controller: :configurations, action: :edit, id: "1") } - - it { should route(:put, '/configurations/1'). - to(controller: :configurations, action: :update, id: "1") } - - it { should route(:delete, '/configurations/1'). - to(controller: :configurations, action: :destroy, id: "1") } - end -end \ No newline at end of file diff --git a/spec/routing/mezuro_configuration_routing_spec.rb b/spec/routing/mezuro_configuration_routing_spec.rb new file mode 100644 index 0000000..e41ce1e --- /dev/null +++ b/spec/routing/mezuro_configuration_routing_spec.rb @@ -0,0 +1,26 @@ +require "spec_helper" + +describe MezuroConfigurationsController do + describe "routing" do + it { should route(:get, '/mezuro_configurations/new'). + to(controller: :mezuro_configurations, action: :new) } + + it { should route(:get, '/mezuro_configurations'). + to(controller: :mezuro_configurations, action: :index) } + + it { should route(:post, '/mezuro_configurations'). + to(controller: :mezuro_configurations, action: :create) } + + it { should route(:get, '/mezuro_configurations/1'). + to(controller: :mezuro_configurations, action: :show, id: "1") } + + it { should route(:get, '/mezuro_configurations/1/edit'). + to(controller: :mezuro_configurations, action: :edit, id: "1") } + + it { should route(:put, '/mezuro_configurations/1'). + to(controller: :mezuro_configurations, action: :update, id: "1") } + + it { should route(:delete, '/mezuro_configurations/1'). + to(controller: :mezuro_configurations, action: :destroy, id: "1") } + end +end \ No newline at end of file -- libgit2 0.21.2