-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first cucumber tests, all pass. NOTE: you need both rspec and cucumbe…
…r gems (it uses rspec "should" and whatnot)
- Loading branch information
Jake McGinty
committed
Feb 26, 2012
1 parent
f4ad1f1
commit 9842bee
Showing
5 changed files
with
59 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
require 'cucumber/rake/task' | ||
require 'cucumber/rake/task' | ||
|
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,33 @@ | ||
$:.push File.join(File.dirname(__FILE__),'..','..','lib') | ||
begin require 'rspec/expectations'; rescue LoadError; require 'spec/expectations'; end | ||
require 'twitter-sentiment/parser/text_mood' | ||
|
||
Before do | ||
@text_mood = nil | ||
end | ||
|
||
After do | ||
end | ||
|
||
Given /I start an instance initialized with '(.*)'/ do |file| | ||
file = file[1..-1].to_sym if file[0] == ":" # convert to symbol from string if that's what's passed | ||
begin | ||
@text_mood = TwitterSentiment::Parser::TextMood.new(file) | ||
rescue Exception => e | ||
@text_mood = Exception.new | ||
end | ||
end | ||
|
||
When /I ask the score of '(.*)'/ do |word| | ||
@result = @text_mood.score word | ||
end | ||
|
||
Then /the score returned should be '(.*)'/ do |result| | ||
result = result == 'nil' ? nil : result.to_f | ||
|
||
@result.should == result | ||
end | ||
|
||
Then /an exception should be thrown/ do | ||
@text_mood.is_a? Exception | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Feature: Text Mood Parsing | ||
In order to make sure the dictionary bag-of-words with weightings is parsed without mistakes | ||
I am going to pass in a known legal file and request it be parsed and report back a score | ||
|
||
Scenario: Initializing with a symbol | ||
Given I start an instance initialized with ':afinn' | ||
When I ask the score of 'assfucking' | ||
Then the score returned should be '-4' | ||
|
||
Scenario: Initializing with a legit filepath string | ||
Given I start an instance initialized with 'dict/AFINN-111.txt' | ||
When I ask the score of 'assfucking' | ||
Then the score returned should be '-4' | ||
|
||
Scenario: Initialize with a nonexistent filepath string | ||
Given I start an instance initialized with 'dict/thisnameshouldneverexist.diggisthebest.justkidding' | ||
Then an exception should be thrown | ||
|
||
Scenario: Initializing with a legit filepath string | ||
Given I start an instance initialized with 'dict/AFINN-111.txt' | ||
When I ask the score of 'darthvaderinaspeedo' | ||
Then the score returned should be 'nil' |
This file was deleted.
Oops, something went wrong.
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