Skip to content

Commit

Permalink
Merge pull request #12 from Qt-dev/Team_Names
Browse files Browse the repository at this point in the history
Team names
  • Loading branch information
trekkie4life committed Feb 15, 2014
2 parents 43a6d3c + 9a03dad commit 08e8f6b
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
require "bundler/gem_tasks"
require 'rspec/core/rake_task'

desc "Run the specs"
RSpec::Core::RakeTask.new(:spec)
5 changes: 4 additions & 1 deletion lib/cool_faker/data.yml

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions lib/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

module CoolFaker
class Team < Base
@data = self.parse(dir + '/cool_faker/data.yml')

def self.name
"#{@data['adjectives'].sample.capitalize} #{@data['animals'].sample.capitalize}"
end

def self.slogan
data = self.parse(dir + '/cool_faker/data.yml')
data['quotes'].sample
@data['quotes'].sample
end

end
Expand Down
32 changes: 32 additions & 0 deletions specs/data_spec.rb → spec/data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,36 @@
end
end
end

describe "the animals node" do
it "should exist" do
YAML.load_file(FILE).should include("animals")
end

it "should have at least 15 possible animals" do
YAML.load_file(FILE)["animals"].length.should be > 5
end

it "should contain only animals with more than 2 letters" do
YAML.load_file(FILE)["animals"].each do |animal|
animal.length.should be > 2
end
end
end

describe "the adjectives node" do
it "should exist" do
YAML.load_file(FILE).should include("adjectives")
end

it "should have at least 15 possible adjectives" do
YAML.load_file(FILE)["adjectives"].length.should be > 5
end

it "should only give one-word adjectives" do
YAML.load_file(FILE)["adjectives"].each do |adjective|
adjective.split(" ").length.should be 1
end
end
end
end
15 changes: 14 additions & 1 deletion specs/method_spec.rb → spec/method_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
end

it "should select a character from #{movie}" do
names[movie].include?(CoolFaker::Character.name_from(movie))
names[movie].should include(CoolFaker::Character.name_from(movie))
end

end
Expand All @@ -46,4 +46,17 @@

end

describe "team name method" do
it "should return a string" do
CoolFaker::Team.name.should be_a String
end

it "should be shorter than 5 words" do
CoolFaker::Team.name.split(' ').length.should be < 5
end

it "should be longer than 1 word" do
CoolFaker::Team.name.split(' ').length.should be > 1
end
end
end

0 comments on commit 08e8f6b

Please sign in to comment.