Created
May 2, 2014 10:55
-
-
Save t-oginogin/11472251 to your computer and use it in GitHub Desktop.
Rails MiniTestでCSVファイルを返すControllerをテストしたい ref: http://qiita.com/t_oginogin/items/04018fd9eb9507e2bec8
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 create_csv | |
| <略> | |
| respond_to do |format| | |
| format.csv { | |
| send_data records.to_csv, :type => 'text/csv', :filename => 'test.csv' | |
| return | |
| } | |
| end | |
| 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
| describe "create_csv" do | |
| it "return csv file" do | |
| get :create_csv | |
| response.body.each_line |line| do | |
| assert_match /\d,\d,\d/, line | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment