Project source can be downloaded from https://github.com/agchan12/BigCommerce.git
Andrew Chan
- Gemfile
- gem package control file.
- router.rb
- Controller, map the URL with certain method.
- twitter_client.rb
- Service code, connecting twitter API, fetch data and handle the logic.
- tc_twitter_client.rb
- Unit test code. mainly tesintg Question 3.
- automatic_test.sh
- A shell script, used as automatic test for Question 1 and 2.
The whole project is written in ruby. Please install ruby developement environment first
Then run the following commands in terminal
NOTE: When running "gem install bundler" and it asks for permission. Try "sudo gem install bundler"
gem install bundler
bundle install
This will install all necessary libraries
cd /path/to/folder
ruby router.rb
NOTE: Make sure to have run the command "ruby router.rb" before continuing
cd /path/to/folder
ruby tc_twitter_client.rb
Expected Results
1 tests, 3 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
If you do not see these results, reconfigure testing environment and check that you have followed this Readme file exactly.
Q1 and Q2 only ask to return text value. Using selenium test seems be too much, So I wrote a shell script that act as automatic test.
Running requirement: "curl" command tool must be installed.
NOTE: Make sure to have run the command "ruby router.rb" before continuing
NOTE: If after running the command "sh automatic_test.sh" returns an unexpected operator. Run "bash ./automatic_test.sh"
cd /path/to/folder
sh automatic_test.sh
Results of the automatic test should be:
testing Q1: pass
testing Q2: pass
If you do not see these results, reconfigure testing environment and check that you have followed this Readme file exactly.
NOTE: Make sure to have run the command "ruby router.rb" before continuing
To run this segment of the code, open up the browser and type in the URL
You should be presented with a page with the words
"Try /hello/:name"
To run this segment of the code, open up the browser and type in the URL
http://localhost:4567/hello/[variable]
Where the "[variable]" is the input.
You should be presented with a page with the words "Hello [variable]"
To run this segment of the code, open up the browser and type in the URL
http://localhost:4567/historgram/[variable]
Where the "[variable]" is the Twitter account name.
You should be presented with a page of numbers in the format of
"0":x, "1":x, "2":x ..."
Where the number to the left of the colon represents every hour for the past 24 hours
The x represents an arbitrary number of tweets from that account for the hour respectively.