Created
October 18, 2012 18:04
-
-
Save kylewelsby/3913805 to your computer and use it in GitHub Desktop.
Example for NWRUG visitor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rspec' | |
class Risk | |
def code(user) | |
user_site = user.site[0..1] | |
if department | |
department_name = department.name[0..1] | |
end | |
[user_site,department_name,"001"].compact.join('-').upcase | |
end | |
# def department | |
# Department.new() | |
# sleep 10 | |
# end | |
end | |
# class Department | |
# def initialize | |
# sleep 10 | |
# end | |
# def name | |
# end | |
# end | |
describe Risk do | |
let(:current_user) {mock "User", :site => "Atherton"} | |
let(:department) {mock "Department", :name => "All Departments"} | |
describe ".code" do | |
context "with department" do | |
it "returns AT-AL-0001" do | |
subject.stub(:department).and_return(department) | |
subject.code(current_user).should eql "AT-AL-001" | |
end | |
end | |
context "without department" do | |
it "returns AT-001" do | |
subject.stub(:department) | |
subject.code(current_user).should eql "AT-001" | |
end | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment