This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'sinatra' | |
| require 'nokogiri' | |
| feed = File.read('test/fixtures/feed.xml') | |
| def parse feed | |
| doc = Nokogiri::XML feed | |
| doc.search('item').map do |doc_item| | |
| item = {} | |
| item[:link] = doc_item.at('link').text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def test_it_says_feed_aggregator | |
| get '/' | |
| assert last_response.ok? | |
| assert_match 'Feed Aggregator', last_response.body | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test$ ruby feed_aggregator_test.rb | |
| Run options: | |
| # Running tests: | |
| ...F | |
| Finished tests in 0.251257s, 15.9200 tests/s, 19.8999 assertions/s. | |
| 1) Failure: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'sinatra' | |
| require 'nokogiri' | |
| def parse feed | |
| doc = Nokogiri::XML feed | |
| doc.search('item').map do |doc_item| | |
| item = {} | |
| item[:link] = doc_item.at('link').text | |
| item[:thumbnail] = doc_item.at('media|thumbnail').attr('url') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test$ ruby feed_aggregator_test.rb | |
| Run options: | |
| # Running tests: | |
| .... | |
| Finished tests in 0.062725s, 63.7704 tests/s, 79.7130 assertions/s. | |
| 4 tests, 5 assertions, 0 failures, 0 errors, 0 skips |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'sinatra' | |
| require 'nokogiri' | |
| def parse feed | |
| doc = Nokogiri::XML feed | |
| doc.search('item').map do |doc_item| | |
| item = {} | |
| item[:link] = doc_item.at('link').text | |
| item[:thumbnail] = doc_item.at('media|thumbnail').attr('url') | |
| item[:title] = doc_item.at('title').text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test$ ruby feed_aggregator_test.rb | |
| Run options: | |
| # Running tests: | |
| .F. | |
| Finished tests in 0.078211s, 38.3578 tests/s, 51.1437 assertions/s. | |
| 1) Failure: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def test_find_the_title | |
| feed = File.read('fixtures/feed.xml') | |
| items = parse feed | |
| item = items.first | |
| title = 'An Evening at Shell Beach' | |
| assert_equal item[:title], title | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test$ ruby feed_aggregator_test.rb | |
| Run options: | |
| # Running tests: | |
| ... | |
| Finished tests in 0.045266s, 66.2749 tests/s, 88.3665 assertions/s. | |
| 3 tests, 4 assertions, 0 failures, 0 errors, 0 skips |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'sinatra' | |
| require 'nokogiri' | |
| def parse feed | |
| doc = Nokogiri::XML feed | |
| doc.search('item').map do |doc_item| | |
| item = {} | |
| item[:link] = doc_item.at('link').text | |
| item[:thumbnail] = doc_item.at('media|thumbnail').attr('url') | |
| item |