Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

split specs

  • Loading branch information...
commit b5b81ef26998803b038f87aed8372883b22b986c 1 parent bb9f0c9
@garybernhardt authored
Showing with 52 additions and 44 deletions.
  1. +10 −44 spec/do_not_want_spec.rb
  2. +42 −0 spec/rails_integration_spec.rb
View
54 spec/do_not_want_spec.rb
@@ -17,15 +17,17 @@ def die!
describe 'do not want' do
let(:walrus) { Walrus.new }
- it "raises an error for unwanted method calls" do
- walrus.should_not_receive(:die!)
- expect do
- walrus.be_killed_by!
- end.to raise_error(DoNotWant::NotSafe)
- end
+ context "method calls" do
+ it "raises an error for unwanted method calls" do
+ walrus.should_not_receive(:die!)
+ expect do
+ walrus.be_killed_by!
+ end.to raise_error(DoNotWant::NotSafe)
+ end
- it "lets other methods through" do
- walrus.class.should == Walrus
+ it "lets other methods through" do
+ walrus.class.should == Walrus
+ end
end
context "caller filtering" do
@@ -42,39 +44,3 @@ def die!
end
end
-ActiveRecord::Base.establish_connection(
- :adapter => "sqlite3",
- :database => ":memory:")
-
-ActiveRecord::Base.connection.create_table(:cheeses) do |t|
- t.string :name
-end
-
-class Cheese < ActiveRecord::Base
-end
-
-describe 'rails integration' do
- let(:cheese) { Cheese.create! }
- it 'rejects unsafe instance methods' do
- DoNotWant::RAILS_INSTANCE_METHOD_THAT_SKIP_VALIDATION.each do |method_name|
- expect do
- cheese.send method_name
- end.to raise_error DoNotWant::NotSafe
- end
- end
-
- it 'allows safe instance methods' do
- cheese.reload
- end
-
- it 'rejects unsafe class methods' do
- DoNotWant::RAILS_CLASS_METHODS_THAT_SKIP_VALIDATION.each do |method_name|
- expect { Cheese.send method_name }.to raise_error DoNotWant::NotSafe
- end
- end
-
- it 'allows safe class methods' do
- Cheese.columns.count.should == 2
- end
-end
-
View
42 spec/rails_integration_spec.rb
@@ -0,0 +1,42 @@
+require 'active_record'
+require 'do_not_want'
+
+class Cheese < ActiveRecord::Base
+end
+
+describe 'rails integration' do
+ before do
+ ActiveRecord::Base.establish_connection(
+ :adapter => "sqlite3",
+ :database => ":memory:")
+
+ ActiveRecord::Base.connection.create_table(:cheeses) do |t|
+ t.string :name
+ end
+ end
+
+ let(:cheese) { Cheese.create! }
+ it 'rejects unsafe instance methods' do
+ DoNotWant::RAILS_INSTANCE_METHOD_THAT_SKIP_VALIDATION.each do |method_name|
+ expect do
+ cheese.send method_name
+ end.to raise_error DoNotWant::NotSafe
+ end
+ end
+
+ it 'allows safe instance methods' do
+ cheese.reload
+ end
+
+ it 'rejects unsafe class methods' do
+ DoNotWant::RAILS_CLASS_METHODS_THAT_SKIP_VALIDATION.each do |method_name|
+ expect { Cheese.send method_name }.to raise_error DoNotWant::NotSafe
+ end
+ end
+
+ it 'allows safe class methods' do
+ Cheese.columns.count.should == 2
+ end
+end
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.