WpTheme::Versionable specs

This commit is contained in:
erwanlr
2013-03-26 16:04:10 +01:00
parent 40f4057d47
commit ba0af6edda
7 changed files with 78 additions and 202 deletions

View File

@@ -8,9 +8,7 @@ class WpTheme < WpItem
@version = Browser.instance.get(style_url).body[%r{Version:\s([^\s]+)}i, 1]
# Get Version from readme.txt
unless @version
@version = super
end
@version ||= super
end
@version
end

View File

@@ -3,8 +3,10 @@
require 'spec_helper'
describe WpTheme do
it_behaves_like 'WpTheme::Versionable'
subject(:wp_theme) { WpTheme.new(uri, options) }
let(:uri) { URI.parse('http://example.com') }
let(:uri) { URI.parse('http://example.com/') }
let(:options) { { name: 'theme-name' } }
let(:theme_path) { 'wp-content/themes/theme-name/' }

View File

@@ -0,0 +1,16 @@
/* Theme Name: Bueno Version: 1.5.1 Description: Designed by <a href='http://www.woothemes.com'>WooThemes</a>
Author: WooThemes Author URI: http://www.woothemes.com Copyright: (c) 2009 WooThemes.
License: GNU/GPL Version 2 or later. http://www.gnu.org/licenses/gpl.html */ /*
WARNING! DO NOT EDIT THIS FILE! To make it easy to update your theme, you should
not edit the styles in this file. Instead use the custom.css file to add your
styles. You can copy a style from this file and paste it in custom.css and it
will override the style in this file. You have been warned! :) */ /* Default styles
*/ @import "css/reset.css"; /*-------------------------------------------------------------------------------------------
INDEX: 1. SETUP -1.1 Defaults -1.2 Hyperlinks 2. SITE STRUCTURE & APPEARANCE -2.1
Containers & Columns -2.2 Navigation -2.2.1 Drop-down menus -2.3 Header -2.4 Content
-2.5 Sidebar -2.6 Extended Footer -2.7 Footer 3. POSTS -3.1 Typographic Elements
-3.2 Images -3.3 Pagination / WP-Pagenavi 4. WIDGETS -4.1 Generic Widgets -4.2
Specific Widgets -4.3 Extended Footer Widgets 5. COMMENTS -5.1 Comments -5.2 Pingbacks
/ Trackbacks -5.3 Comments Form -5.4 Gravity forms -------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------*/
/* 1. SETUP */ /*-------------------------------------------------------------------------------------------*/

View File

@@ -1,198 +0,0 @@
/* Theme Name: Bueno Version: 1.5.1 Description: Designed by <a href='http://www.woothemes.com'>WooThemes</a>
Author: WooThemes Author URI: http://www.woothemes.com Copyright: (c) 2009 WooThemes.
License: GNU/GPL Version 2 or later. http://www.gnu.org/licenses/gpl.html */ /*
WARNING! DO NOT EDIT THIS FILE! To make it easy to update your theme, you should
not edit the styles in this file. Instead use the custom.css file to add your
styles. You can copy a style from this file and paste it in custom.css and it
will override the style in this file. You have been warned! :) */ /* Default styles
*/ @import "css/reset.css"; /*-------------------------------------------------------------------------------------------
INDEX: 1. SETUP -1.1 Defaults -1.2 Hyperlinks 2. SITE STRUCTURE & APPEARANCE -2.1
Containers & Columns -2.2 Navigation -2.2.1 Drop-down menus -2.3 Header -2.4 Content
-2.5 Sidebar -2.6 Extended Footer -2.7 Footer 3. POSTS -3.1 Typographic Elements
-3.2 Images -3.3 Pagination / WP-Pagenavi 4. WIDGETS -4.1 Generic Widgets -4.2
Specific Widgets -4.3 Extended Footer Widgets 5. COMMENTS -5.1 Comments -5.2 Pingbacks
/ Trackbacks -5.3 Comments Form -5.4 Gravity forms -------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------*/
/* 1. SETUP */ /*-------------------------------------------------------------------------------------------*/
/* 1.1 Defaults */ body { font: 14px Georgia, Times, Serif; line-height: 1.5;
color: #7a7a7a; } h1, h2, h3, h4, h5, h6 { margin: 0; font-family: Arial,Helvetica,Sans-serif;
color: #000; } h1 {font-size: 30px;} h2 {font-size: 24px;} h3 {font-size: 20px;}
h4 {font-size: 18px;} h5 {font-size: 14px;} h6 {font-size: 12px;} p {margin: 0;}
/* 1.2 Hyperlinks */ h1 a:link, h1 a:visited, h2 a:link, h2 a:visited, h3 a:link,
h3 a:visited, h4 a:link, h4 a:visited, h5 a:link, h5 a:visited, h6 a:link, h6
a:visited { text-decoration: none; } h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover,
h5 a:hover, h6 a:hover {text-decoration: underline;} /*-------------------------------------------------------------------------------------------*/
/* 2. SITE STRUCTURE & APPEARANCE */ /*-------------------------------------------------------------------------------------------*/
/* 2.1 Containers & Columns */ #container { } .col-left { float: left; } .col-right
{ float: right; } .col-full { width: 940px; margin: 0 auto; } /* 2.2 Navigation
*/ #navigation { text-transform: uppercase; font-size:11px; background-color:
#000; } .nav, .nav ul { z-index:100; margin:0; padding:0; list-style:none; line-height:1;
} .nav li { float:left; width: auto; } /* 2.2.1 Drop-down menus */ .nav li ul
{ position: absolute; left: -999em; width: 160px; } .nav li ul li { border: 1px
solid #d8d8d8; background: #FFF; border-width: 0 1px 1px; } .nav li ul li a {
width:148px; line-height:25px!important; font-size:11px; color:#555!important;
padding: 0 0 0 10px; } .nav li ul ul { margin: -26px 0 0 158px!important; } .nav
li ul ul li a { } .nav li ul li ul li a { } .nav li:hover ul ul, .nav li:hover
ul ul ul, .nav li:hover ul ul ul ul, .nav li.sfhover ul ul, .nav li.sfhover ul
ul ul, .nav li.sfhover ul ul ul ul { left: -999em; } .nav li:hover ul, .nav li
li:hover ul, .nav li li li:hover ul, .nav li li li li:hover ul, .nav li.sfhover
ul, .nav li li.sfhover ul, .nav li li li.sfhover ul, .nav li li li li.sfhover
ul { left: auto;} .nav li:hover,.nav li.hover { position:static; } /* CATEGORY
NAVIGATION */ #catnav { width: 620px; } #catnav a:link, #catnav a:visited { display:block;
z-index:100; padding:0 20px 0 0; line-height: 50px; font-family: Helvetica, Arial,
sans-serif; text-decoration: none; color: #fff; } #catnav a:hover { text-decoration:
underline; } #catnav li ul { margin-top: -15px; border-top: 1px solid #d8d8d8;
} #catnav li ul a:link, #catnav li ul a:visited { padding: 0 0 0 10px; } #catnav
li ul a:hover { color: #000!important; background: #d8d8d8; } /* PAGES NAVIGATION
*/ #pagenav { margin-top: 20px; } #pagenav a { display:block; z-index:100; margin:
0; padding:0 15px 10px 15px; text-decoration: none; text-transform: uppercase;
font-size: 25px; font-family: Impact, Helvetica, arial, sans-serif; color: #000;
} #pagenav li ul a:link, #pagenav li ul a:visited { padding: 0 0 0 10px; font-family:
Helvetica, Arial, sans-serif !important; font-size: 14px; text-transform: none;
border: none; } #pagenav li.rss a { padding-right: 25px; } /* 2.3 Header */ #topsearch
{ width: 300px; line-height: 0; } #topsearch #searchform_top { margin: 14px 0
0 0; } #header{padding:45px 0;clear:both;position:relative;} #logo { } #logo img
{ } #logo .site-title a { color:#222; font-size:48px; line-height:48px; text-transform:none;
font-weight:normal; text-decoration:none; } #logo .site-title a:hover { text-decoration:underline;
} #logo .site-description { color:#999; font:italic 14px Georgia, serif; } #logo
.site-title, #logo .site-description { display:none; } /* 2.4 Content */ #content{min-height:550px;padding:0;}
* html #content{height:550px;} #main{width:620px;} #main.fullwidth { width: 940px;
} /* 2.5 Sidebar */ #sidebar{width:300px;overflow:hidden;} /* 2.6 Extended Footer
*/ #extended-footer { margin: 50px 0 0 0; padding: 40px 0; } .block { float: left;
width: 300px; padding: 0 10px 0 0; } .one, .two { margin: 0 9px 0 0; } .three
{ padding: 0; } /* 2.7 Footer */ #footer { font-family: Helvetica, Arial, sans-serif;
font-size: 11px; padding: 20px 0; background-color: #000; color: #fff; text-transform:
uppercase; } #footer a:link, #footer a:visited { color: #fff; } #footer p { margin:
5px 0 0 0; } #footer #credit img { vertical-align: middle; } #footer #credit span
{ display: none; } /*-------------------------------------------------------------------------------------------*/
/* 3. POSTS */ /*-------------------------------------------------------------------------------------------*/
#breadcrumb, .archive_header { font-family: Helvetica, Arial, sans-serif; display:
block; margin:10px 0; padding: 0 55px; font-size: 18px; font-weight: bold; color:
#000; } #breadcrumb { font-size: 14px; font-weight: normal; padding: 0; } .archive_header
.catrss a { font-size: 14px; text-decoration: none; line-height: 28px; } .post
{ position: relative; margin: 0 0 60px 0; padding: 50px 55px; background-color:
#fff; border: 5px solid #efefef; } .post .title { width:100%; position:relative;
margin: 0 0 30px 0; padding: 0 0 25px 0; color: #000; border-bottom: 1px solid
#e7e7e7; font-size: 32px; font-family:Arial; } .post .title a:link, .post .title
a:visited { color: #000; } .post .title a:hover { text-decoration: none; } .post
.date { position: absolute; top: 30px; left: -40px; width: 71px; height: 60px;
padding: 10px 0 0 0; text-align: center; color: #fff; } .post .date .day { display:
block; font-size: 36px; line-height: 32px; } .post .date .month { display: block;
font-size: 12px; text-transform: uppercase; font-weight: bold; } .post-meta {
margin: 30px 0 0 0; font-size: 11px; color: #9F9F9F; border-top: 1px solid #c4c4c4;
border-bottom: 1px solid #c4c4c4; } .post-meta li { float: left; width: 154px;
padding: 10px 0 7px 10px; } .post-meta li.categories { border-left: 1px solid
#e7e7e7; border-right: 1px solid #e7e7e7; } .post-meta li span { display: block;
} .post-meta li .head { font-size: 10px; text-transform: uppercase; font-weight:
bold; font-family: Helvetica, Arial, sans-serif; color: #000; } .post-meta li
.body, .post-meta li .body a:link, .post-meta li .body a:visited { font-size:
13px; color: #7a7a7a; font-style: italic; text-decoration: none; } .post img.thumbnail
{ margin: 0 0 20px 0; } .entry {} /* 3.1 Typographic Elements */ .entry h1 {}
.entry h2 {} .entry h3 {} .entry h4 {} .entry h5 {} .entry h6 {} .entry h1, .entry
h2, .entry h3, .entry h4, .entry h5, .entry h6 { margin: 0 0 15px 0; } .entry
p { margin: 0 0 15px 0; } .entry blockquote { padding: 10px 30px; color: #666;
font-style: italic; font-size: 16px; } .entry blockquote p {} .entry ul { margin:
0 0 15px 0; padding: 0 0 0 30px; } .entry ul ul { margin: 0; } .entry ul li {
list-style-type: circle; } .entry ul ul li { list-style-type: disc; } .entry ol
{ margin: 0 0 15px 0; padding: 0 0 0 30px; } .entry ol ol { margin: 0; } .entry
ol li { list-style-type: upper-latin; } .entry ol li ol li { list-style-type:
lower-latin; } /* 3.2 Images */ img.wp-smiley { padding: 0; border: none; } .entry
.alignleft { float: left; width: auto; margin: 10px 15px 10px 0; } .entry .alignright
{ float: right; width: auto; margin: 10px 0 10px 15px; } .entry .aligncenter {
text-align: center; } .entry .wp-caption { padding: 1px; text-align:center; background:#F8F8F4;
border: solid 1px #e6e6e6; } .entry .wp-caption img{ margin:0; padding:4px 0;
background:none; border:0; } .entry .wp-caption-text { margin:0; padding:0; font-size:11px;
text-align:center; } /* 3.3 Pagination / WP-Pagenavi */ .more_entries { margin-top:
-30px; padding: 10px 55px; background-color: #fff; border: 5px solid #efefef;
} .more_entries a { display: block; margin: 0 0 0 0; text-transform: uppercase;
font-weight: bold; text-decoration: none; } .more_entries .wp-pagenavi { margin:
0; text-align: center; } .more_entries .wp-pagenavi a:link, .more_entries .wp-pagenavi
a:visited { display: inline; text-decoration: none !important; padding: 4px 6px!important;
} .more_entries .wp-pagenavi .current, .more_entries .wp-pagenavi .on, .more_entries
.wp-pagenavi a:hover { padding: 4px 7px; font-weight: bold; } .more_entries .wp-pagenavi
.extend { background:none; border:none; } /*-------------------------------------------------------------------------------------------*/
/* 4. WIDGETS */ /*-------------------------------------------------------------------------------------------*/
/* 4.1 Generic Widgets */ .widget { margin: 0 0 30px 0; } .widget h3 { margin:
0; padding: 10px 0; text-transform:uppercase; color: #404040; } .widget ul { clear:both;
} .widget ul li {} .widget ul li a:link, .widget ul li a:visited { display: block;
padding: 0 0 0 25px; line-height: 30px; text-decoration: none; color:#666; } .widget
ul ul { padding: 0 0 0 15px; border-top: none; } .widget_recent_comments li, #twitter
li { padding: 6px 0 6px 10px; line-height: 18px; } /* RESET LI STYLING FOR RECENT
COMMENT & TWITTER */ .widget_recent_comments li a, #twitter a { display: inline;
padding: 0; line-height: 18px!important; background: none!important; border: none!important;
} /* RESET <A> STYLING FOR RECENT COMMENT & TWITTER */ /* 4.2 Specific Widgets
*/ /* FEATURED POSTS */ #featured li { float: left; width: 300px; padding: 10px
0; list-style: none; } #featured li a { padding: 0; background: none; border:
none; } #featured span { display: block; } #featured span.thumb { float: left;
width: 80px; } #featured .right { float: right; width: 200px; font-size: 12px;
line-height: 18px; } #featured .right h4 { margin: 0 0 5px 0; font-size: 14px;
line-height: 18px; } #featured .right h4 a { line-height: 18px; } /* WIDGET FORMS
*/ #searchform { margin: 15px 0 0 0; } input#s, input.field { float: left; width:
216px; padding: 5px 0 5px 5px; } input.submit { display:block; float: right; line-height:
17px; border: none; padding: 4px 5px; color: #fff; text-shadow: 1px 1px 0 #424242;
text-transform: uppercase; font-size: 12px; } .widget .screen-reader-text { display:
none; } /* FLICKR */ #flickr h3 {} #flickr h3 span{color:#0061D8;} #flickr h3
span span{color:#FF1183;} #flickr .flickr_badge_image { width: 75px; float: left;
margin: 15px 34px 0 0; } #flickr .pictures { margin-right: -28px; } #flickr a
img { float: left; display: block;} /* LIFESTREAM */ .widget_lifestream ul li
a { border:none; background:none!important; } .widget_lifestream ul .lifestream_meta
{ color: inherit; } /* TEXT WIDGET */ .textwidget { padding: 10px 0; } /* CALENDAR
*/ #wp-calendar{width:95%;margin-bottom:15px;clear:both;padding:0;} #wp-calendar
caption{padding:10px;} #wp-calendar th,#wp-calendar td{text-align:center;padding:5px;}
#wp-calendar td{background:transparent;} #wp-calendar td,table#wp-calendar th{padding:3px
0;} /* ADS */ #sidebar .ads125 { padding: 0 0 12px 12px; background: #fff; } .ads125
img { margin: 14px 16px 0 0; } /* 4.3 Extended Footer Widgets */ #extended-footer
.widget { margin: 0 0 30px 0; padding: 0 10px; } #extended-footer .widget h3 {
font-size: 16px; margin: 0 0 10px 0; padding: 0; border-bottom: none; } #extended-footer
.widget ul li a { padding: 0; line-height: 24px; background: none; border-bottom:
none; } #extended-footer .widget ul li a:hover { background: none; } #extended-footer
.textwidget { padding: 0; } #extended-footer #flickr .flickr_badge_image { width:
75px; float: left; margin: 15px 25px 0 0; } #extended-footer #flickr .pictures
{ margin-right: -28px; } #extended-footer input#s, #extended-footer input.field
{ width: 210px; } #extended-footer #advert_300x250 { padding-left: 0; padding-right:
0; } #extended-footer .ads125 img { margin: 14px 13px 0 0; } #extended-footer
.widget_recent_comments li, #extended-footer #twitter li { padding: 6px 0 6px
0; } /*-------------------------------------------------------------------------------------------*/
/* 5. COMMENTS */ /*-------------------------------------------------------------------------------------------*/
/* 5.1 Comments */ #comments { position:relative; margin: 0 0 60px 0; padding:
50px 55px; background-color: #fff; border: 5px solid #efefef; } #comments h3{
margin: 0 0 20px 0; } #comments .comment{margin-top:10px;width:100%;list-style-type:none;}
#comments .comment .comment-container { padding: 10px 0; border-bottom: 3px solid
#eee;} #comments .comment-head { margin: 0 0 15px 0; } #comments .comment-head
.avatar { float: left; } #comments .comment-head .avatar img{margin: 0 10px 0
0;vertical-align: middle;border:3px solid #eee;} #comments .comment-head .name
{ display: block; margin: 0 0 -5px 0; font-weight: bold; font-size: 15px; } #comments
.comment-head .date, #comments .comment-head .edit, #comments .comment-head .perma
{ font-size: 11px; } #comments .comment-entry p { margin: 0 0 10px 0;} #comments
ul.children{margin:10px 0 0 25px;padding:0;} #comments .cancel-comment-reply a,
#comments .comment-reply-link { text-transform: uppercase; font-family: helvetica,
arial, sans-serif; font-weight: bold; text-decoration: none; font-size: 11px;}
#comments .navigation { } #comments .navigation a{ display: block; margin: 15px
0 0 0; text-decoration: none; } #comments .navigation a:hover{} /* 5.2 Pingbacks
/ Trackbacks */ #pings { margin: 0 0 60px 0; padding: 50px 55px; background-color:
#fff; border: 5px solid #efefef; } #pings h3 { margin: 0 0 20px 0; } .pinglist
li { margin: 0 0 0 20px; list-style-type: decimal; } .pinglist li .author { font-weight:
bold; font-size: 15px; } .pinglist li .date { font-size: 11px; } .pinglist li
.pingcontent { display: block; margin: 10px 0; } /* 5.3 Comments Form */ #respond
{ margin: 15px 0 0 0; padding: 50px 55px; background-color: #fff; border: 5px
solid #efefef; } #comments #respond { padding: 20px 0; margin: 0; border: none;
} #comments #respond h3 { margin-bottom: 0; } #respond h3 { } #commentform { margin:
15px 0 0 0; } #commentform input.txt { width: 260px; margin: 0 5px 10px 0; padding:
7px 5px; border: 1px solid #eee; } #commentform label { font-family: Helvetica,
Arial, sans-serif; font-size: 11px; text-transform: uppercase; font-weight: bold;
} #commentform textarea { width: 95%!important; padding: 5px; border: 1px solid
#eee; } #commentform #submit { border: none; margin: 20px 0 0 0; padding: 4px
10px; color: #fff; text-shadow: 1px 1px 0 #424242; text-transform: uppercase;
font-size: 12px; } /* 5.4 Gravity forms */ .gfield { margin-bottom: 10px; } .gform_wrapper
.top_label .gfield_label { display:block;float:left; padding-right:20px; width:
100px; margin: 5px 0px 4px !important; } .gform_wrapper input.button { padding:
4px 10px 4px !important; color: #fff !important; text-shadow: 1px 1px 0 #424242;
text-transform: uppercase; font-size: 12px !important; } .gform_wrapper input
{ padding: 7px 3px !important; border: 1px solid #EEE; } .gform_wrapper .top_label
input.large, .gform_wrapper .top_label select.large, .gform_wrapper .top_label
textarea.textarea { width: 350px !important; padding: 7px 3px !important; border:
1px solid #EEE; } .gform_wrapper .entry img, .gform_wrapper img.thumbnail { padding:
0px !important; border: 0px !important; } ul.top_label .clear-multi { clear: none
!important; } .gform_wrapper .gfield_checkbox, .gform_wrapper .gfield_radio {
margin-left: 120px !important; } img.ui-datepicker-trigger { border: 0px !important;
padding: 0px; }</a>

View File

@@ -0,0 +1,58 @@
# encoding: UTF-8
shared_examples 'WpTheme::Versionable' do
let(:fixtures_dir) { MODELS_FIXTURES + '/wp_theme/versionable/' }
describe '#version' do
after do
if @file
body = File.new(fixtures_dir + @file)
stub_request(:get, subject.style_url).to_return(status: 200, body: body)
end
subject.version.should == @expected
end
context 'the version is already sets' do
it 'returns it' do
subject.version = '2.1'
@expected = '2.1'
end
end
context 'when the version is not found' do
let(:file) { 'twentyeleven-unknow.css' }
context 'from the style_url' do
it 'gets it from the readme' do
stub_request(:get, subject.readme_url).to_return(status: 200, body: 'Stable Tag: 1.3.4')
@file = file
@expected = '1.3.4'
end
end
context 'from both style & readme' do
it 'returns nil' do
stub_request(:get, subject.readme_url).to_return(status: 404)
@file = file
@expected = nil
end
end
end
context 'when the stylesheet is inline' do
it 'returns the correct version' do
@file = 'bueno-1.5.1.css'
@expected = '1.5.1'
end
end
it 'returns the correct version' do
@file = 'twentyeleven-1.3.css'
@expected = '1.3'
end
end
end