spec/rspec/its_spec.rb in rspec-its-1.0.1 vs spec/rspec/its_spec.rb in rspec-its-1.1.0
- old
+ new
@@ -20,10 +20,18 @@
@call_count += 1
end
end.new
end
+ before(:each, :meta) do
+ subject.call_count
+ end
+
+ context "with some metadata" do
+ its(:call_count, :meta) { should eq(2) }
+ end
+
context "with a call counter" do
its(:call_count) { should eq(1) }
end
context "with nil value" do
@@ -84,10 +92,24 @@
should eq(64)
end.to raise_error(NoMethodError)
end
end
end
+
+ context "when it's a hash" do
+ subject { {:a => {:deep => {:key => "value"}}} }
+
+ its([:a]) { should eq({:deep => {:key => "value"}}) }
+ its([:a, :deep]) { should eq({:key => "value"}) }
+ its([:a, :deep, :key]) { should eq("value") }
+
+ context "when referring to a key that doesn't exist" do
+ its([:not_here]) { should be_nil }
+ its([:a, :ghost]) { should be_nil }
+ its([:deep, :ghost]) { expect { should eq("missing") }.to raise_error(NoMethodError) }
+ end
+ end
end
context "when it does not respond to #[]" do
subject { Object.new }
@@ -180,11 +202,14 @@
group = RSpec::Core::ExampleGroup.describe(Array) do
include shared
end
group.run(NullFormatter.new)
- # Using to_h[:status].to_sym in following instead of .status due to need to run in RSpec 2.99
- expect(group.children.first.examples.first.execution_result.to_h[:status].to_sym).to eq(:passed)
+
+ result = group.children.first.examples.first.execution_result
+ # Following conditional needed to work across mix of RSpec and ruby versions without warning
+ status = result.respond_to?(:status) ? result.status : result[:status].to_sym
+ expect(status).to eq(:passed)
end
end
end
end
end