Skip to content

Commit

Permalink
dryed a little the specs
Browse files Browse the repository at this point in the history
  • Loading branch information
charly committed Oct 9, 2012
1 parent 090e2c5 commit 2763c90
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 26 deletions.
21 changes: 10 additions & 11 deletions spec/models/cdnjs_spec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# TODO : TAFT # TODO : TAFT
describe Jail::Cdnjs, :vcr do describe Jail::Cdnjs, :vcr do


let(:jail) { Jail::Cdnjs.find("chosen") }

describe "#package" do describe "#package" do
let(:jail) { Jail::Cdnjs.find("chosen") }

it "holds a Hashie of parsed package.json" do it "holds a Hashie of parsed package.json" do
jail.package.should be_a(Hashie::Mash) jail.package.should be_a(Hashie::Mash)
end end
Expand All @@ -28,30 +28,29 @@
end end


describe "#version_path" do describe "#version_path" do
let(:jail) { Jail::Cdnjs.find("chosen") } it "returns a Pathname" do
jail.version_path.should be_a(Pathname)
end


it "it has the pathname of latest version" do it "it has the pathname of latest version" do
jail.version_path.to_s.should match(/libs\/chosen\/\d+.\d+.\d+/) jail.version_path.to_s.should match(/libs\/chosen\/\d+.\d+.\d+/)
end end
end end


describe "#files" do describe "#version_files" do
let(:jail) { Jail::Cdnjs.find("chosen") }

it "lists the files in #version_path" do it "lists the files in #version_path" do
jail.files.map(&:path).last.should match(/libs\/chosen\/\d+.\d+.\d+/) jail.version_files.map(&:path).last.should match(/libs\/chosen\/\d+.\d+.\d+/)
end end


it "github API resp listing the (latest) version folder" do it "github API resp listing the (latest) version folder" do
jail.files.map(&:name).should include("chosen-sprite.png", "chosen.css", "chosen.jquery.js") jail.version_files.map(&:name).should include("chosen-sprite.png", "chosen.css", "chosen.jquery.js")
end end
end end


describe "#file(path)" do describe "#file(path)" do
let(:jail) { Jail::Cdnjs.find("chosen") }

it "it holds the github instance with the path" do it "it holds the github instance with the path" do
jail.file("chosen.css").contents.type.should == "file" path = jail.version_path.join("chosen.css")
jail.file(path).contents.type.should == "file"
end end
end end


Expand Down
18 changes: 3 additions & 15 deletions spec/models/github_spec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@


# TODO : TAFT # TODO : TAFT
describe Jail::Github, :vcr do describe Jail::Github, :vcr do


let(:git) { Jail::Github.find("harvesthq", "chosen") }

describe "#github" do describe "#github" do
let(:git) { Jail::Github.find("harvesthq", "chosen") }

it "holds a Github::Client (API v3) instance" do it "holds a Github::Client (API v3) instance" do
git.github.should be_a(Github::Client) git.github.should be_a(Github::Client)
end end
end end


describe "#where(path)" do describe "#where(path)" do
let(:git) { Jail::Github.find("harvesthq", "chosen") }

it "sets #path to the arg it's passed" do it "sets #path to the arg it's passed" do
git.where("/chosen") git.where("/chosen")
git.path.should == "/chosen" git.path.should == "/chosen"
Expand All @@ -25,17 +23,13 @@
end end


describe "#repos" do describe "#repos" do
let(:git) { Jail::Github.find("harvesthq", "chosen") }

it "holds a Github::Repo(API v3) response" do it "holds a Github::Repo(API v3) response" do
git.repos.should be_a(Hashie::Mash) git.repos.should be_a(Hashie::Mash)
git.repos.should respond_to(:owner, :watchers, :full_name, :language) git.repos.should respond_to(:owner, :watchers, :full_name, :language)
end end
end end


describe "#contents" do describe "#contents" do
let(:git) { Jail::Github.find("harvesthq", "chosen") }

it "holds a Github::Content (API v3) response" do it "holds a Github::Content (API v3) response" do
content = git.contents.first content = git.contents.first
content.should be_a(Hashie::Mash) content.should be_a(Hashie::Mash)
Expand All @@ -44,24 +38,18 @@
end end


describe "#readme" do describe "#readme" do
let(:git) { Jail::Github.find("harvesthq", "chosen") }

it "returns the readme decoded" do it "returns the readme decoded" do
git.readme.should match(/Chosen is a library for making/) git.readme.should match(/Chosen is a library for making/)
end end
end end


describe "#read" do describe "#read" do
let(:git) { Jail::Github.find("harvesthq", "chosen") }

it "decodes the base64 of the current content (if it's a file)" do it "decodes the base64 of the current content (if it's a file)" do
git.where("VERSION").read.should match(/\d+.\d+.\d+/) git.where("VERSION").read.should match(/\d+.\d+.\d+/)
end end
end end


describe "#target( type )" do describe "#target( type )" do
let(:git) { Jail::Github.find("harvesthq", "chosen") }

it "returns a Pathanme" do it "returns a Pathanme" do
git.where("chosen/chosen.css").target(:js).should == git.where("chosen/chosen.css").target(:js).should ==
Rails.root.join("vendor/assets/javascripts/chosen.css") Rails.root.join("vendor/assets/javascripts/chosen.css")
Expand Down

0 comments on commit 2763c90

Please sign in to comment.