diff --git a/Gemfile b/Gemfile index 4ca15d2..806e1e3 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,6 @@ source 'https://rubygems.org' +gem 'article_json' gem 'google_drive' gem 'sinatra' diff --git a/Gemfile.lock b/Gemfile.lock index 0813269..cac33c3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,6 +3,11 @@ GEM specs: addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) + article_json (0.3.0) + css_parser (~> 1.5) + nokogiri (~> 1.8) + css_parser (1.6.0) + addressable declarative (0.0.10) declarative-option (0.1.0) diff-lcs (1.3) @@ -85,6 +90,7 @@ PLATFORMS ruby DEPENDENCIES + article_json google_drive rack-test rspec diff --git a/app/server.rb b/app/server.rb index ff56aac..13f47c2 100644 --- a/app/server.rb +++ b/app/server.rb @@ -1,5 +1,6 @@ require 'sinatra' require 'yaml' +require 'article_json' require_relative 'config' require_relative 'google_drive_connector' diff --git a/app/views/show.erb b/app/views/show.erb index a5a3286..4c53d97 100644 --- a/app/views/show.erb +++ b/app/views/show.erb @@ -5,5 +5,5 @@
- Lorem ipsum, sit dolor amet. + <%= ArticleJSON::Article.from_google_doc_html(doc.export_as_string('html')).to_html %>
diff --git a/spec/server_spec.rb b/spec/server_spec.rb index 7fde4e4..7985a45 100644 --- a/spec/server_spec.rb +++ b/spec/server_spec.rb @@ -64,11 +64,41 @@ def app title: 'My first document', last_modifying_user: user_double end + let(:html) do + <<~HTML + + + + + + +

+ Simple article +

+

+ +

+

+ It's nice when it works! +

+

+ +

+ + + HTML + end + + before do + allow(document_double) + .to receive(:export_as_string).with('html').and_return(html) + end it 'should return the article page for the given document' do get "/#{doc_id}" expect(last_response).to be_successful expect(last_response.body).to include document_double.title + expect(last_response.body).to include "It's nice when it works!" end end