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

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