Skip to content

Commit efa84a4

Browse files
authored
Merge pull request #42 from emory-libraries/testing
adds test and switches to generator file with logic
2 parents 24f095f + cf3bbc0 commit efa84a4

5 files changed

Lines changed: 59 additions & 26 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class EmoryLibrariesFooterGenerator < Rails::Generators::Base
2+
desc "this generator copies over everything you need to get started"
3+
source_root File.expand_path("../../templates", __dir__)
4+
5+
# giving them a links file
6+
def write_links_file
7+
# where to look for it?
8+
host_file = File.join(destination_root, "app/views/railsfooter/_footer_links.html.erb")
9+
10+
# IF they don't already have the links file, copy over a blank one.
11+
if File.exist?(host_file)
12+
puts "awesome, you already have your links file"
13+
else
14+
copy_file "_footer_links.html.erb", "app/views/railsfooter/_footer_links.html.erb"
15+
end
16+
end
17+
18+
# giving them a lovely test for their test suite
19+
def write_spec_file
20+
# copy over a test file. will use copy_file? to write/overwrite an existing test file. can instruct to rename the test if they edit?
21+
copy_file "footer_gem_test_spec.rb", "spec/features/footer_gem_test_spec.rb"
22+
end
23+
end

lib/generators/links_file_generator.rb

Lines changed: 0 additions & 26 deletions
This file was deleted.

railsfooter.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
2323
end
2424

2525
spec.add_dependency "rails", ">= 5.0"
26+
spec.executables = [ "railsfooter_setup" ]
2627
end
File renamed without changes.

templates/footer_gem_test_spec.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# frozen_string_literal: true
2+
3+
require 'rails_helper'
4+
5+
RSpec.describe "visit page, there's a footer", type: :feature do
6+
# is the footer placed?
7+
it 'has a footer' do
8+
visit root_path
9+
expect(page).to have_selector("#emory-footer")
10+
end
11+
12+
# and are the links in place?
13+
it 'footer has links' do
14+
visit root_path
15+
expect(page).to have_selector(".footer-list")
16+
end
17+
18+
# can haz selenium test?
19+
# are the styles applied?
20+
it 'footer is emory blue', js: true do
21+
visit root_path
22+
expect(page.find('#emory-footer footer')).to match_style('background-color' => 'rgb(9, 28, 68)')
23+
end
24+
end
25+
26+
# test that the version line is pulling variables
27+
RSpec.describe "version is displaying correctly", type: :feature do
28+
it "shows the version information in the footer" do
29+
stub_const("BRANCH", "branchy-mcversionface")
30+
stub_const("LAST_DEPLOYED", "when it is a damp drizzly november in my soul")
31+
32+
visit root_path
33+
expect(page.find('#emory-footer')).to have_content("Version branchy-mcversionface updated when it is a damp drizzly november in my soul")
34+
end
35+
end

0 commit comments

Comments
 (0)