Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

move 'its' specs to subject_spec and reorg a bit

  • Loading branch information...
commit 14d77bf9740364097624f8a6d5416617cd712f63 1 parent 599c0c9
@dchelimsky dchelimsky authored
View
77 spec/rspec/core/example_group_spec.rb
@@ -635,83 +635,6 @@ module RSpec::Core
end
end
- describe "#its" do
- subject do
- Class.new do
- def initialize
- @call_count = 0
- end
- def attribute_call_count
- @call_count += 1
- end
- end.new
- end
-
- its(:attribute_call_count) { should eq(1) }
-
- context "with nil value" do
- subject do
- Class.new do
- def nil_value
- nil
- end
- end.new
- end
- its(:nil_value) { should be_nil }
- end
-
- context "with nested attributes" do
- subject do
- Class.new do
- def name
- "John"
- end
- end.new
- end
- its("name.size") { should == 4 }
- its("name.size.class") { should == Fixnum }
- end
-
- context "when it is a Hash" do
- subject do
- { :attribute => 'value',
- 'another_attribute' => 'another_value' }
- end
- its([:attribute]) { should == 'value' }
- its([:attribute]) { should_not == 'another_value' }
- its([:another_attribute]) { should == 'another_value' }
- its([:another_attribute]) { should_not == 'value' }
- its(:keys) { should =~ ['another_attribute', :attribute] }
- context "when referring to an attribute without the proper array syntax" do
- context "it raises an error" do
- its(:attribute) do
- expect do
- should eq('value')
- end.to raise_error(NoMethodError)
- end
- end
- end
- end
-
- context "calling and overriding super" do
- it "calls to the subject defined in the parent group" do
- group = ExampleGroup.describe(Array) do
- subject { [1, 'a'] }
-
- its(:last) { should == 'a' }
-
- describe '.first' do
- def subject; super().first; end
-
- its(:next) { should == 2 }
- end
- end
-
- group.run.should be_true
- end
- end
-
- end
describe "#top_level_description" do
it "returns the description from the outermost example group" do
View
81 spec/rspec/core/subject_spec.rb
@@ -93,5 +93,86 @@ def ok?; true; end
end
end
+ describe "#its" do
+ subject do
+ Class.new do
+ def initialize
+ @call_count = 0
+ end
+
+ def call_count
+ @call_count += 1
+ end
+ end.new
+ end
+
+ context "with a call counter" do
+ its(:call_count) { should eq(1) }
+ end
+
+ context "with nil value" do
+ subject do
+ Class.new do
+ def nil_value
+ nil
+ end
+ end.new
+ end
+ its(:nil_value) { should be_nil }
+ end
+
+ context "with nested attributes" do
+ subject do
+ Class.new do
+ def name
+ "John"
+ end
+ end.new
+ end
+ its("name") { should eq("John") }
+ its("name.size") { should eq(4) }
+ its("name.size.class") { should eq(Fixnum) }
+ end
+
+ context "when it is a Hash" do
+ subject do
+ { :attribute => 'value',
+ 'another_attribute' => 'another_value' }
+ end
+ its([:attribute]) { should == 'value' }
+ its([:attribute]) { should_not == 'another_value' }
+ its([:another_attribute]) { should == 'another_value' }
+ its([:another_attribute]) { should_not == 'value' }
+ its(:keys) { should =~ ['another_attribute', :attribute] }
+ context "when referring to an attribute without the proper array syntax" do
+ context "it raises an error" do
+ its(:attribute) do
+ expect do
+ should eq('value')
+ end.to raise_error(NoMethodError)
+ end
+ end
+ end
+ end
+
+ context "calling and overriding super" do
+ it "calls to the subject defined in the parent group" do
+ group = ExampleGroup.describe(Array) do
+ subject { [1, 'a'] }
+
+ its(:last) { should == 'a' }
+
+ describe '.first' do
+ def subject; super().first; end
+
+ its(:next) { should == 2 }
+ end
+ end
+
+ group.run.should be_true
+ end
+ end
+
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.