Permalink
Browse files

dryed a little the specs

  • Loading branch information...
1 parent 090e2c5 commit 2763c90fbeb1642152f6095fcb39be6ff90000de @charly committed Oct 9, 2012
Showing with 13 additions and 26 deletions.
  1. +10 −11 spec/models/cdnjs_spec.rb
  2. +3 −15 spec/models/github_spec.rb
View
@@ -3,9 +3,9 @@
# TODO : TAFT
describe Jail::Cdnjs, :vcr do
+ let(:jail) { Jail::Cdnjs.find("chosen") }
+
describe "#package" do
- let(:jail) { Jail::Cdnjs.find("chosen") }
-
it "holds a Hashie of parsed package.json" do
jail.package.should be_a(Hashie::Mash)
end
@@ -28,30 +28,29 @@
end
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
jail.version_path.to_s.should match(/libs\/chosen\/\d+.\d+.\d+/)
end
end
- describe "#files" do
- let(:jail) { Jail::Cdnjs.find("chosen") }
-
+ describe "#version_files" 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
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
describe "#file(path)" do
- let(:jail) { Jail::Cdnjs.find("chosen") }
-
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
View
@@ -2,18 +2,16 @@
# TODO : TAFT
describe Jail::Github, :vcr do
-
+
+ let(:git) { Jail::Github.find("harvesthq", "chosen") }
+
describe "#github" do
- let(:git) { Jail::Github.find("harvesthq", "chosen") }
-
it "holds a Github::Client (API v3) instance" do
git.github.should be_a(Github::Client)
end
end
describe "#where(path)" do
- let(:git) { Jail::Github.find("harvesthq", "chosen") }
-
it "sets #path to the arg it's passed" do
git.where("/chosen")
git.path.should == "/chosen"
@@ -25,17 +23,13 @@
end
describe "#repos" do
- let(:git) { Jail::Github.find("harvesthq", "chosen") }
-
it "holds a Github::Repo(API v3) response" do
git.repos.should be_a(Hashie::Mash)
git.repos.should respond_to(:owner, :watchers, :full_name, :language)
end
end
describe "#contents" do
- let(:git) { Jail::Github.find("harvesthq", "chosen") }
-
it "holds a Github::Content (API v3) response" do
content = git.contents.first
content.should be_a(Hashie::Mash)
@@ -44,24 +38,18 @@
end
describe "#readme" do
- let(:git) { Jail::Github.find("harvesthq", "chosen") }
-
it "returns the readme decoded" do
git.readme.should match(/Chosen is a library for making/)
end
end
describe "#read" do
- let(:git) { Jail::Github.find("harvesthq", "chosen") }
-
it "decodes the base64 of the current content (if it's a file)" do
git.where("VERSION").read.should match(/\d+.\d+.\d+/)
end
end
describe "#target( type )" do
- let(:git) { Jail::Github.find("harvesthq", "chosen") }
-
it "returns a Pathanme" do
git.where("chosen/chosen.css").target(:js).should ==
Rails.root.join("vendor/assets/javascripts/chosen.css")

0 comments on commit 2763c90

Please sign in to comment.