Commit 91f734da9d6073705c982bf2139fd80c1957ff40

Authored by Cyril Mougel
1 parent a07c943b
Exists in master and in 1 other branch production

Add test about the _id field of App to avoid forget it

@@ -112,6 +112,7 @@ group :test do @@ -112,6 +112,7 @@ group :test do
112 gem 'email_spec' 112 gem 'email_spec'
113 gem 'timecop', '0.6.1' # last version compatible to ruby 1.8 113 gem 'timecop', '0.6.1' # last version compatible to ruby 1.8
114 gem 'coveralls', :require => false 114 gem 'coveralls', :require => false
  115 + gem 'mongoid-rspec', :require => false
115 end 116 end
116 117
117 group :heroku, :production do 118 group :heroku, :production do
@@ -185,6 +185,10 @@ GEM @@ -185,6 +185,10 @@ GEM
185 moped (~> 1.4) 185 moped (~> 1.4)
186 origin (~> 1.0) 186 origin (~> 1.0)
187 tzinfo (~> 0.3.22) 187 tzinfo (~> 0.3.22)
  188 + mongoid-rspec (1.9.0)
  189 + mongoid (>= 3.0.1)
  190 + rake
  191 + rspec (>= 2.14)
188 mongoid_rails_migrations (1.0.1) 192 mongoid_rails_migrations (1.0.1)
189 activesupport (>= 3.2.0) 193 activesupport (>= 3.2.0)
190 bundler (>= 1.0.0) 194 bundler (>= 1.0.0)
@@ -288,6 +292,10 @@ GEM @@ -288,6 +292,10 @@ GEM
288 rest-client (1.6.7) 292 rest-client (1.6.7)
289 mime-types (>= 1.16) 293 mime-types (>= 1.16)
290 ri_cal (0.8.8) 294 ri_cal (0.8.8)
  295 + rspec (2.14.1)
  296 + rspec-core (~> 2.14.0)
  297 + rspec-expectations (~> 2.14.0)
  298 + rspec-mocks (~> 2.14.0)
291 rspec-core (2.14.5) 299 rspec-core (2.14.5)
292 rspec-expectations (2.14.2) 300 rspec-expectations (2.14.2)
293 diff-lcs (>= 1.1.3, < 2.0) 301 diff-lcs (>= 1.1.3, < 2.0)
@@ -412,6 +420,7 @@ DEPENDENCIES @@ -412,6 +420,7 @@ DEPENDENCIES
412 lighthouse-api 420 lighthouse-api
413 meta_request 421 meta_request
414 mongoid (~> 3.1.4) 422 mongoid (~> 3.1.4)
  423 + mongoid-rspec
415 mongoid_rails_migrations (~> 1.0.1) 424 mongoid_rails_migrations (~> 1.0.1)
416 octokit 425 octokit
417 omniauth-github 426 omniauth-github
spec/models/app_spec.rb
1 require 'spec_helper' 1 require 'spec_helper'
2 2
3 describe App do 3 describe App do
  4 + context "Attributes" do
  5 + it { should have_field(:_id).of_type(String) }
  6 + it { should have_field(:name).of_type(String) }
  7 + it { should have_fields(:api_key, :github_repo, :bitbucket_repo, :asset_host, :repository_branch) }
  8 + it { should have_fields(:resolve_errs_on_deploy, :notify_all_users, :notify_on_errs, :notify_on_deploys).of_type(Boolean) }
  9 + it { should have_field(:email_at_notices).of_type(Array).with_default_value_of(Errbit::Config.email_at_notices) }
  10 + end
  11 +
4 context 'validations' do 12 context 'validations' do
5 it 'requires a name' do 13 it 'requires a name' do
6 app = Fabricate.build(:app, :name => nil) 14 app = Fabricate.build(:app, :name => nil)
@@ -156,7 +164,6 @@ describe App do @@ -156,7 +164,6 @@ describe App do
156 end 164 end
157 end 165 end
158 166
159 -  
160 context '#find_or_create_err!' do 167 context '#find_or_create_err!' do
161 before do 168 before do
162 @app = Fabricate(:app) 169 @app = Fabricate(:app)
@@ -185,7 +192,6 @@ describe App do @@ -185,7 +192,6 @@ describe App do
185 end 192 end
186 end 193 end
187 194
188 -  
189 describe ".find_by_api_key!" do 195 describe ".find_by_api_key!" do
190 it 'return the app with api_key' do 196 it 'return the app with api_key' do
191 app = Fabricate(:app) 197 app = Fabricate(:app)
spec/spec_helper.rb
@@ -23,6 +23,7 @@ require &#39;database_cleaner&#39; @@ -23,6 +23,7 @@ require &#39;database_cleaner&#39;
23 require 'webmock/rspec' 23 require 'webmock/rspec'
24 require 'xmpp4r' 24 require 'xmpp4r'
25 require 'xmpp4r/muc' 25 require 'xmpp4r/muc'
  26 +require 'mongoid-rspec'
26 27
27 28
28 # Requires supporting files with custom matchers and macros, etc, 29 # Requires supporting files with custom matchers and macros, etc,
@@ -36,6 +37,7 @@ end @@ -36,6 +37,7 @@ end
36 RSpec.configure do |config| 37 RSpec.configure do |config|
37 config.mock_with :rspec 38 config.mock_with :rspec
38 config.include Devise::TestHelpers, :type => :controller 39 config.include Devise::TestHelpers, :type => :controller
  40 + config.include Mongoid::Matchers, :type => :model
39 config.filter_run :focused => true 41 config.filter_run :focused => true
40 config.run_all_when_everything_filtered = true 42 config.run_all_when_everything_filtered = true
41 config.alias_example_to :fit, :focused => true 43 config.alias_example_to :fit, :focused => true