This repository has been archived by the owner on Aug 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
22 RSpec-Tests, twittercontent displayed in the content-area
- Loading branch information
1 parent
9e0b50b
commit b190039
Showing
9 changed files
with
84 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
class IslandsController < ApplicationController | ||
def index; end | ||
def index | ||
twitter = TwitterService.new | ||
@trend_names = twitter.trend_names | ||
@tweets = twitter.search_tweets('', 5, 'puppy', 'cute') | ||
end | ||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<h1> Wow there is content on this island! </h1> | ||
|
||
<% @tweets.each do |tweet| %> | ||
<h3><%= tweet.user.name %></h3><a href="<%= tweet.url %>"> Show source tweet</a> | ||
<p><%= tweet.text %><p> | ||
|
||
<% tweet.media.each do |item| %> | ||
<img src="<% item.display_url %>" > | ||
<% end %> | ||
<br> | ||
<% end %> |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
consumer_key: consumer_key | ||
consumer_secret: consumer_secret | ||
access_token: consumer_secret | ||
access_token_secret: access_token_secret |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,48 @@ | ||
require 'pry' | ||
require 'rails_helper' | ||
require 'twitter' | ||
|
||
describe 'TwitterService' do | ||
let(:APP_CONFIG) { {"consumer_key"=>"con_key", | ||
"consumer_secret"=>"con_secret", | ||
"access_token"=>"access_tk", | ||
"access_token_secret"=>"access_secret_tk"}} | ||
let(:service) { TwitterService.new} | ||
let(:service) do | ||
TwitterService.new do |config| | ||
config.consumer_key = APP_CONFIG['consumer_key'] | ||
config.consumer_secret = APP_CONFIG['consumer_secret'] | ||
config.access_token = APP_CONFIG['access_token'] | ||
config.access_token_secret = APP_CONFIG['access_token_secret'] | ||
end | ||
end | ||
|
||
context '#initialize' do # pointless test | ||
it 'creates a new TwitterService with given parameters' do | ||
expect(service.class).to eq(TwitterService) | ||
end | ||
end | ||
|
||
context '#trend_names' do | ||
it 'returns the trend names' do | ||
trend_results = Twitter::TrendResults.new(trends: | ||
[{ name: 'Foo', | ||
url: 'http://foo.baz/', | ||
promoted_content: nil, | ||
query: '1', | ||
tweet_volume: 1 }, | ||
{ name: 'Bar', | ||
url: 'http://bar.baz/', | ||
promoted_content: nil, | ||
query: '1', | ||
tweet_volume: 1 }]) | ||
allow(service).to receive(:trends).and_return(trend_results) | ||
expect(service.trend_names).to eq %w(Foo Bar) | ||
end | ||
end | ||
|
||
context 'search_tweets' do | ||
it 'returns a given number of tweets containing specific words ' do | ||
expect(service.search_tweets('', 5, 'puppy', 'cute').first.class) | ||
.to eq(Twitter::Tweet) | ||
expect(service.search_tweets('', 5, 'puppy', 'cute').count).to eq(5) | ||
expect(service.search_tweets('', 5, 'puppy', 'cute').first.text) | ||
.to include('puppy') | ||
end | ||
end | ||
end |