README.md in onebox-1.8.4 vs README.md in onebox-1.8.5

- old
+ new

@@ -74,11 +74,11 @@ Development Preview Interface ============================= The onebox gem comes with a development server for previewing the results -of your changes. You can run it by running `rake server` after checking +of your changes. You can run it by running `bundle exec rake server` after checking out the project. You can then try out URLs. The server doesn't reload code changes automatically (PRs accepted!) so make sure to hit CTRL-C and restart the server to try a code change out. @@ -90,91 +90,91 @@ If it does, you can probably get away with just whitelisting the URL in `Onebox::Engine::WhitelistedGenericOnebox` (see: [Whitelisted Generic Onebox caveats](#user-content-whitelisted-generic-onebox-caveats)). If the site does not support open standards, you can create a new engine. 2. Create new onebox engine - ``` ruby - # in lib/onebox/engine/name_onebox.rb + ``` ruby + # in lib/onebox/engine/name_onebox.rb - module Onebox - module Engine - class NameOnebox - include LayoutSupport - include HTML + module Onebox + module Engine + class NameOnebox + include LayoutSupport + include HTML - private + private - def data - { - url: @url, - name: raw.css("h1").inner_text, - image: raw.css("#main-image").first["src"], - description: raw.css("#postBodyPS").inner_text - } - end - end - end - end - ``` + def data + { + url: @url, + name: raw.css("h1").inner_text, + image: raw.css("#main-image").first["src"], + description: raw.css("#postBodyPS").inner_text + } + end + end + end + end + ``` 3. Create new onebox spec using [FakeWeb](https://github.com/chrisk/fakeweb) - ``` ruby - # in spec/lib/onebox/engine/name_spec.rb - require "spec_helper" + ``` ruby + # in spec/lib/onebox/engine/name_spec.rb + require "spec_helper" - describe Onebox::Engine::NameOnebox do - let(:link) { "http://example.com" } - let(:html) { described_class.new(link).to_html } + describe Onebox::Engine::NameOnebox do + let(:link) { "http://example.com" } + let(:html) { described_class.new(link).to_html } - before do - fake(link, response("name.response")) - end + before do + fake(link, response("name.response")) + end - it "has the video's title" do - expect(html).to include("title") - end + it "has the video's title" do + expect(html).to include("title") + end - it "has the video's still shot" do - expect(html).to include("photo.jpg") - end + it "has the video's still shot" do + expect(html).to include("photo.jpg") + end - it "has the video's description" do - expect(html).to include("description") - end + it "has the video's description" do + expect(html).to include("description") + end - it "has the URL to the resource" do - expect(html).to include(link) - end - end - ``` + it "has the URL to the resource" do + expect(html).to include(link) + end + end + ``` 4. Create new mustache template - ``` html - # in templates/name.mustache - <div class="onebox"> - <a href="{{url}}"> - <h1>{{name}}</h1> - <h2 class="host">example.com</h2> - <img src="{{image}}" /> - <p>{{description}}</p> - </a> - </div> - ``` + ``` html + # in templates/name.mustache + <div class="onebox"> + <a href="{{url}}"> + <h1>{{name}}</h1> + <h2 class="host">example.com</h2> + <img src="{{image}}" /> + <p>{{description}}</p> + </a> + </div> + ``` 5. Create new fixture from HTML response for your FakeWeb request(s) - ``` bash - curl --output spec/fixtures/oneboxname.response -L -X -GET http://example.com - ``` + ``` bash + curl --output spec/fixtures/oneboxname.response -L -X -GET http://example.com + ``` 6. Require in Engine module - ``` ruby - # in lib/onebox/engine.rb - require_relative "engine/name_onebox" - ``` + ``` ruby + # in lib/onebox/engine.rb + require_relative "engine/name_onebox" + ``` Whitelisted Generic Onebox caveats ==================================