Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
source 'https://rubygems.org'

gem "bronto-gem", git: "https://github.com/hale/bronto.git"

# Specify your gem's dependencies in rails_nlp.gemspec
gemspec
5 changes: 3 additions & 2 deletions lib/rails_nlp/keyword.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'active_record'
require 'text'
require 'bronto-gem'
require 'bronto'

module RailsNlp
class Keyword < ActiveRecord::Base
Expand Down Expand Up @@ -28,7 +28,8 @@ def set_stem
end

def set_synonyms
self.synonyms = BrontoGem.lookup(name)
@thesaurus ||= Bronto::Thesaurus.new
self.synonyms = @thesaurus.lookup(name)
end
end
end
1 change: 1 addition & 0 deletions rails_nlp.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "activerecord", "~> 4.0"
spec.add_runtime_dependency "ffi-hunspell", "~> 0.3.0"
spec.add_runtime_dependency "text", "~> 1.2.3"
spec.add_runtime_dependency "bronto-gem", "~> 0.1.0"
end
11 changes: 10 additions & 1 deletion spec/rails_nlp/keyword_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

module RailsNlp
describe Keyword do
#before(:each) do
#@model = flexmock("analysable model")
#@model.should_receive(:id).and_return(1)
#@model.should_receive(:title).and_return("Title").by_default
#@model.should_receive(:content).and_return("Content").by_default
#@thesaurus = Bronto::Thesaurus.new
#end

it { should validate_presence_of(:name)}
it { should validate_uniqueness_of(:name)}
it { should have_many(:wordcounts) }
Expand Down Expand Up @@ -34,7 +42,8 @@ module RailsNlp
end

it "sets the #synonyms to be an array of synonyms" do
flexmock(BrontoGem).should_receive(:lookup).with("cat").and_return({
thesaurus = Bronto::Thesaurus.new
flexmock(thesaurus).should_receive(:lookup).with("cat").and_return({
noun: { syn: ["adult female", "adult male"]},
verb: { syn: ["barf", "cast", "chuck"]}
})
Expand Down
9 changes: 6 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
require_relative 'factories.rb'
require 'shoulda/matchers'

require 'bronto'


RSpec.configure do |config|
config.order = "random"
config.tty = true
Expand All @@ -19,9 +22,9 @@
raise ActiveRecord::Rollback
end
end
config.before(:all) do
flexmock(BrontoGem).should_receive(:lookup).and_return({}).by_default
end
#config.before(:all) do
# flexmock(BrontoGem).should_receive(:lookup).and_return({}).by_default
#end
end

ActiveRecord::Base.establish_connection(
Expand Down