Skip to content

Commit 485a200

Browse files
committed
adds rspec suite, circleci and implements some basic tests
1 parent c6610e7 commit 485a200

11 files changed

+135
-12
lines changed

.circleci/config.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Ruby CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
4+
#
5+
version: 2
6+
jobs:
7+
build:
8+
docker:
9+
# specify the version you desire here
10+
- image: circleci/ruby:2.4.3-node-browsers
11+
12+
# Specify service dependencies here if necessary
13+
# CircleCI maintains a library of pre-built images
14+
# documented at https://circleci.com/docs/2.0/circleci-images/
15+
# - image: circleci/postgres:9.4
16+
17+
working_directory: ~/repo
18+
19+
steps:
20+
- checkout
21+
22+
# Download and cache dependencies
23+
- restore_cache:
24+
keys:
25+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
26+
# fallback to using the latest cache if no exact match is found
27+
- v1-dependencies-
28+
29+
- run:
30+
name: install dependencies
31+
command: |
32+
bundle install --jobs=4 --retry=3 --path vendor/bundle
33+
34+
- save_cache:
35+
paths:
36+
- ./vendor/bundle
37+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
38+
39+
# run tests!
40+
- run:
41+
name: run tests
42+
command: |
43+
mkdir /tmp/test-results
44+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
45+
46+
bundle exec rspec --format progress \
47+
--format RspecJunitFormatter \
48+
--out /tmp/test-results/rspec.xml \
49+
--format progress \
50+
$TEST_FILES
51+
52+
# collect reports
53+
- store_test_results:
54+
path: /tmp/test-results
55+
- store_artifacts:
56+
path: /tmp/test-results
57+
destination: test-results

.rspec

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--require spec_helper

Gemfile

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ source "https://rubygems.org"
22
gem 'materialize-sass'
33
gem "jekyll", "~> 3.6.2"
44
gem "minima", "~> 2.0"
5+
gem 'rspec'
6+
gem 'capybara'
7+
gem "selenium-webdriver"
8+
gem "chromedriver-helper"
9+
gem "rack-jekyll"
10+
gem "pry"
11+
512

613
group :jekyll_plugins do
714
gem "jekyll-feed", "~> 0.6"

_includes/blog-feed.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div class="card-image">
77
<img src="{{post.image}}">
88
<span class="card-title"><a style="color:white">{{ post.title | escape }}</a></span>
9-
<a class="btn-floating halfway-fab waves-effect waves-light red" href="{{ post.url | relative_url }}"><i class="material-icons">more_horiz</i></a>
9+
<a id="{{post.url}}" class="btn-floating halfway-fab waves-effect waves-light red" href="{{ post.url | relative_url }}"><i class="material-icons">more_horiz</i></a>
1010
</div>
1111
<div class="card-content">
1212
<p>{{post.excerpt}}</p>

_site/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ Or install it yourself as:
5151
5252
The ```_config.yml``` file has the following options.
5353

54+
Please ensure to copy this sample before serving up your site as some variables are required in order to make the site run correctly.
55+
5456
```yaml
5557
title: Your awesome title
5658
name: Your Name
5759
5860
description: Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.
5961
62+
theme: jekyll-material-theme
63+
6064
parallax_image_one: assets/images/startup3.jpg # These are the images used for the parallax background
6165
parallax_image_two: assets/images/startup3.jpg
6266

_site/feed.xml

+1-1
Large diffs are not rendered by default.

_site/index.html

+1-1
Large diffs are not rendered by default.

_site/material-theme.gemspec

+10-7
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@ Gem::Specification.new do |spec|
1010
spec.homepage = "https://github.com/jameshamann/jekyll-material-theme"
1111
spec.license = "MIT"
1212

13-
spec.files = `git ls-files -z`.split("\x0").select { |f| f.match(%r{^(js|css|assets|_layouts|_includes|_posts|LICENSE|README)}i) }
13+
spec.files = `git ls-files -z`.split("\x0").select { |f| f.match(%r{^(js|css|assets|_layouts|_includes|_posts|LICENSE|README|_config.yml)}i) }
1414

1515
spec.add_runtime_dependency "jekyll", "~> 3.5"
16-
spec.add_runtime_dependency "jekyll-assets"
17-
spec.add_runtime_dependency "jekyll-minifier"
18-
spec.add_runtime_dependency "jekyll-feed"
19-
spec.add_runtime_dependency "kramdown"
20-
21-
16+
spec.add_runtime_dependency "jekyll-assets", "~> 3.0"
17+
spec.add_runtime_dependency "jekyll-minifier", "~> 0.1"
18+
spec.add_runtime_dependency "jekyll-feed", "~> 0.9"
19+
spec.add_runtime_dependency "kramdown", "~> 1.16"
2220

2321

2422
spec.add_development_dependency "bundler", "~> 1.12"
2523
spec.add_development_dependency "rake", "~> 10.0"
24+
spec.add_development_dependency "capybara", "~> 10.0"
25+
spec.add_development_dependency "rspec", "~> 3.7"
26+
spec.add_development_dependency "selenium-webdriver", "~> 3.8"
27+
28+
2629
end

material-theme.gemspec

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ Gem::Specification.new do |spec|
1919
spec.add_runtime_dependency "kramdown", "~> 1.16"
2020

2121

22-
23-
2422
spec.add_development_dependency "bundler", "~> 1.12"
2523
spec.add_development_dependency "rake", "~> 10.0"
24+
spec.add_development_dependency "capybara", "~> 10.0"
25+
spec.add_development_dependency "rspec", "~> 3.7"
26+
spec.add_development_dependency "selenium-webdriver", "~> 3.8"
27+
28+
2629
end

spec/material_theme_spec.rb

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require "spec_helper"
2+
3+
4+
describe "Website Loads Up", type: :feature, js: true do
5+
it "has the page title" do
6+
visit '/'
7+
8+
expect(page).to have_content('Your awesome title')
9+
expect(page).to have_content('Portfolio')
10+
11+
end
12+
it "renders the blog post page" do
13+
visit '/'
14+
15+
click_link('/2017/12/04/hello-world/')
16+
expect(page).to have_content('Hello World!')
17+
18+
end
19+
end

spec/spec_helper.rb

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Require all of the necessary gems
2+
require 'yaml'
3+
require 'rspec'
4+
require 'capybara/rspec'
5+
require 'rack/jekyll'
6+
require 'rack/test'
7+
require 'pry'
8+
9+
RSpec.configure do |config|
10+
config.expect_with :rspec do |expectations|
11+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
12+
end
13+
14+
config.mock_with :rspec do |mocks|
15+
mocks.verify_partial_doubles = true
16+
end
17+
18+
# Configure Capybara to use Selenium.
19+
Capybara.register_driver :selenium do |app|
20+
# Configure selenium to use Chrome.
21+
Capybara::Selenium::Driver.new(app, :browser => :chrome)
22+
end
23+
24+
# Configure Capybara to load the website through rack-jekyll.
25+
# (force_build: true) builds the site before the tests are run,
26+
# so our tests are always running against the latest version
27+
# of our jekyll site.
28+
Capybara.app = Rack::Jekyll.new(force_build: true)
29+
end

0 commit comments

Comments
 (0)