diff --git a/Gemfile b/Gemfile index 4796c2d..5b2f54f 100644 --- a/Gemfile +++ b/Gemfile @@ -112,6 +112,7 @@ group :test do gem 'email_spec' gem 'timecop', '0.6.1' # last version compatible to ruby 1.8 gem 'coveralls', :require => false + gem 'mongoid-rspec', :require => false end group :heroku, :production do diff --git a/Gemfile.lock b/Gemfile.lock index 1da086f..f1e72a2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -185,6 +185,10 @@ GEM moped (~> 1.4) origin (~> 1.0) tzinfo (~> 0.3.22) + mongoid-rspec (1.9.0) + mongoid (>= 3.0.1) + rake + rspec (>= 2.14) mongoid_rails_migrations (1.0.1) activesupport (>= 3.2.0) bundler (>= 1.0.0) @@ -288,6 +292,10 @@ GEM rest-client (1.6.7) mime-types (>= 1.16) ri_cal (0.8.8) + rspec (2.14.1) + rspec-core (~> 2.14.0) + rspec-expectations (~> 2.14.0) + rspec-mocks (~> 2.14.0) rspec-core (2.14.5) rspec-expectations (2.14.2) diff-lcs (>= 1.1.3, < 2.0) @@ -412,6 +420,7 @@ DEPENDENCIES lighthouse-api meta_request mongoid (~> 3.1.4) + mongoid-rspec mongoid_rails_migrations (~> 1.0.1) octokit omniauth-github diff --git a/spec/models/app_spec.rb b/spec/models/app_spec.rb index 9367e4d..f523c95 100644 --- a/spec/models/app_spec.rb +++ b/spec/models/app_spec.rb @@ -1,6 +1,14 @@ require 'spec_helper' describe App do + context "Attributes" do + it { should have_field(:_id).of_type(String) } + it { should have_field(:name).of_type(String) } + it { should have_fields(:api_key, :github_repo, :bitbucket_repo, :asset_host, :repository_branch) } + it { should have_fields(:resolve_errs_on_deploy, :notify_all_users, :notify_on_errs, :notify_on_deploys).of_type(Boolean) } + it { should have_field(:email_at_notices).of_type(Array).with_default_value_of(Errbit::Config.email_at_notices) } + end + context 'validations' do it 'requires a name' do app = Fabricate.build(:app, :name => nil) @@ -156,7 +164,6 @@ describe App do end end - context '#find_or_create_err!' do before do @app = Fabricate(:app) @@ -185,7 +192,6 @@ describe App do end end - describe ".find_by_api_key!" do it 'return the app with api_key' do app = Fabricate(:app) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f618312..5ab660e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -23,6 +23,7 @@ require 'database_cleaner' require 'webmock/rspec' require 'xmpp4r' require 'xmpp4r/muc' +require 'mongoid-rspec' # Requires supporting files with custom matchers and macros, etc, @@ -36,6 +37,7 @@ end RSpec.configure do |config| config.mock_with :rspec config.include Devise::TestHelpers, :type => :controller + config.include Mongoid::Matchers, :type => :model config.filter_run :focused => true config.run_all_when_everything_filtered = true config.alias_example_to :fit, :focused => true -- libgit2 0.21.2