upgrade RSpec

This commit is contained in:
Andrew Cantino 2014-08-08 19:59:19 -07:00
parent aec14b2225
commit dfa71d1f45
16 changed files with 58 additions and 48 deletions

View file

@ -88,8 +88,9 @@ group :development, :test do
gem 'vcr'
gem 'dotenv-rails'
gem 'pry'
gem 'rspec-rails', '~> 2.14'
gem 'rspec', '~> 2.14'
gem 'rspec-rails', '~> 2.99'
gem 'rspec', '~> 2.99'
gem 'rspec-collection_matchers'
gem 'shoulda-matchers'
gem 'rr'
gem 'delorean'

View file

@ -238,22 +238,25 @@ GEM
mime-types (>= 1.16)
retriable (1.4.1)
rr (1.1.2)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
rspec (2.99.0)
rspec-core (~> 2.99.0)
rspec-expectations (~> 2.99.0)
rspec-mocks (~> 2.99.0)
rspec-collection_matchers (1.0.0)
rspec-expectations (>= 2.99.0.beta1)
rspec-core (2.99.1)
rspec-expectations (2.99.2)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rspec-rails (2.14.2)
rspec-mocks (2.99.2)
rspec-rails (2.99.0)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-collection_matchers
rspec-core (~> 2.99.0)
rspec-expectations (~> 2.99.0)
rspec-mocks (~> 2.99.0)
rturk (2.12.1)
erector
nokogiri
@ -402,8 +405,9 @@ DEPENDENCIES
rails (= 4.1.4)
rails_12factor
rr
rspec (~> 2.14)
rspec-rails (~> 2.14)
rspec (~> 2.99)
rspec-collection_matchers
rspec-rails (~> 2.99)
rturk (~> 2.12.1)
ruby-growl (~> 4.1.0)
rufus-scheduler (~> 3.0.8)

View file

@ -14,7 +14,7 @@ describe AgentsController do
it "only returns Agents for the current user" do
sign_in users(:bob)
get :index
assigns(:agents).all? {|i| i.user.should == users(:bob) }.should be_true
assigns(:agents).all? {|i| i.user.should == users(:bob) }.should be_truthy
end
end

View file

@ -10,14 +10,14 @@ describe EventsController do
it "only returns Events created by Agents of the current user" do
sign_in users(:bob)
get :index
assigns(:events).all? {|i| i.user.should == users(:bob) }.should be_true
assigns(:events).all? {|i| i.user.should == users(:bob) }.should be_truthy
end
it "can filter by Agent" do
sign_in users(:bob)
get :index, :agent_id => agents(:bob_website_agent)
assigns(:events).length.should == agents(:bob_website_agent).events.length
assigns(:events).all? {|i| i.agent.should == agents(:bob_website_agent) }.should be_true
assigns(:events).all? {|i| i.agent.should == agents(:bob_website_agent) }.should be_truthy
lambda {
get :index, :agent_id => agents(:jane_website_agent)

View file

@ -6,7 +6,7 @@ describe LogsController do
sign_in users(:bob)
get :index, :agent_id => agents(:bob_weather_agent).id
assigns(:logs).length.should == agents(:bob_weather_agent).logs.length
assigns(:logs).all? {|i| i.agent.should == agents(:bob_weather_agent) }.should be_true
assigns(:logs).all? {|i| i.agent.should == agents(:bob_weather_agent) }.should be_truthy
end
it "only loads Agents owned by the current user" do

View file

@ -12,7 +12,7 @@ describe ScenariosController do
describe "GET index" do
it "only returns Scenarios for the current user" do
get :index
assigns(:scenarios).all? {|i| i.user.should == users(:bob) }.should be_true
assigns(:scenarios).all? {|i| i.user.should == users(:bob) }.should be_truthy
end
end
@ -50,7 +50,7 @@ describe ScenariosController do
assigns(:exporter).options[:description].should == scenarios(:bob_weather).description
assigns(:exporter).options[:agents].should == scenarios(:bob_weather).agents
assigns(:exporter).options[:guid].should == scenarios(:bob_weather).guid
assigns(:exporter).options[:source_url].should be_false
assigns(:exporter).options[:source_url].should be_falsey
response.headers['Content-Disposition'].should == 'attachment; filename="bob-s-weather-alert-scenario.json"'
response.headers['Content-Type'].should == 'application/json; charset=utf-8'
JSON.parse(response.body)["name"].should == scenarios(:bob_weather).name

View file

@ -15,7 +15,7 @@ describe UserCredentialsController do
describe "GET index" do
it "only returns UserCredentials for the current user" do
get :index
assigns(:user_credentials).all? {|i| i.user.should == users(:bob) }.should be_true
assigns(:user_credentials).all? {|i| i.user.should == users(:bob) }.should be_truthy
end
end

View file

@ -89,7 +89,7 @@ describe DotHelper do
end
end
describe DotHelper::DotDrawer do
describe "DotHelper::DotDrawer" do
describe "#id" do
it "properly escapes double quotaion and backslash" do
DotHelper::DotDrawer.draw(foo: "") {

View file

@ -20,7 +20,7 @@ describe AgentsExporter do
Time.parse(data[:exported_at]).should be_within(2).of(Time.now.utc)
data[:links].should == [{ :source => 0, :receiver => 1 }]
data[:agents].should == agent_list.map { |agent| exporter.agent_as_json(agent) }
data[:agents].all? { |agent_json| agent_json[:guid].present? && agent_json[:type].present? && agent_json[:name].present? }.should be_true
data[:agents].all? { |agent_json| agent_json[:guid].present? && agent_json[:type].present? && agent_json[:name].present? }.should be_truthy
data[:agents][0].should_not have_key(:propagate_immediately) # can't receive events
data[:agents][1].should_not have_key(:schedule) # can't be scheduled

View file

@ -213,7 +213,7 @@ describe Agent do
@checker.last_check_at.should be_nil
Agents::SomethingSource.async_check(@checker.id)
@checker.reload.last_check_at.should be_within(2).of(Time.now)
@checker.reload.options[:new].should be_true # Show that we save options
@checker.reload.options[:new].should be_truthy # Show that we save options
end
it "should log exceptions" do

View file

@ -60,7 +60,7 @@ describe Agents::GrowlAgent do
end
@checker.register_growl
called.should be_true
called.should be_truthy
end
end
@ -78,7 +78,7 @@ describe Agents::GrowlAgent do
mock(obj).notify(@checker.options[:growl_notification_name],subject,message)
end
@checker.notify_growl(subject,message)
called.should be_true
called.should be_truthy
end
end

View file

@ -323,7 +323,7 @@ describe Agents::HumanTaskAgent do
@checker.send :review_hits
assignments.all? {|a| a.approved == true }.should be_false
assignments.all? {|a| a.approved == true }.should be_falsey
@checker.memory['hits'].should == { "JH3132836336DHG" => { 'event_id' => @event.id } }
end
@ -341,7 +341,7 @@ describe Agents::HumanTaskAgent do
@checker.send :review_hits
assignments.all? {|a| a.approved == true }.should be_false
assignments.all? {|a| a.approved == true }.should be_falsey
@checker.memory['hits'].should == { "JH3132836336DHG" => { 'event_id' => @event.id } }
end
@ -360,7 +360,7 @@ describe Agents::HumanTaskAgent do
@checker.send :review_hits
}.should change { Event.count }.by(1)
assignments.all? {|a| a.approved == true }.should be_true
assignments.all? {|a| a.approved == true }.should be_truthy
hit.should be_disposed
@checker.events.last.payload['answers'].should == [
@ -405,7 +405,7 @@ describe Agents::HumanTaskAgent do
@checker.send :review_hits
}.should change { Event.count }.by(1)
assignments.all? {|a| a.approved == true }.should be_true
assignments.all? {|a| a.approved == true }.should be_truthy
@checker.events.last.payload['answers'].should == [
{ 'sentiment' => "sad", 'age_range' => "<50" },
@ -458,7 +458,7 @@ describe Agents::HumanTaskAgent do
@checker.send :review_hits
}.should change { Event.count }.by(1)
assignments.all? {|a| a.approved == true }.should be_true
assignments.all? {|a| a.approved == true }.should be_truthy
@checker.events.last.payload['answers'].should == [
{ 'rating' => "1" },
@ -520,7 +520,7 @@ describe Agents::HumanTaskAgent do
# it approves the existing assignments
assignments.all? {|a| a.approved == true }.should be_true
assignments.all? {|a| a.approved == true }.should be_truthy
hit.should be_disposed
# it creates a new HIT for the poll
@ -582,7 +582,7 @@ describe Agents::HumanTaskAgent do
# it approves the existing assignments
assignments.all? {|a| a.approved == true }.should be_true
assignments.all? {|a| a.approved == true }.should be_truthy
hit.should be_disposed
@checker.memory['hits'].should be_empty

View file

@ -53,7 +53,7 @@ describe Agents::WeiboPublishAgent do
Agents::WeiboPublishAgent.async_receive(@checker.id, [event.id])
@sent_messages.count.should eq(1)
@checker.events.count.should eq(1)
@sent_messages.first.include?("t.co").should_not be_true
@sent_messages.first.include?("t.co").should_not be_truthy
end
end

View file

@ -172,7 +172,7 @@ describe ScenarioImport do
scenario_import.scenario.description.should == description
scenario_import.scenario.guid.should == guid
scenario_import.scenario.source_url.should == source_url
scenario_import.scenario.public.should be_false
scenario_import.scenario.public.should be_falsey
end
it "creates the Agents" do
@ -186,7 +186,7 @@ describe ScenarioImport do
weather_agent.name.should == "a weather agent"
weather_agent.schedule.should == "5pm"
weather_agent.keep_events_for.should == 14
weather_agent.propagate_immediately.should be_false
weather_agent.propagate_immediately.should be_falsey
weather_agent.should be_disabled
weather_agent.memory.should be_empty
weather_agent.options.should == weather_agent_options
@ -195,7 +195,7 @@ describe ScenarioImport do
trigger_agent.sources.should == [weather_agent]
trigger_agent.schedule.should be_nil
trigger_agent.keep_events_for.should == 0
trigger_agent.propagate_immediately.should be_true
trigger_agent.propagate_immediately.should be_truthy
trigger_agent.should_not be_disabled
trigger_agent.memory.should be_empty
trigger_agent.options.should == trigger_agent_options
@ -272,7 +272,7 @@ describe ScenarioImport do
existing_scenario.description.should == description
existing_scenario.name.should == name
existing_scenario.source_url.should == source_url
existing_scenario.public.should be_false
existing_scenario.public.should be_falsey
end
it "updates any existing agents in the scenario, and makes new ones as needed" do
@ -290,7 +290,7 @@ describe ScenarioImport do
weather_agent.name.should == "a weather agent"
weather_agent.schedule.should == "5pm"
weather_agent.keep_events_for.should == 14
weather_agent.propagate_immediately.should be_false
weather_agent.propagate_immediately.should be_falsey
weather_agent.should be_disabled
weather_agent.memory.should be_empty
weather_agent.options.should == weather_agent_options
@ -299,7 +299,7 @@ describe ScenarioImport do
trigger_agent.sources.should == [weather_agent]
trigger_agent.schedule.should be_nil
trigger_agent.keep_events_for.should == 0
trigger_agent.propagate_immediately.should be_true
trigger_agent.propagate_immediately.should be_truthy
trigger_agent.should_not be_disabled
trigger_agent.memory.should be_empty
trigger_agent.options.should == trigger_agent_options
@ -318,7 +318,7 @@ describe ScenarioImport do
scenario_import.should be_valid
scenario_import.import.should be_true
scenario_import.import.should be_truthy
weather_agent = existing_scenario.agents.find_by(:guid => "a-weather-agent")
weather_agent.name.should == "updated name"
@ -338,7 +338,7 @@ describe ScenarioImport do
}
}
scenario_import.import.should be_false
scenario_import.import.should be_falsey
errors = scenario_import.errors.full_messages.to_sentence
errors.should =~ /Name can't be blank/

View file

@ -32,6 +32,11 @@ RSpec.configure do |config|
# instead of true.
config.use_transactional_fixtures = true
# rspec-rails 3 will no longer automatically infer an example group's spec type
# from the file location. You can explicitly opt-in to this feature using this
# snippet:
config.infer_spec_type_from_file_location!
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.

View file

@ -7,23 +7,23 @@ shared_examples_for WorkingHelpers do
agent.last_error_log_at = 10.minutes.ago
agent.last_event_at = 10.minutes.ago
agent.recent_error_logs?.should be_true
agent.recent_error_logs?.should be_truthy
agent.last_error_log_at = 11.minutes.ago
agent.last_event_at = 10.minutes.ago
agent.recent_error_logs?.should be_true
agent.recent_error_logs?.should be_truthy
agent.last_error_log_at = 5.minutes.ago
agent.last_event_at = 10.minutes.ago
agent.recent_error_logs?.should be_true
agent.recent_error_logs?.should be_truthy
agent.last_error_log_at = 15.minutes.ago
agent.last_event_at = 10.minutes.ago
agent.recent_error_logs?.should be_false
agent.recent_error_logs?.should be_falsey
agent.last_error_log_at = 2.days.ago
agent.last_event_at = 10.minutes.ago
agent.recent_error_logs?.should be_false
agent.recent_error_logs?.should be_falsey
end
end