Skip to content

Commit

Permalink
Merge pull request mislav#24 from codeforboston/mjz/21-return-legal-s…
Browse files Browse the repository at this point in the history
…tatus

Resolve mislav#21 Return Legal Status
  • Loading branch information
AlexMerritt committed Feb 14, 2017
2 parents c676ab6 + 2165070 commit 795607f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
14 changes: 14 additions & 0 deletions app/models/listing.rb
@@ -1,2 +1,16 @@
class Listing < ApplicationRecord
def illegal?
case self.description
when /no\s*section\s*(8|eight)/i
true
when /professionals\s*only/i
true
when /no\s*students/i
true
when /no\s*couples/i
true
else
return false
end
end
end
25 changes: 24 additions & 1 deletion spec/models/listing_spec.rb
@@ -1,5 +1,28 @@
require 'rails_helper'

RSpec.describe Listing, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
context 'no section eight' do
it 'marks it as illegal' do
listing = build(:listing, description: 'No section eight')
expect(listing.illegal?).to be_truthy
end
end
context 'professionals only' do
it 'marks it as illegal' do
listing = build(:listing, description: 'professionals only')
expect(listing.illegal?).to be_truthy
end
end
context 'no students' do
it 'marks it as illegal' do
listing = build(:listing, description: 'no students')
expect(listing.illegal?).to be_truthy
end
end
context 'no couples' do
it 'marks it as illegal' do
listing = build(:listing, description: 'no couples')
expect(listing.illegal?).to be_truthy
end
end
end
1 change: 1 addition & 0 deletions spec/rails_helper.rb
Expand Up @@ -5,6 +5,7 @@
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'spec_helper'
require 'rspec/rails'
require 'support/factory_girl'
# Add additional requires below this line. Rails is not loaded until this point!

# Requires supporting ruby files with custom matchers and macros, etc, in
Expand Down
3 changes: 3 additions & 0 deletions spec/support/factory_girl.rb
@@ -0,0 +1,3 @@
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end

0 comments on commit 795607f

Please sign in to comment.